summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-07-30 02:10:09 +0100
committerCarl Hetherington <cth@carlh.net>2015-07-30 02:10:09 +0100
commit57b862d997857868d0c3c91a9776f854b62c6b56 (patch)
treeed3bf26ba60645094853d05918bc22750bb356f7 /test
parentd69d2d2d32b6f874cc13ecec1ce705d44a1feb24 (diff)
Merge Signer into CertificateChain.
Diffstat (limited to 'test')
-rw-r--r--test/certificates_test.cc12
-rw-r--r--test/encryption_test.cc20
-rw-r--r--test/round_trip_test.cc8
3 files changed, 17 insertions, 23 deletions
diff --git a/test/certificates_test.cc b/test/certificates_test.cc
index 3926c710..166ebb2d 100644
--- a/test/certificates_test.cc
+++ b/test/certificates_test.cc
@@ -19,7 +19,7 @@
#include <boost/test/unit_test.hpp>
#include "certificate.h"
-#include "signer.h"
+#include "certificate_chain.h"
#include "util.h"
using std::list;
@@ -141,11 +141,11 @@ BOOST_AUTO_TEST_CASE (signer_validation)
chain.add (dcp::Certificate (dcp::file_to_string ("test/ref/crypt/ca.self-signed.pem")));
chain.add (dcp::Certificate (dcp::file_to_string ("test/ref/crypt/intermediate.signed.pem")));
chain.add (dcp::Certificate (dcp::file_to_string ("test/ref/crypt/leaf.signed.pem")));
- dcp::Signer signer (chain, dcp::file_to_string ("test/ref/crypt/leaf.key"));
- BOOST_CHECK (signer.valid ());
+ chain.set_key (dcp::file_to_string ("test/ref/crypt/leaf.key"));
+ BOOST_CHECK (chain.valid ());
/* Put in an unrelated key and the signer should no longer be valid */
- dcp::Signer another_signer ("openssl");
- signer.set_key (another_signer.key ());
- BOOST_CHECK (!signer.valid ());
+ dcp::CertificateChain another_chain ("openssl");
+ chain.set_key (another_chain.key().get ());
+ BOOST_CHECK (!chain.valid ());
}
diff --git a/test/encryption_test.cc b/test/encryption_test.cc
index 0f3aa69e..bab20958 100644
--- a/test/encryption_test.cc
+++ b/test/encryption_test.cc
@@ -21,7 +21,7 @@
#include "metadata.h"
#include "certificate.h"
#include "dcp.h"
-#include "signer.h"
+#include "certificate_chain.h"
#include "cpl.h"
#include "mono_picture_asset.h"
#include "picture_asset_writer.h"
@@ -66,17 +66,11 @@ BOOST_AUTO_TEST_CASE (encryption_test)
dcp::DCP d ("build/test/DCP/encryption_test");
/* Use test/ref/crypt so this test is repeatable */
- dcp::CertificateChain chain;
- chain.add (dcp::Certificate (dcp::file_to_string ("test/ref/crypt/ca.self-signed.pem")));
- chain.add (dcp::Certificate (dcp::file_to_string ("test/ref/crypt/intermediate.signed.pem")));
- chain.add (dcp::Certificate (dcp::file_to_string ("test/ref/crypt/leaf.signed.pem")));
-
- shared_ptr<dcp::Signer> signer (
- new dcp::Signer (
- chain,
- dcp::file_to_string ("test/ref/crypt/leaf.key")
- )
- );
+ shared_ptr<dcp::CertificateChain> signer (new dcp::CertificateChain ());
+ signer->add (dcp::Certificate (dcp::file_to_string ("test/ref/crypt/ca.self-signed.pem")));
+ signer->add (dcp::Certificate (dcp::file_to_string ("test/ref/crypt/intermediate.signed.pem")));
+ signer->add (dcp::Certificate (dcp::file_to_string ("test/ref/crypt/leaf.signed.pem")));
+ signer->set_key (dcp::file_to_string ("test/ref/crypt/leaf.key"));
shared_ptr<dcp::CPL> cpl (new dcp::CPL ("A Test DCP", dcp::FEATURE));
@@ -138,7 +132,7 @@ BOOST_AUTO_TEST_CASE (encryption_test)
"2012-07-17T04:45:18+00:00"
);
- kdm.encrypt (signer, signer->certificates().leaf(), dcp::MODIFIED_TRANSITIONAL_1).as_xml ("build/test/encryption_test.kdm.xml");
+ kdm.encrypt (signer, signer->leaf(), dcp::MODIFIED_TRANSITIONAL_1).as_xml ("build/test/encryption_test.kdm.xml");
int r = system (
"xmllint --path schema --nonet --noout --schema schema/SMPTE-430-1-2006-Amd-1-2009-KDM.xsd build/test/encryption_test.kdm.xml "
diff --git a/test/round_trip_test.cc b/test/round_trip_test.cc
index 38d1037a..a1f44a3e 100644
--- a/test/round_trip_test.cc
+++ b/test/round_trip_test.cc
@@ -20,7 +20,7 @@
#include "certificate.h"
#include "decrypted_kdm.h"
#include "encrypted_kdm.h"
-#include "signer.h"
+#include "certificate_chain.h"
#include "mono_picture_asset.h"
#include "sound_asset.h"
#include "reel.h"
@@ -46,7 +46,7 @@ using boost::scoped_array;
/** Build an encrypted picture asset and a KDM for it and check that the KDM can be decrypted */
BOOST_AUTO_TEST_CASE (round_trip_test)
{
- shared_ptr<dcp::Signer> signer (new dcp::Signer ("openssl"));
+ shared_ptr<dcp::CertificateChain> signer (new dcp::CertificateChain ("openssl"));
boost::filesystem::path work_dir = "build/test/round_trip_test";
boost::filesystem::create_directory (work_dir);
@@ -81,10 +81,10 @@ BOOST_AUTO_TEST_CASE (round_trip_test)
boost::filesystem::path const kdm_file = work_dir / "kdm.xml";
- kdm_A.encrypt(signer, signer->certificates().leaf(), dcp::MODIFIED_TRANSITIONAL_1).as_xml (kdm_file);
+ kdm_A.encrypt(signer, signer->leaf(), dcp::MODIFIED_TRANSITIONAL_1).as_xml (kdm_file);
/* Reload the KDM, using our private key to decrypt it */
- dcp::DecryptedKDM kdm_B (dcp::EncryptedKDM (dcp::file_to_string (kdm_file)), signer->key ());
+ dcp::DecryptedKDM kdm_B (dcp::EncryptedKDM (dcp::file_to_string (kdm_file)), signer->key().get ());
/* 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());