bsdtar: test passphrase for appended archives

Exercise --passphrase while copying entries from an encrypted
@archive into a new archive, then extract the result and verify the
copied file contents.
This commit is contained in:
Peiwei Hu committed 2026-08-03 08:49:51 +08:00
1 parent 0d71fa2ad7
commit 7bd12a903f
1 file changed
+19
+19
View File
@@ -21,4 +21,23 @@ DEFINE_TEST(test_option_passphrase)
assertTextFileContents("contents of file2.\n", "file2");
assertEmptyFile("test.out");
assertEmptyFile("test.err");
/* The passphrase must also be applied to archives read via @archive. */
failure("--passphrase option is broken with @archive");
assertEqualInt(0, systemf(
"%s --passphrase pass1 -cf append.tar @%s "
">append-create.out 2>append-create.err",
testprog, reffile));
assertEmptyFile("append-create.out");
assertEmptyFile("append-create.err");
assertMakeDir("append", 0755);
assertEqualInt(0, systemf(
"%s -xf append.tar -C append "
">append-extract.out 2>append-extract.err",
testprog));
assertTextFileContents("contents of file1.\n", "append/file1");
assertTextFileContents("contents of file2.\n", "append/file2");
assertEmptyFile("append-extract.out");
assertEmptyFile("append-extract.err");
}