mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +00:00
Fix tests with password-protected files
This commit is contained in:
parent
38042fa273
commit
4c3c658e25
@ -373,9 +373,9 @@ $td->runtest("show-encryption works invalid password",
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
|
||||
my @cenc = (
|
||||
[11, 'hybrid-xref.pdf', "''", 'r2', "", ""],
|
||||
[12, 'hybrid-xref.pdf', "''", 'r3', "", ""],
|
||||
[15, 'hybrid-xref.pdf', "''", 'r4', "", ""],
|
||||
[11, 'hybrid-xref.pdf', "''", 'r2', "", "user1"],
|
||||
[12, 'hybrid-xref.pdf', "''", 'r3', "", "user2"],
|
||||
[15, 'hybrid-xref.pdf', "''", 'r4', "", "user2"],
|
||||
[17, 'hybrid-xref.pdf', "''", 'r5', "", "owner3"],
|
||||
[18, 'hybrid-xref.pdf', "''", 'r6', "", "user4"],
|
||||
[13, 'c-r2.pdf', 'user1', 'decrypt with user',
|
||||
@ -404,7 +404,7 @@ foreach my $d (@cenc)
|
||||
if (-f $pdf_outfile)
|
||||
{
|
||||
$td->runtest("check $description content",
|
||||
{$td->COMMAND => "qpdf-test-compare a.pdf $pdf_outfile"},
|
||||
{$td->COMMAND => "qpdf-test-compare a.pdf $pdf_outfile $checkpass"},
|
||||
{$td->FILE => $pdf_outfile, $td->EXIT_STATUS => 0});
|
||||
}
|
||||
else
|
||||
@ -413,7 +413,8 @@ foreach my $d (@cenc)
|
||||
# /Perms static, so we have no way to predictably create a
|
||||
# /V=5 encrypted file. It's not worth adding this...the test
|
||||
# suite is adequate without having a statically predictable
|
||||
# file.
|
||||
# file. (qpdf-test-compare ignores /Perms, but it's not worth
|
||||
# adding output files for these cases.)
|
||||
$td->runtest("check $description",
|
||||
{$td->COMMAND =>
|
||||
"qpdf --check a.pdf --password=$checkpass"},
|
||||
|
@ -24,7 +24,7 @@ $td->runtest("linearize duplicated pages",
|
||||
$td->EXIT_STATUS => 3},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("compare files",
|
||||
{$td->COMMAND => "qpdf-test-compare a.pdf"},
|
||||
{$td->COMMAND => "qpdf-test-compare a.pdf linearize-duplicate-page.pdf"},
|
||||
{$td->FILE => "linearize-duplicate-page.pdf", $td->EXIT_STATUS => 0});
|
||||
$td->runtest("extract duplicated pages",
|
||||
{$td->COMMAND =>
|
||||
|
@ -30,18 +30,18 @@ my @bad_json = (
|
||||
"json-error"
|
||||
);
|
||||
my @good_json = (
|
||||
"choice-match",
|
||||
"input-file-password",
|
||||
"empty-input",
|
||||
"replace-input",
|
||||
"encrypt-40",
|
||||
"encrypt-128",
|
||||
"encrypt-256-with-restrictions",
|
||||
"add-attachments",
|
||||
"copy-attachments",
|
||||
"underlay-overlay",
|
||||
"underlay-overlay-password",
|
||||
"misc-options",
|
||||
["choice-match", ""],
|
||||
["input-file-password", "user"],
|
||||
["empty-input", ""],
|
||||
["replace-input", ""],
|
||||
["encrypt-40", "u"],
|
||||
["encrypt-128", "u"],
|
||||
["encrypt-256-with-restrictions", "u"],
|
||||
["add-attachments", ""],
|
||||
["copy-attachments", ""],
|
||||
["underlay-overlay", ""],
|
||||
["underlay-overlay-password", ""],
|
||||
["misc-options", ""],
|
||||
);
|
||||
my $n_tests = 11 + scalar(@bad_json) + (2 * scalar(@good_json));
|
||||
|
||||
@ -56,28 +56,29 @@ foreach my $i (@bad_json)
|
||||
|
||||
foreach my $i (@good_json)
|
||||
{
|
||||
if ($i eq 'replace-input')
|
||||
my ($base, $pass) = @$i;
|
||||
if ($base eq 'replace-input')
|
||||
{
|
||||
copy("minimal.pdf", 'a.pdf');
|
||||
}
|
||||
$td->runtest("QPDFJob good json: $i",
|
||||
{$td->COMMAND => "qpdf --job-json-file=job-json-$i.json"},
|
||||
$td->runtest("QPDFJob good json: $base",
|
||||
{$td->COMMAND => "qpdf --job-json-file=job-json-$base.json"},
|
||||
{$td->STRING => "", $td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
if ($i =~ m/encrypt-256/)
|
||||
if ($base =~ m/encrypt-256/)
|
||||
{
|
||||
$td->runtest("check encryption $i",
|
||||
$td->runtest("check encryption $base",
|
||||
{$td->COMMAND =>
|
||||
"qpdf a.pdf --password=u" .
|
||||
" --job-json-file=job-show-encryption.json"},
|
||||
{$td->FILE => "job-json-$i.out", $td->EXIT_STATUS => 0},
|
||||
{$td->FILE => "job-json-$base.out", $td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
}
|
||||
else
|
||||
{
|
||||
$td->runtest("check good json $i output",
|
||||
{$td->COMMAND => "qpdf-test-compare a.pdf job-json-$i.pdf"},
|
||||
{$td->FILE => "job-json-$i.pdf", $td->EXIT_STATUS => 0});
|
||||
$td->runtest("check good json $base output",
|
||||
{$td->COMMAND => "qpdf-test-compare a.pdf job-json-$base.pdf $pass"},
|
||||
{$td->FILE => "job-json-$base.pdf", $td->EXIT_STATUS => 0});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,8 +70,8 @@ $td->runtest("split page with labels",
|
||||
foreach my $i (qw(01-06 07-11))
|
||||
{
|
||||
$td->runtest("check output ($i)",
|
||||
{$td->FILE => "split-out-labels-$i.pdf"},
|
||||
{$td->FILE => "labels-split-$i.pdf"});
|
||||
{$td->COMMAND => "qpdf-test-compare split-out-labels-$i.pdf labels-split-$i.pdf"},
|
||||
{$td->FILE => "labels-split-$i.pdf", $td->EXIT_STATUS => 0});
|
||||
}
|
||||
|
||||
# See comments in TODO about these expected failures. Search for
|
||||
@ -121,8 +121,8 @@ foreach my $d (@sp_cases)
|
||||
my $expected = $actual;
|
||||
$expected =~ s/split-out/split-exp/;
|
||||
$td->runtest("check output page $i ($description)",
|
||||
{$td->FILE => $actual},
|
||||
{$td->FILE => $expected});
|
||||
{$td->COMMAND => "qpdf-test-compare $actual $expected u"},
|
||||
{$td->FILE => $expected, $td->EXIT_STATUS => 0});
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,8 +201,8 @@ foreach my $d (@fo_resources)
|
||||
{$td->STRING => "", $td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("check output ($f)",
|
||||
{$td->FILE => "a.pdf"},
|
||||
{$td->FILE => "$f-out.pdf"});
|
||||
{$td->COMMAND => "qpdf-test-compare a.pdf $f-out.pdf"},
|
||||
{$td->FILE => "$f-out.pdf", $td->EXIT_STATUS => 0});
|
||||
if ($compare)
|
||||
{
|
||||
compare_pdfs($td, "$f.pdf", "a.pdf");
|
||||
|
Loading…
Reference in New Issue
Block a user