@@ -1,4 +1,4 @@
1−import ./make-test.nix ({ pkgs, ... }:
1+import ./make-test-python.nix ({ pkgs, ... }:
22
33let
44 passphrase = "supersecret";
@@ -106,60 +106,70 @@ in {
106106 };
107107
108108 testScript = ''
109− startAll;
110−
111− $client->fail('test -d "${remoteRepo}"');
112−
113− $client->succeed("cp ${privateKey} /root/id_ed25519");
114− $client->succeed("chmod 0600 /root/id_ed25519");
115− $client->succeed("cp ${privateKeyAppendOnly} /root/id_ed25519.appendOnly");
116− $client->succeed("chmod 0600 /root/id_ed25519.appendOnly");
117−
118− $client->succeed("mkdir -p ${dataDir}");
119− $client->succeed("touch ${dataDir}/${excludeFile}");
120− $client->succeed("echo '${keepFileData}' > ${dataDir}/${keepFile}");
121−
122− subtest "local", sub {
123− my $borg = "BORG_PASSPHRASE='${passphrase}' borg";
124− $client->systemctl("start --wait borgbackup-job-local");
125− $client->fail("systemctl is-failed borgbackup-job-local");
126− # Make sure exactly one archive has been created
127− $client->succeed("c=\$($borg list '${localRepo}' | wc -l) && [[ \$c == '1' ]]");
128− # Make sure excludeFile has been excluded
129− $client->fail("$borg list '${localRepo}::${archiveName}' | grep -qF '${excludeFile}'");
130− # Make sure keepFile has the correct content
131− $client->succeed("$borg extract '${localRepo}::${archiveName}'");
132− $client->succeed('c=$(cat ${dataDir}/${keepFile}) && [[ "$c" == "${keepFileData}" ]]');
133− # Make sure the same is true when using `borg mount`
134− $client->succeed("mkdir -p /mnt/borg && $borg mount '${localRepo}::${archiveName}' /mnt/borg");
135− $client->succeed('c=$(cat /mnt/borg/${dataDir}/${keepFile}) && [[ "$c" == "${keepFileData}" ]]');
136− };
137−
138− subtest "remote", sub {
139− my $borg = "BORG_RSH='ssh -oStrictHostKeyChecking=no -i /root/id_ed25519' borg";
140− $server->waitForUnit("sshd.service");
141− $client->waitForUnit("network.target");
142− $client->systemctl("start --wait borgbackup-job-remote");
143− $client->fail("systemctl is-failed borgbackup-job-remote");
144−
145− # Make sure we can't access repos other than the specified one
146− $client->fail("$borg list borg\@server:wrong");
147−
148− #TODO: Make sure that data is actually deleted
149− };
150−
151− subtest "remoteAppendOnly", sub {
152− my $borg = "BORG_RSH='ssh -oStrictHostKeyChecking=no -i /root/id_ed25519.appendOnly' borg";
153− $server->waitForUnit("sshd.service");
154− $client->waitForUnit("network.target");
155− $client->systemctl("start --wait borgbackup-job-remoteAppendOnly");
156− $client->fail("systemctl is-failed borgbackup-job-remoteAppendOnly");
157−
158− # Make sure we can't access repos other than the specified one
159− $client->fail("$borg list borg\@server:wrong");
160−
161− #TODO: Make sure that data is not actually deleted
162− };
163−
109+ start_all()
110+
111+ client.fail('test -d "${remoteRepo}"')
112+
113+ client.succeed(
114+ "cp ${privateKey} /root/id_ed25519"
115+ )
116+ client.succeed("chmod 0600 /root/id_ed25519")
117+ client.succeed(
118+ "cp ${privateKeyAppendOnly} /root/id_ed25519.appendOnly"
119+ )
120+ client.succeed("chmod 0600 /root/id_ed25519.appendOnly")
121+
122+ client.succeed("mkdir -p ${dataDir}")
123+ client.succeed("touch ${dataDir}/${excludeFile}")
124+ client.succeed("echo '${keepFileData}' > ${dataDir}/${keepFile}")
125+
126+ with subtest("local"):
127+ borg = "BORG_PASSPHRASE='${passphrase}' borg"
128+ client.systemctl("start --wait borgbackup-job-local")
129+ client.fail("systemctl is-failed borgbackup-job-local")
130+ # Make sure exactly one archive has been created
131+ assert int(client.succeed("{} list '${localRepo}' | wc -l".format(borg))) > 0
132+ # Make sure excludeFile has been excluded
133+ client.fail(
134+ "{} list '${localRepo}::${archiveName}' | grep -qF '${excludeFile}'".format(borg)
135+ )
136+ # Make sure keepFile has the correct content
137+ client.succeed("{} extract '${localRepo}::${archiveName}'".format(borg))
138+ assert "${keepFileData}" in client.succeed("cat ${dataDir}/${keepFile}")
139+ # Make sure the same is true when using `borg mount`
140+ client.succeed(
141+ "mkdir -p /mnt/borg && {} mount '${localRepo}::${archiveName}' /mnt/borg".format(
142+ borg
143+ )
144+ )
145+ assert "${keepFileData}" in client.succeed(
146+ "cat /mnt/borg/${dataDir}/${keepFile}"
147+ )
148+
149+ with subtest("remote"):
150+ borg = "BORG_RSH='ssh -oStrictHostKeyChecking=no -i /root/id_ed25519' borg"
151+ server.wait_for_unit("sshd.service")
152+ client.wait_for_unit("network.target")
153+ client.systemctl("start --wait borgbackup-job-remote")
154+ client.fail("systemctl is-failed borgbackup-job-remote")
155+
156+ # Make sure we can't access repos other than the specified one
157+ client.fail("{} list borg\@server:wrong".format(borg))
158+
159+ # TODO: Make sure that data is actually deleted
160+
161+ with subtest("remoteAppendOnly"):
162+ borg = (
163+ "BORG_RSH='ssh -oStrictHostKeyChecking=no -i /root/id_ed25519.appendOnly' borg"
164+ )
165+ server.wait_for_unit("sshd.service")
166+ client.wait_for_unit("network.target")
167+ client.systemctl("start --wait borgbackup-job-remoteAppendOnly")
168+ client.fail("systemctl is-failed borgbackup-job-remoteAppendOnly")
169+
170+ # Make sure we can't access repos other than the specified one
171+ client.fail("{} list borg\@server:wrong".format(borg))
172+
173+ # TODO: Make sure that data is not actually deleted
164174 '';
165175})