Commit 4c3c658e2594d1f1a5eab530d744d62a1f22d269
1 parent
38042fa2
Fix tests with password-protected files
Showing
4 changed files
with
35 additions
and
33 deletions
qpdf/qtest/encryption.test
| @@ -373,9 +373,9 @@ $td->runtest("show-encryption works invalid password", | @@ -373,9 +373,9 @@ $td->runtest("show-encryption works invalid password", | ||
| 373 | $td->NORMALIZE_NEWLINES); | 373 | $td->NORMALIZE_NEWLINES); |
| 374 | 374 | ||
| 375 | my @cenc = ( | 375 | my @cenc = ( |
| 376 | - [11, 'hybrid-xref.pdf', "''", 'r2', "", ""], | ||
| 377 | - [12, 'hybrid-xref.pdf', "''", 'r3', "", ""], | ||
| 378 | - [15, 'hybrid-xref.pdf', "''", 'r4', "", ""], | 376 | + [11, 'hybrid-xref.pdf', "''", 'r2', "", "user1"], |
| 377 | + [12, 'hybrid-xref.pdf', "''", 'r3', "", "user2"], | ||
| 378 | + [15, 'hybrid-xref.pdf', "''", 'r4', "", "user2"], | ||
| 379 | [17, 'hybrid-xref.pdf', "''", 'r5', "", "owner3"], | 379 | [17, 'hybrid-xref.pdf', "''", 'r5', "", "owner3"], |
| 380 | [18, 'hybrid-xref.pdf', "''", 'r6', "", "user4"], | 380 | [18, 'hybrid-xref.pdf', "''", 'r6', "", "user4"], |
| 381 | [13, 'c-r2.pdf', 'user1', 'decrypt with user', | 381 | [13, 'c-r2.pdf', 'user1', 'decrypt with user', |
| @@ -404,7 +404,7 @@ foreach my $d (@cenc) | @@ -404,7 +404,7 @@ foreach my $d (@cenc) | ||
| 404 | if (-f $pdf_outfile) | 404 | if (-f $pdf_outfile) |
| 405 | { | 405 | { |
| 406 | $td->runtest("check $description content", | 406 | $td->runtest("check $description content", |
| 407 | - {$td->COMMAND => "qpdf-test-compare a.pdf $pdf_outfile"}, | 407 | + {$td->COMMAND => "qpdf-test-compare a.pdf $pdf_outfile $checkpass"}, |
| 408 | {$td->FILE => $pdf_outfile, $td->EXIT_STATUS => 0}); | 408 | {$td->FILE => $pdf_outfile, $td->EXIT_STATUS => 0}); |
| 409 | } | 409 | } |
| 410 | else | 410 | else |
| @@ -413,7 +413,8 @@ foreach my $d (@cenc) | @@ -413,7 +413,8 @@ foreach my $d (@cenc) | ||
| 413 | # /Perms static, so we have no way to predictably create a | 413 | # /Perms static, so we have no way to predictably create a |
| 414 | # /V=5 encrypted file. It's not worth adding this...the test | 414 | # /V=5 encrypted file. It's not worth adding this...the test |
| 415 | # suite is adequate without having a statically predictable | 415 | # suite is adequate without having a statically predictable |
| 416 | - # file. | 416 | + # file. (qpdf-test-compare ignores /Perms, but it's not worth |
| 417 | + # adding output files for these cases.) | ||
| 417 | $td->runtest("check $description", | 418 | $td->runtest("check $description", |
| 418 | {$td->COMMAND => | 419 | {$td->COMMAND => |
| 419 | "qpdf --check a.pdf --password=$checkpass"}, | 420 | "qpdf --check a.pdf --password=$checkpass"}, |
qpdf/qtest/pages-tree.test
| @@ -24,7 +24,7 @@ $td->runtest("linearize duplicated pages", | @@ -24,7 +24,7 @@ $td->runtest("linearize duplicated pages", | ||
| 24 | $td->EXIT_STATUS => 3}, | 24 | $td->EXIT_STATUS => 3}, |
| 25 | $td->NORMALIZE_NEWLINES); | 25 | $td->NORMALIZE_NEWLINES); |
| 26 | $td->runtest("compare files", | 26 | $td->runtest("compare files", |
| 27 | - {$td->COMMAND => "qpdf-test-compare a.pdf"}, | 27 | + {$td->COMMAND => "qpdf-test-compare a.pdf linearize-duplicate-page.pdf"}, |
| 28 | {$td->FILE => "linearize-duplicate-page.pdf", $td->EXIT_STATUS => 0}); | 28 | {$td->FILE => "linearize-duplicate-page.pdf", $td->EXIT_STATUS => 0}); |
| 29 | $td->runtest("extract duplicated pages", | 29 | $td->runtest("extract duplicated pages", |
| 30 | {$td->COMMAND => | 30 | {$td->COMMAND => |
qpdf/qtest/qpdfjob.test
| @@ -30,18 +30,18 @@ my @bad_json = ( | @@ -30,18 +30,18 @@ my @bad_json = ( | ||
| 30 | "json-error" | 30 | "json-error" |
| 31 | ); | 31 | ); |
| 32 | my @good_json = ( | 32 | my @good_json = ( |
| 33 | - "choice-match", | ||
| 34 | - "input-file-password", | ||
| 35 | - "empty-input", | ||
| 36 | - "replace-input", | ||
| 37 | - "encrypt-40", | ||
| 38 | - "encrypt-128", | ||
| 39 | - "encrypt-256-with-restrictions", | ||
| 40 | - "add-attachments", | ||
| 41 | - "copy-attachments", | ||
| 42 | - "underlay-overlay", | ||
| 43 | - "underlay-overlay-password", | ||
| 44 | - "misc-options", | 33 | + ["choice-match", ""], |
| 34 | + ["input-file-password", "user"], | ||
| 35 | + ["empty-input", ""], | ||
| 36 | + ["replace-input", ""], | ||
| 37 | + ["encrypt-40", "u"], | ||
| 38 | + ["encrypt-128", "u"], | ||
| 39 | + ["encrypt-256-with-restrictions", "u"], | ||
| 40 | + ["add-attachments", ""], | ||
| 41 | + ["copy-attachments", ""], | ||
| 42 | + ["underlay-overlay", ""], | ||
| 43 | + ["underlay-overlay-password", ""], | ||
| 44 | + ["misc-options", ""], | ||
| 45 | ); | 45 | ); |
| 46 | my $n_tests = 11 + scalar(@bad_json) + (2 * scalar(@good_json)); | 46 | my $n_tests = 11 + scalar(@bad_json) + (2 * scalar(@good_json)); |
| 47 | 47 | ||
| @@ -56,28 +56,29 @@ foreach my $i (@bad_json) | @@ -56,28 +56,29 @@ foreach my $i (@bad_json) | ||
| 56 | 56 | ||
| 57 | foreach my $i (@good_json) | 57 | foreach my $i (@good_json) |
| 58 | { | 58 | { |
| 59 | - if ($i eq 'replace-input') | 59 | + my ($base, $pass) = @$i; |
| 60 | + if ($base eq 'replace-input') | ||
| 60 | { | 61 | { |
| 61 | copy("minimal.pdf", 'a.pdf'); | 62 | copy("minimal.pdf", 'a.pdf'); |
| 62 | } | 63 | } |
| 63 | - $td->runtest("QPDFJob good json: $i", | ||
| 64 | - {$td->COMMAND => "qpdf --job-json-file=job-json-$i.json"}, | 64 | + $td->runtest("QPDFJob good json: $base", |
| 65 | + {$td->COMMAND => "qpdf --job-json-file=job-json-$base.json"}, | ||
| 65 | {$td->STRING => "", $td->EXIT_STATUS => 0}, | 66 | {$td->STRING => "", $td->EXIT_STATUS => 0}, |
| 66 | $td->NORMALIZE_NEWLINES); | 67 | $td->NORMALIZE_NEWLINES); |
| 67 | - if ($i =~ m/encrypt-256/) | 68 | + if ($base =~ m/encrypt-256/) |
| 68 | { | 69 | { |
| 69 | - $td->runtest("check encryption $i", | 70 | + $td->runtest("check encryption $base", |
| 70 | {$td->COMMAND => | 71 | {$td->COMMAND => |
| 71 | "qpdf a.pdf --password=u" . | 72 | "qpdf a.pdf --password=u" . |
| 72 | " --job-json-file=job-show-encryption.json"}, | 73 | " --job-json-file=job-show-encryption.json"}, |
| 73 | - {$td->FILE => "job-json-$i.out", $td->EXIT_STATUS => 0}, | 74 | + {$td->FILE => "job-json-$base.out", $td->EXIT_STATUS => 0}, |
| 74 | $td->NORMALIZE_NEWLINES); | 75 | $td->NORMALIZE_NEWLINES); |
| 75 | } | 76 | } |
| 76 | else | 77 | else |
| 77 | { | 78 | { |
| 78 | - $td->runtest("check good json $i output", | ||
| 79 | - {$td->COMMAND => "qpdf-test-compare a.pdf job-json-$i.pdf"}, | ||
| 80 | - {$td->FILE => "job-json-$i.pdf", $td->EXIT_STATUS => 0}); | 79 | + $td->runtest("check good json $base output", |
| 80 | + {$td->COMMAND => "qpdf-test-compare a.pdf job-json-$base.pdf $pass"}, | ||
| 81 | + {$td->FILE => "job-json-$base.pdf", $td->EXIT_STATUS => 0}); | ||
| 81 | } | 82 | } |
| 82 | } | 83 | } |
| 83 | 84 |
qpdf/qtest/split-pages.test
| @@ -70,8 +70,8 @@ $td->runtest("split page with labels", | @@ -70,8 +70,8 @@ $td->runtest("split page with labels", | ||
| 70 | foreach my $i (qw(01-06 07-11)) | 70 | foreach my $i (qw(01-06 07-11)) |
| 71 | { | 71 | { |
| 72 | $td->runtest("check output ($i)", | 72 | $td->runtest("check output ($i)", |
| 73 | - {$td->FILE => "split-out-labels-$i.pdf"}, | ||
| 74 | - {$td->FILE => "labels-split-$i.pdf"}); | 73 | + {$td->COMMAND => "qpdf-test-compare split-out-labels-$i.pdf labels-split-$i.pdf"}, |
| 74 | + {$td->FILE => "labels-split-$i.pdf", $td->EXIT_STATUS => 0}); | ||
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | # See comments in TODO about these expected failures. Search for | 77 | # See comments in TODO about these expected failures. Search for |
| @@ -121,8 +121,8 @@ foreach my $d (@sp_cases) | @@ -121,8 +121,8 @@ foreach my $d (@sp_cases) | ||
| 121 | my $expected = $actual; | 121 | my $expected = $actual; |
| 122 | $expected =~ s/split-out/split-exp/; | 122 | $expected =~ s/split-out/split-exp/; |
| 123 | $td->runtest("check output page $i ($description)", | 123 | $td->runtest("check output page $i ($description)", |
| 124 | - {$td->FILE => $actual}, | ||
| 125 | - {$td->FILE => $expected}); | 124 | + {$td->COMMAND => "qpdf-test-compare $actual $expected u"}, |
| 125 | + {$td->FILE => $expected, $td->EXIT_STATUS => 0}); | ||
| 126 | } | 126 | } |
| 127 | } | 127 | } |
| 128 | 128 | ||
| @@ -201,8 +201,8 @@ foreach my $d (@fo_resources) | @@ -201,8 +201,8 @@ foreach my $d (@fo_resources) | ||
| 201 | {$td->STRING => "", $td->EXIT_STATUS => 0}, | 201 | {$td->STRING => "", $td->EXIT_STATUS => 0}, |
| 202 | $td->NORMALIZE_NEWLINES); | 202 | $td->NORMALIZE_NEWLINES); |
| 203 | $td->runtest("check output ($f)", | 203 | $td->runtest("check output ($f)", |
| 204 | - {$td->FILE => "a.pdf"}, | ||
| 205 | - {$td->FILE => "$f-out.pdf"}); | 204 | + {$td->COMMAND => "qpdf-test-compare a.pdf $f-out.pdf"}, |
| 205 | + {$td->FILE => "$f-out.pdf", $td->EXIT_STATUS => 0}); | ||
| 206 | if ($compare) | 206 | if ($compare) |
| 207 | { | 207 | { |
| 208 | compare_pdfs($td, "$f.pdf", "a.pdf"); | 208 | compare_pdfs($td, "$f.pdf", "a.pdf"); |