From 6bdac26369c0d770759c2b6ce24afef608a91ec9 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 27 Sep 2009 20:33:17 +0000 Subject: finished testing C API git-svn-id: svn+q:///qpdf/trunk@734 71b93d88-0707-0410-a8cf-f5a4172ac649 --- README.maintainer | 2 ++ configure.ac | 2 +- libqpdf/qpdf-c.cc | 8 +++--- manual/qpdf-manual.xml | 4 +-- qpdf.spec | 2 +- qpdf/qpdf-ctest.c | 43 +++++++++++++++++++++++++++++++ qpdf/qpdf.cc | 2 +- qpdf/qtest/qpdf.test | 25 ++++++++++++++++++ qpdf/qtest/qpdf/c-decrypt-with-owner.pdf | Bin 0 -> 9668 bytes qpdf/qtest/qpdf/c-decrypt-with-user.pdf | Bin 0 -> 9668 bytes qpdf/qtest/qpdf/c-r2.pdf | Bin 0 -> 9893 bytes qpdf/qtest/qpdf/c-r3.pdf | Bin 0 -> 9897 bytes 12 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 qpdf/qtest/qpdf/c-decrypt-with-owner.pdf create mode 100644 qpdf/qtest/qpdf/c-decrypt-with-user.pdf create mode 100644 qpdf/qtest/qpdf/c-r2.pdf create mode 100644 qpdf/qtest/qpdf/c-r3.pdf diff --git a/README.maintainer b/README.maintainer index 2fe189f0..28fb6119 100644 --- a/README.maintainer +++ b/README.maintainer @@ -16,6 +16,8 @@ Release Reminders make_dist verifies this consistency. + * Update release date in manual/qpdf-manual.xml + * Each year, update copyright notices. Just search for Copyright. Last updated: 2009. diff --git a/configure.ac b/configure.ac index e66af81f..21fd01c6 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. dnl This config.in requires autoconf 2.5 or greater. AC_PREREQ(2.60) -AC_INIT(qpdf,2.0.6) +AC_INIT(qpdf,2.1.a1) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_FILES([autoconf.mk]) diff --git a/libqpdf/qpdf-c.cc b/libqpdf/qpdf-c.cc index 5f894895..9e2d0cbf 100644 --- a/libqpdf/qpdf-c.cc +++ b/libqpdf/qpdf-c.cc @@ -376,10 +376,10 @@ void qpdf_set_r3_encryption_parameters( ((print == QPDF_R3_PRINT_LOW) ? QPDFWriter::r3p_low : (print == QPDF_R3_PRINT_NONE) ? QPDFWriter::r3p_none : QPDFWriter::r3p_full), - ((print == QPDF_R3_MODIFY_ANNOTATE) ? QPDFWriter::r3m_annotate : - (print == QPDF_R3_MODIFY_FORM) ? QPDFWriter::r3m_form : - (print == QPDF_R3_MODIFY_ASSEMBLY) ? QPDFWriter::r3m_assembly : - (print == QPDF_R3_MODIFY_NONE) ? QPDFWriter::r3m_none : + ((modify == QPDF_R3_MODIFY_ANNOTATE) ? QPDFWriter::r3m_annotate : + (modify == QPDF_R3_MODIFY_FORM) ? QPDFWriter::r3m_form : + (modify == QPDF_R3_MODIFY_ASSEMBLY) ? QPDFWriter::r3m_assembly : + (modify == QPDF_R3_MODIFY_NONE) ? QPDFWriter::r3m_none : QPDFWriter::r3m_all)); } diff --git a/manual/qpdf-manual.xml b/manual/qpdf-manual.xml index eb3c54b9..d5f43cac 100644 --- a/manual/qpdf-manual.xml +++ b/manual/qpdf-manual.xml @@ -5,8 +5,8 @@ - - + + ]> diff --git a/qpdf.spec b/qpdf.spec index f7fd855a..433d3bd1 100644 --- a/qpdf.spec +++ b/qpdf.spec @@ -1,6 +1,6 @@ Summary: Command-line tools and library for transforming PDF files Name: qpdf -Version: 2.0.6 +Version: 2.1.a1 Release: 1%{?dist} License: Artistic Group: System Environment/Libraries diff --git a/qpdf/qpdf-ctest.c b/qpdf/qpdf-ctest.c index 456f06c6..42d8f9f4 100644 --- a/qpdf/qpdf-ctest.c +++ b/qpdf/qpdf-ctest.c @@ -159,6 +159,46 @@ static void test10(char const* infile, report_errors(); } +static void test11(char const* infile, + char const* password, + char const* outfile) +{ + qpdf_read(qpdf, infile, password); + qpdf_init_write(qpdf, outfile); + qpdf_set_static_ID(qpdf, QPDF_TRUE); + qpdf_set_r2_encryption_parameters( + qpdf, "user1", "owner1", QPDF_FALSE, QPDF_TRUE, QPDF_TRUE, QPDF_TRUE); + qpdf_write(qpdf); + report_errors(); +} + +static void test12(char const* infile, + char const* password, + char const* outfile) +{ + qpdf_read(qpdf, infile, password); + qpdf_init_write(qpdf, outfile); + qpdf_set_static_ID(qpdf, QPDF_TRUE); + qpdf_set_r3_encryption_parameters( + qpdf, "user2", "owner2", QPDF_TRUE, QPDF_TRUE, + QPDF_R3_PRINT_LOW, QPDF_R3_MODIFY_ALL); + qpdf_write(qpdf); + report_errors(); +} + +static void test13(char const* infile, + char const* password, + char const* outfile) +{ + qpdf_read(qpdf, infile, password); + printf("user password: %s\n", qpdf_get_user_password(qpdf)); + qpdf_init_write(qpdf, outfile); + qpdf_set_static_ID(qpdf, QPDF_TRUE); + qpdf_set_preserve_encryption(qpdf, QPDF_FALSE); + qpdf_write(qpdf); + report_errors(); +} + int main(int argc, char* argv[]) { char* whoami = 0; @@ -202,6 +242,9 @@ int main(int argc, char* argv[]) (n == 8) ? test08 : (n == 9) ? test09 : (n == 10) ? test10 : + (n == 11) ? test11 : + (n == 12) ? test12 : + (n == 13) ? test13 : 0); if (fn == 0) diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index 9cd0df7b..cc65328f 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -472,7 +472,7 @@ int main(int argc, char* argv[]) // 1 2 3 4 5 6 7 8 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 std::cout - << whoami << " version 2.0.6" << std::endl + << whoami << " version 2.1.a1" << std::endl << "Copyright (c) 2005-2009 Jay Berkenbilt" << std::endl << "This software may be distributed under the terms of version 2 of the" diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index 70021676..8cf355b0 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -851,6 +851,31 @@ $td->runtest("invalid password", $td->EXIT_STATUS => 2}, $td->NORMALIZE_NEWLINES); +my @cenc = ( + [11, 'hybrid-xref.pdf', "''", 'r2', ""], + [12, 'hybrid-xref.pdf', "''", 'r3', ""], + [13, 'c-r2.pdf', 'user1', 'decrypt with user', + "user password: user1\n"], + [13, 'c-r3.pdf', 'owner2', 'decrypt with owner', + "user password: user2\n"], + ); +$n_tests += 2 * @cenc; + +foreach my $d (@cenc) +{ + my ($n, $infile, $pass, $description, $output) = @$d; + my $outfile = $description; + $outfile =~ s/ /-/g; + my $outfile = "c-$outfile.pdf"; + $td->runtest("C API encryption: $description", + {$td->COMMAND => "qpdf-ctest $n $infile $pass a.pdf"}, + {$td->STRING => $output, $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); + $td->runtest("check $description", + {$td->FILE => "a.pdf"}, + {$td->FILE => $outfile}); +} + # Test combinations of linearization and encryption. Note that we do # content checks on encrypted and linearized files in various # combinations below. Here we are just making sure that they are diff --git a/qpdf/qtest/qpdf/c-decrypt-with-owner.pdf b/qpdf/qtest/qpdf/c-decrypt-with-owner.pdf new file mode 100644 index 00000000..9a0f23b4 Binary files /dev/null and b/qpdf/qtest/qpdf/c-decrypt-with-owner.pdf differ diff --git a/qpdf/qtest/qpdf/c-decrypt-with-user.pdf b/qpdf/qtest/qpdf/c-decrypt-with-user.pdf new file mode 100644 index 00000000..9a0f23b4 Binary files /dev/null and b/qpdf/qtest/qpdf/c-decrypt-with-user.pdf differ diff --git a/qpdf/qtest/qpdf/c-r2.pdf b/qpdf/qtest/qpdf/c-r2.pdf new file mode 100644 index 00000000..0301696c Binary files /dev/null and b/qpdf/qtest/qpdf/c-r2.pdf differ diff --git a/qpdf/qtest/qpdf/c-r3.pdf b/qpdf/qtest/qpdf/c-r3.pdf new file mode 100644 index 00000000..55493b2e Binary files /dev/null and b/qpdf/qtest/qpdf/c-r3.pdf differ -- cgit v1.2.3-54-g00ecf