summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-07-17 16:12:56 +0100
committerCarl Hetherington <cth@carlh.net>2014-07-17 16:12:56 +0100
commit3d77daab7639c06d1cdbeb852559fc4be5671819 (patch)
tree1bbe412ad4107a4b3dde663eb6397079c65de465 /test
parente21bb3e3c2cf5d0d971f1a5cf25da431fcde0409 (diff)
Add variousn new bits to CertificateChain.
Diffstat (limited to 'test')
-rw-r--r--test/certificates_test.cc28
1 files changed, 21 insertions, 7 deletions
diff --git a/test/certificates_test.cc b/test/certificates_test.cc
index 57ecd2f7..3e345948 100644
--- a/test/certificates_test.cc
+++ b/test/certificates_test.cc
@@ -82,35 +82,49 @@ BOOST_AUTO_TEST_CASE (certificates)
BOOST_CHECK_EQUAL (test.certificate(), c.root()->certificate());
}
-/** Check that dcp::CertificateChain::validate() basically works */
+/** Check that dcp::CertificateChain::validate() and ::attempt_reorder() basically work */
BOOST_AUTO_TEST_CASE (certificates_validation)
{
- dcp::CertificateChain good;
- good.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem"))));
- good.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/intermediate.signed.pem"))));
- good.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem"))));
- BOOST_CHECK (good.verify ());
-
+ dcp::CertificateChain good1;
+ good1.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem"))));
+ good1.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/intermediate.signed.pem"))));
+ good1.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem"))));
+ BOOST_CHECK (good1.verify ());
+
+ dcp::CertificateChain good2;
+ good2.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem"))));
+ BOOST_CHECK (good2.verify ());
+
dcp::CertificateChain bad1;
bad1.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/intermediate.signed.pem"))));
bad1.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem"))));
BOOST_CHECK (!bad1.verify ());
+ BOOST_CHECK (!bad1.attempt_reorder ());
dcp::CertificateChain bad2;
bad2.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem"))));
bad2.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem"))));
bad2.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/intermediate.signed.pem"))));
BOOST_CHECK (!bad2.verify ());
+ BOOST_CHECK (bad2.attempt_reorder ());
dcp::CertificateChain bad3;
bad3.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/intermediate.signed.pem"))));
bad3.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem"))));
bad3.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem"))));
BOOST_CHECK (!bad3.verify ());
+ BOOST_CHECK (bad3.attempt_reorder ());
dcp::CertificateChain bad4;
bad4.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem"))));
bad4.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/intermediate.signed.pem"))));
bad4.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem"))));
BOOST_CHECK (!bad4.verify ());
+ BOOST_CHECK (bad4.attempt_reorder ());
+
+ dcp::CertificateChain bad5;
+ bad5.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem"))));
+ bad5.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem"))));
+ BOOST_CHECK (!bad5.verify ());
+ BOOST_CHECK (!bad5.attempt_reorder ());
}