diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-07-18 11:45:19 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-07-18 11:45:19 +0100 |
| commit | 9984f8318ba9999e39cf2f6688bd41408982cca9 (patch) | |
| tree | a74ace56260cbea8f326bc0cf9f5ca99e74353f0 /test | |
| parent | 56e7a6f1768036df852a45d939b9adc038b17057 (diff) | |
Various small tweaks and fixes.
Diffstat (limited to 'test')
| -rw-r--r-- | test/certificates_test.cc | 46 | ||||
| -rw-r--r-- | test/encryption_test.cc | 6 | ||||
| -rw-r--r-- | test/util_test.cc | 6 |
3 files changed, 32 insertions, 26 deletions
diff --git a/test/certificates_test.cc b/test/certificates_test.cc index 8cbe9527..4f0a41f9 100644 --- a/test/certificates_test.cc +++ b/test/certificates_test.cc @@ -31,9 +31,9 @@ BOOST_AUTO_TEST_CASE (certificates) { dcp::CertificateChain c; - c.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem")))); - c.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/intermediate.signed.pem")))); - c.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem")))); + c.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/ca.self-signed.pem")))); + c.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/intermediate.signed.pem")))); + c.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/leaf.signed.pem")))); dcp::CertificateChain::List leaf_to_root = c.leaf_to_root (); @@ -90,45 +90,45 @@ BOOST_AUTO_TEST_CASE (certificates) BOOST_AUTO_TEST_CASE (certificates_validation) { 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")))); + good1.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/ca.self-signed.pem")))); + good1.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/intermediate.signed.pem")))); + good1.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/leaf.signed.pem")))); BOOST_CHECK (good1.valid ()); dcp::CertificateChain good2; - good2.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem")))); + good2.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/ca.self-signed.pem")))); BOOST_CHECK (good2.valid ()); 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")))); + bad1.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/intermediate.signed.pem")))); + bad1.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/leaf.signed.pem")))); BOOST_CHECK (!bad1.valid ()); 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")))); + bad2.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/leaf.signed.pem")))); + bad2.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/ca.self-signed.pem")))); + bad2.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/intermediate.signed.pem")))); BOOST_CHECK (!bad2.valid ()); 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")))); + bad3.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/intermediate.signed.pem")))); + bad3.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/leaf.signed.pem")))); + bad3.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/ca.self-signed.pem")))); BOOST_CHECK (!bad3.valid ()); 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")))); + bad4.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/leaf.signed.pem")))); + bad4.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/intermediate.signed.pem")))); + bad4.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/ca.self-signed.pem")))); BOOST_CHECK (!bad4.valid ()); 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")))); + bad5.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/ca.self-signed.pem")))); + bad5.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/leaf.signed.pem")))); BOOST_CHECK (!bad5.valid ()); BOOST_CHECK (!bad5.attempt_reorder ()); } @@ -138,9 +138,9 @@ BOOST_AUTO_TEST_CASE (signer_validation) { /* Check a valid signer */ dcp::CertificateChain chain; - chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem")))); - chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/intermediate.signed.pem")))); - chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem")))); + chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/ca.self-signed.pem")))); + chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/intermediate.signed.pem")))); + chain.add (shared_ptr<dcp::Certificate> (new 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 ()); diff --git a/test/encryption_test.cc b/test/encryption_test.cc index 6d2e052e..e096c5fd 100644 --- a/test/encryption_test.cc +++ b/test/encryption_test.cc @@ -67,9 +67,9 @@ BOOST_AUTO_TEST_CASE (encryption_test) /* Use test/ref/crypt so this test is repeatable */ dcp::CertificateChain chain; - chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem")))); - chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/intermediate.signed.pem")))); - chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem")))); + chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/ca.self-signed.pem")))); + chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/intermediate.signed.pem")))); + chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (dcp::file_to_string ("test/ref/crypt/leaf.signed.pem")))); shared_ptr<dcp::Signer> signer ( new dcp::Signer ( diff --git a/test/util_test.cc b/test/util_test.cc index 15f22f57..34dc0c18 100644 --- a/test/util_test.cc +++ b/test/util_test.cc @@ -113,3 +113,9 @@ BOOST_AUTO_TEST_CASE (relative_to_root_test) BOOST_CHECK_EQUAL (rel.get(), check); } } + +/** Test private_key_fingerprint() */ +BOOST_AUTO_TEST_CASE (private_key_fingerprint_test) +{ + BOOST_CHECK_EQUAL (dcp::private_key_fingerprint (dcp::file_to_string ("test/data/private.key")), "Jdz1bFpCcKI7R16Ccx9JHYytag0="); +} |
