Fix apparently broken test certificate chain (root certificate had wrong dnQualifier).
[libdcp.git] / test / util_test.cc
index 74a3e9200f3949e27e8123202185514bc2a420cd..34dc0c1862e2fd6c816131db3caeb4cfe023bcc6 100644 (file)
@@ -70,3 +70,52 @@ BOOST_AUTO_TEST_CASE (content_kind_test)
        BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("psa"), dcp::PUBLIC_SERVICE_ANNOUNCEMENT);
        BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("advertisement"), dcp::ADVERTISEMENT);
 }
+
+BOOST_AUTO_TEST_CASE (relative_to_root_test)
+{
+       {
+               boost::filesystem::path root = "a";
+               root /= "b";
+               
+               boost::filesystem::path file = "a";
+               file /= "b";
+               file /= "c";
+               
+               boost::optional<boost::filesystem::path> rel = dcp::relative_to_root (root, file);
+               BOOST_CHECK (rel);
+               BOOST_CHECK_EQUAL (rel.get(), boost::filesystem::path ("c"));
+       }
+
+       {
+               boost::filesystem::path root = "a";
+               root /= "b";
+               root /= "c";
+               
+               boost::filesystem::path file = "a";
+               file /= "b";
+               
+               boost::optional<boost::filesystem::path> rel = dcp::relative_to_root (root, file);
+               BOOST_CHECK (!rel);
+       }
+
+       {
+               boost::filesystem::path root = "a";
+               
+               boost::filesystem::path file = "a";
+               file /= "b";
+               file /= "c";
+               
+               boost::optional<boost::filesystem::path> rel = dcp::relative_to_root (root, file);
+               BOOST_CHECK (rel);
+
+               boost::filesystem::path check = "b";
+               check /= "c";
+               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=");
+}