aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/positive-p.test
blob: ab0bcff0f32590d461b9753fc9aab93620e8c02e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env perl
require 5.008;
use warnings;
use strict;

unshift(@INC, '.');
require qpdf_test_helpers;

chdir("qpdf") or die "chdir testdir failed: $!\n";

require TestDriver;

cleanup();

my $td = new TestDriver('positive-p');

my $n_tests = 4;

# Files have been seen where /P in the encryption dictionary was an
# unsigned rather than a signed integer. To create
# encrypted-positive-P.pdf, I temporarily modified QPDFWriter.cc to
# introduce this error.

$td->runtest("decrypt positive P",
             {$td->COMMAND =>
                  "qpdf --decrypt --static-id encrypted-positive-P.pdf a.pdf"},
             {$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check output",
             {$td->FILE => "a.pdf"},
             {$td->FILE => "decrypted-positive-P.pdf"});
$td->runtest("copy encryption positive P",
             {$td->COMMAND =>
                  "qpdf --static-id --static-aes-iv" .
                  " encrypted-positive-P.pdf a.pdf"},
             {$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check output",
             {$td->FILE => "a.pdf"},
             {$td->FILE => "copied-positive-P.pdf"});

cleanup();
$td->report($n_tests);