No-op: whitespace.
[libdcp.git] / test / certificates_test.cc
1 /*
2     Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <boost/test/unit_test.hpp>
21 #include "certificates.h"
22
23 using std::list;
24 using boost::shared_ptr;
25
26 BOOST_AUTO_TEST_CASE (certificates)
27 {
28         libdcp::CertificateChain c;
29
30         c.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem"))));
31         c.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("test/ref/crypt/intermediate.signed.pem"))));
32         c.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem"))));
33
34         list<shared_ptr<libdcp::Certificate> > leaf_to_root = c.leaf_to_root ();
35
36         list<shared_ptr<libdcp::Certificate> >::iterator i = leaf_to_root.begin ();
37
38         /* Leaf */
39         BOOST_CHECK_EQUAL (*i, c.leaf ());
40
41         BOOST_CHECK_EQUAL (
42                 c.leaf()->issuer(),
43                 "dnQualifier=bmtwThq3srgxIAeRMjX6BFhgLDw=,CN=.smpte-430-2.INTERMEDIATE.NOT_FOR_PRODUCTION,OU=example.org,O=example.org"
44                 );
45
46         BOOST_CHECK_EQUAL (
47                 c.leaf()->subject(),
48                 "dnQualifier=d95fGDzERNdxfYPgphvAR8A18L4=,CN=CS.smpte-430-2.LEAF.NOT_FOR_PRODUCTION,OU=example.org,O=example.org"
49                 );
50
51         ++i;
52
53         /* Intermediate */
54         BOOST_CHECK_EQUAL (
55                 (*i)->issuer(),
56                 "dnQualifier=ndND9A/cODo2rTdrbLVmfQnoaSc=,CN=.smpte-430-2.ROOT.NOT_FOR_PRODUCTION,OU=example.org,O=example.org"
57                 );
58
59         BOOST_CHECK_EQUAL (
60                 (*i)->subject(),
61                 "dnQualifier=bmtwThq3srgxIAeRMjX6BFhgLDw=,CN=.smpte-430-2.INTERMEDIATE.NOT_FOR_PRODUCTION,OU=example.org,O=example.org"
62                 );
63
64         ++i;
65
66         /* Root */
67         BOOST_CHECK_EQUAL (*i, c.root ());
68         BOOST_CHECK_EQUAL (
69                 c.root()->issuer(),
70                 "dnQualifier=ndND9A/cODo2rTdrbLVmfQnoaSc=,CN=.smpte-430-2.ROOT.NOT_FOR_PRODUCTION,OU=example.org,O=example.org"
71                 );
72
73         BOOST_CHECK_EQUAL (c.root()->serial(), "5");
74
75         BOOST_CHECK_EQUAL (
76                 c.root()->subject(),
77                 "dnQualifier=ndND9A/cODo2rTdrbLVmfQnoaSc=,CN=.smpte-430-2.ROOT.NOT_FOR_PRODUCTION,OU=example.org,O=example.org"
78                 );
79
80         /* Check that reconstruction from a string works */
81         libdcp::Certificate test (c.root()->certificate (true));
82         BOOST_CHECK_EQUAL (test.certificate(), c.root()->certificate());
83 }