2 Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "lib/kdm_util.h"
23 #include <dcp/certificate.h>
25 #include <boost/test/unit_test.hpp>
28 BOOST_AUTO_TEST_CASE(check_kdm_and_certificate_validity_periods_good)
30 auto const result = check_kdm_and_certificate_validity_periods(
31 dcp::Certificate(dcp::file_to_string("test/data/cert.pem")),
32 dcp::LocalTime("2023-01-03T10:30:00"),
33 dcp::LocalTime("2050-10-20T14:00:00")
36 BOOST_CHECK(result == KDMCertificatePeriod::KDM_WITHIN_CERTIFICATE);
40 BOOST_AUTO_TEST_CASE(check_kdm_and_certificate_validity_periods_overlap_start)
42 auto const result = check_kdm_and_certificate_validity_periods(
43 dcp::Certificate(dcp::file_to_string("test/data/cert.pem")),
44 dcp::LocalTime("2011-01-03T10:30:00"),
45 dcp::LocalTime("2050-10-20T14:00:00")
48 BOOST_CHECK(result == KDMCertificatePeriod::KDM_OVERLAPS_CERTIFICATE);
52 BOOST_AUTO_TEST_CASE(check_kdm_and_certificate_validity_periods_overlap_end)
54 auto const result = check_kdm_and_certificate_validity_periods(
55 dcp::Certificate(dcp::file_to_string("test/data/cert.pem")),
56 dcp::LocalTime("2033-01-03T10:30:00"),
57 dcp::LocalTime("2095-10-20T14:00:00")
60 BOOST_CHECK(result == KDMCertificatePeriod::KDM_OVERLAPS_CERTIFICATE);
64 BOOST_AUTO_TEST_CASE(check_kdm_and_certificate_validity_periods_overlap_start_and_end)
66 auto const result = check_kdm_and_certificate_validity_periods(
67 dcp::Certificate(dcp::file_to_string("test/data/cert.pem")),
68 dcp::LocalTime("2011-01-03T10:30:00"),
69 dcp::LocalTime("2095-10-20T14:00:00")
72 BOOST_CHECK(result == KDMCertificatePeriod::KDM_OVERLAPS_CERTIFICATE);
76 BOOST_AUTO_TEST_CASE(check_kdm_and_certificate_validity_periods_outside)
78 auto const result = check_kdm_and_certificate_validity_periods(
79 dcp::Certificate(dcp::file_to_string("test/data/cert.pem")),
80 dcp::LocalTime("2011-01-03T10:30:00"),
81 dcp::LocalTime("2012-10-20T14:00:00")
84 BOOST_CHECK(result == KDMCertificatePeriod::KDM_OUTSIDE_CERTIFICATE);