Bump libcxml again.
[libdcp.git] / test / encryption_test.cc
index c079acbe85a1928dfed75b6274a8fa788be1a80e..f08d48271e2a7c959a583c50b6039b45d3693726 100644 (file)
@@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE (encryption)
 {
        boost::filesystem::remove_all ("build/test/signer");
        boost::filesystem::create_directory ("build/test/signer");
-       libdcp::make_signer_chain ("build/test/signer");
+       libdcp::make_signer_chain ("build/test/signer", "openssl");
        
        Kumu::libdcp_test = true;
 
@@ -54,27 +54,28 @@ BOOST_AUTO_TEST_CASE (encryption)
        xml_metadata.creator = "OpenDCP 0.0.25";
        xml_metadata.issue_date = "2012-07-17T04:45:18+00:00";
        
-       boost::filesystem::remove_all ("build/test/bar");
-       boost::filesystem::create_directories ("build/test/bar");
+       boost::filesystem::remove_all ("build/test/DCP/bar");
+       boost::filesystem::create_directories ("build/test/DCP/bar");
        libdcp::DCP d ("build/test/DCP/bar");
 
+       /* Use test/ref/crypt so this test is repeatable */
        libdcp::CertificateChain chain;
-       chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("build/test/signer/ca.self-signed.pem"))));
-       chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("build/test/signer/intermediate.signed.pem"))));
-       chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("build/test/signer/leaf.signed.pem"))));
+       chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem"))));
+       chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("test/ref/crypt/intermediate.signed.pem"))));
+       chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem"))));
 
        shared_ptr<libdcp::Signer> signer (
                new libdcp::Signer (
                        chain,
-                       "build/test/signer/leaf.key"
+                       "test/ref/crypt/leaf.key"
                        )
                );
 
-       shared_ptr<libdcp::CPL> cpl (new libdcp::CPL ("build/test/bar", "A Test DCP", libdcp::FEATURE, 24, 24));
+       shared_ptr<libdcp::CPL> cpl (new libdcp::CPL ("build/test/DCP/bar", "A Test DCP", libdcp::FEATURE, 24, 24));
 
        libdcp::Key key;
        
-       shared_ptr<libdcp::MonoPictureAsset> mp (new libdcp::MonoPictureAsset ("build/test/bar", "video.mxf"));
+       shared_ptr<libdcp::MonoPictureAsset> mp (new libdcp::MonoPictureAsset ("build/test/DCP/bar", "video.mxf"));
        mp->set_progress (&d.Progress);
        mp->set_edit_rate (24);
        mp->set_intrinsic_duration (24);
@@ -84,7 +85,7 @@ BOOST_AUTO_TEST_CASE (encryption)
        mp->set_key (key);
        mp->create (j2c);
 
-       shared_ptr<libdcp::SoundAsset> ms (new libdcp::SoundAsset ("build/test/bar", "audio.mxf"));
+       shared_ptr<libdcp::SoundAsset> ms (new libdcp::SoundAsset ("build/test/DCP/bar", "audio.mxf"));
        ms->set_progress (&d.Progress);
        ms->set_edit_rate (24);
        ms->set_intrinsic_duration (24);
@@ -110,12 +111,29 @@ BOOST_AUTO_TEST_CASE (encryption)
                );
 
        kdm.as_xml ("build/test/bar.kdm.xml");
-       system ("xmllint --path schema --nonet --noout --schema schema/SMPTE-430-1-2006-Amd-1-2009-KDM.xsd build/test/bar.kdm.xml");
-       system ("xmlsec1 verify "
-               "--pubkey-cert-pem build/test/signer/leaf.signed.pem "
-               "--trusted-pem build/test/signer/intermediate.signed.pem "
-               "--trusted-pem build/test/signer/ca.self-signed.pem "
+       
+       int r = system (
+               "xmllint --path schema --nonet --noout --schema schema/SMPTE-430-1-2006-Amd-1-2009-KDM.xsd build/test/bar.kdm.xml "
+               "> build/test/xmllint.log 2>&1 < /dev/null"
+               );
+
+#ifdef DCPOMATIC_POSIX 
+       BOOST_CHECK_EQUAL (WEXITSTATUS (r), 0);
+#else
+       BOOST_CHECK_EQUAL (r, 0);
+#endif 
+               
+       r = system ("xmlsec1 verify "
+               "--pubkey-cert-pem test/ref/crypt/leaf.signed.pem "
+               "--trusted-pem test/ref/crypt/intermediate.signed.pem "
+               "--trusted-pem test/ref/crypt/ca.self-signed.pem "
                "--id-attr:Id http://www.smpte-ra.org/schemas/430-3/2006/ETM:AuthenticatedPublic "
                "--id-attr:Id http://www.smpte-ra.org/schemas/430-3/2006/ETM:AuthenticatedPrivate "
-               "build/test/bar.kdm.xml");
+                   "build/test/bar.kdm.xml > build/test/xmlsec1.log 2>&1 < /dev/null");
+       
+#ifdef DCPOMATIC_POSIX 
+       BOOST_CHECK_EQUAL (WEXITSTATUS (r), 0);
+#else
+       BOOST_CHECK_EQUAL (r, 0);
+#endif 
 }