Add another type to raw/locale convert.
[libdcp.git] / test / kdm_test.cc
index b312c754f16f943264352ba9c98abd7e8234411a..8dced8ac2bc28b7047ebde5bd153014b8716f047 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
 
     You should have received a copy of the GNU General Public License
     along with libdcp.  If not, see <http://www.gnu.org/licenses/>.
+
+    In addition, as a special exception, the copyright holders give
+    permission to link the code of portions of this program with the
+    OpenSSL library under certain conditions as described in each
+    individual source file, and distribute linked combinations
+    including the two.
+
+    You must obey the GNU General Public License in all respects
+    for all of the code used other than OpenSSL.  If you modify
+    file(s) with this exception, you may extend this exception to your
+    version of the file(s), but you are not obligated to do so.  If you
+    do not wish to do so, delete this exception statement from your
+    version.  If you delete this exception statement from all source
+    files in the program, then also delete it here.
 */
 
 #include "encrypted_kdm.h"
@@ -31,6 +45,7 @@ using std::list;
 using std::string;
 using std::vector;
 using boost::shared_ptr;
+using boost::optional;
 
 /** Check reading and decryption of a KDM */
 BOOST_AUTO_TEST_CASE (kdm_test)
@@ -132,7 +147,7 @@ BOOST_AUTO_TEST_CASE (kdm_key_type_scope)
 }
 
 static cxml::ConstNodePtr
-kdm_forensic_test (cxml::Document& doc, int picture, int audio)
+kdm_forensic_test (cxml::Document& doc, bool picture, optional<int> audio)
 {
        dcp::DecryptedKDM decrypted (
                dcp::EncryptedKDM (
@@ -145,10 +160,13 @@ kdm_forensic_test (cxml::Document& doc, int picture, int audio)
        signer->set_key(dcp::file_to_string("test/data/private.key"));
 
        dcp::EncryptedKDM kdm = decrypted.encrypt (
-               signer, signer->leaf(), vector<dcp::Certificate>(), dcp::MODIFIED_TRANSITIONAL_1, picture, audio
+               signer, signer->leaf(), vector<string>(), dcp::MODIFIED_TRANSITIONAL_1, picture, audio
                );
 
-       doc.read_string (kdm.as_xml ());
+       /* Check that we can pass this through correctly */
+       BOOST_CHECK_EQUAL (kdm.as_xml(), dcp::EncryptedKDM(kdm.as_xml()).as_xml());
+
+       doc.read_string (kdm.as_xml());
 
        return doc.node_child("AuthenticatedPublic")->
                node_child("RequiredExtensions")->
@@ -160,7 +178,7 @@ kdm_forensic_test (cxml::Document& doc, int picture, int audio)
 BOOST_AUTO_TEST_CASE (kdm_forensic_test1)
 {
        cxml::Document doc;
-       cxml::ConstNodePtr forensic = kdm_forensic_test(doc, -1, -1);
+       cxml::ConstNodePtr forensic = kdm_forensic_test(doc, true, 0);
        BOOST_REQUIRE (forensic);
        list<cxml::NodePtr> flags = forensic->node_children("ForensicMarkFlag");
        BOOST_REQUIRE_EQUAL (flags.size(), 2);
@@ -172,7 +190,7 @@ BOOST_AUTO_TEST_CASE (kdm_forensic_test1)
 BOOST_AUTO_TEST_CASE (kdm_forensic_test2)
 {
        cxml::Document doc;
-       cxml::ConstNodePtr forensic = kdm_forensic_test(doc, -1, 0);
+       cxml::ConstNodePtr forensic = kdm_forensic_test(doc, true, optional<int>());
        BOOST_REQUIRE (forensic);
        list<cxml::NodePtr> flags = forensic->node_children("ForensicMarkFlag");
        BOOST_REQUIRE_EQUAL (flags.size(), 1);
@@ -183,7 +201,7 @@ BOOST_AUTO_TEST_CASE (kdm_forensic_test2)
 BOOST_AUTO_TEST_CASE (kdm_forensic_test3)
 {
        cxml::Document doc;
-       cxml::ConstNodePtr forensic = kdm_forensic_test(doc, 0, -1);
+       cxml::ConstNodePtr forensic = kdm_forensic_test(doc, false, 0);
        BOOST_REQUIRE (forensic);
        list<cxml::NodePtr> flags = forensic->node_children("ForensicMarkFlag");
        BOOST_REQUIRE_EQUAL (flags.size(), 1);
@@ -194,7 +212,7 @@ BOOST_AUTO_TEST_CASE (kdm_forensic_test3)
 BOOST_AUTO_TEST_CASE (kdm_forensic_test4)
 {
        cxml::Document doc;
-       cxml::ConstNodePtr forensic = kdm_forensic_test(doc, -1, 3);
+       cxml::ConstNodePtr forensic = kdm_forensic_test(doc, true, 3);
        BOOST_REQUIRE (forensic);
        list<cxml::NodePtr> flags = forensic->node_children("ForensicMarkFlag");
        BOOST_REQUIRE_EQUAL (flags.size(), 2);
@@ -206,6 +224,6 @@ BOOST_AUTO_TEST_CASE (kdm_forensic_test4)
 BOOST_AUTO_TEST_CASE (kdm_forensic_test5)
 {
        cxml::Document doc;
-       cxml::ConstNodePtr forensic = kdm_forensic_test(doc, 0, 0);
+       cxml::ConstNodePtr forensic = kdm_forensic_test(doc, false, optional<int>());
        BOOST_CHECK (!forensic);
 }