Bump libcxml for Centos build fix.
[libdcp.git] / test / round_trip_test.cc
index 2747a71fb840aa89c0b5bfad64995e3f5d2271e0..19ed482aa810cf28973243cc043346c34ca3d7a2 100644 (file)
@@ -31,6 +31,7 @@
 #include "argb_frame.h"
 #include "signer_chain.h"
 
+using std::list;
 using boost::shared_ptr;
 
 /* Build an encrypted picture MXF and a KDM for it and check that the KDM can be decrypted */
@@ -38,7 +39,7 @@ BOOST_AUTO_TEST_CASE (round_trip_test)
 {
        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");
        
        libdcp::CertificateChain chain;
        chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("build/test/signer/ca.self-signed.pem"))));
@@ -67,16 +68,22 @@ BOOST_AUTO_TEST_CASE (round_trip_test)
 
        shared_ptr<libdcp::CPL> cpl (new libdcp::CPL (work_dir, "A Test DCP", libdcp::FEATURE, 24, 24));
        cpl->add_reel (shared_ptr<libdcp::Reel> (new libdcp::Reel (asset_A, shared_ptr<libdcp::SoundAsset> (), shared_ptr<libdcp::SubtitleAsset> ())));
+       libdcp::XMLMetadata metadata;
+       cpl->write_xml (true, metadata, signer);
+
+       boost::filesystem::path cpl_path = work_dir / (cpl->id() + "_cpl.xml");
 
        /* A KDM using our certificate chain's leaf key pair */
        libdcp::KDM kdm_A (
-               cpl,
+               cpl_path,
                signer,
                signer->certificates().leaf(),
+               key,
                boost::posix_time::time_from_string ("2013-01-01 00:00:00"),
                boost::posix_time::time_from_string ("2013-01-08 00:00:00"),
                "libdcp",
-               "2012-07-17T04:45:18+00:00"
+               "2012-07-17T04:45:18+00:00",
+               libdcp::KDM::MODIFIED_TRANSITIONAL_1
                );
 
        boost::filesystem::path const kdm_file = work_dir / "kdm.xml";
@@ -86,6 +93,18 @@ BOOST_AUTO_TEST_CASE (round_trip_test)
        /* Reload the KDM, using our private key to decrypt it */
        libdcp::KDM kdm_B (kdm_file, "build/test/signer/leaf.key");
 
+       /* Check that the decrypted KDMKeys are the same as the ones we started with */
+       BOOST_CHECK_EQUAL (kdm_A.keys().size(), kdm_B.keys().size());
+       list<libdcp::KDMKey> keys_A = kdm_A.keys ();
+       list<libdcp::KDMKey> keys_B = kdm_B.keys ();
+       list<libdcp::KDMKey>::const_iterator i = keys_A.begin();
+       list<libdcp::KDMKey>::const_iterator j = keys_B.begin();
+       while (i != keys_A.end ()) {
+               BOOST_CHECK (*i == *j);
+               ++i;
+               ++j;
+       }
+
        /* Reload the picture MXF */
        shared_ptr<libdcp::MonoPictureAsset> asset_B (
                new libdcp::MonoPictureAsset (work_dir, "video.mxf")