summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/QA/TLSTest/CertificateTest.cpp')
-rw-r--r--Swiften/QA/TLSTest/CertificateTest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/Swiften/QA/TLSTest/CertificateTest.cpp b/Swiften/QA/TLSTest/CertificateTest.cpp
index 02ec0f8..21f749c 100644
--- a/Swiften/QA/TLSTest/CertificateTest.cpp
+++ b/Swiften/QA/TLSTest/CertificateTest.cpp
@@ -30,12 +30,14 @@ class CertificateTest : public CppUnit::TestFixture {
30 CPPUNIT_TEST(testGetSRVNames); 30 CPPUNIT_TEST(testGetSRVNames);
31 CPPUNIT_TEST(testGetDNSNames); 31 CPPUNIT_TEST(testGetDNSNames);
32 CPPUNIT_TEST(testGetXMPPAddresses); 32 CPPUNIT_TEST(testGetXMPPAddresses);
33 CPPUNIT_TEST(testCreateCertificateChain);
33 CPPUNIT_TEST_SUITE_END(); 34 CPPUNIT_TEST_SUITE_END();
34 35
35 public: 36 public:
36 void setUp() { 37 void setUp() {
37 pathProvider = std::make_unique<PlatformApplicationPathProvider>("FileReadBytestreamTest"); 38 pathProvider = std::make_unique<PlatformApplicationPathProvider>("FileReadBytestreamTest");
38 readByteArrayFromFile(certificateData, (pathProvider->getExecutableDir() / "jabber_org.crt")); 39 readByteArrayFromFile(certificateData, (pathProvider->getExecutableDir() / "jabber_org.crt"));
40 readByteArrayFromFile(chainData, (pathProvider->getExecutableDir() / "certificateChain.pem"));
39 certificateFactory = std::unique_ptr<CertificateFactory>(new CERTIFICATE_FACTORY()); 41 certificateFactory = std::unique_ptr<CertificateFactory>(new CERTIFICATE_FACTORY());
40 } 42 }
41 43
@@ -88,9 +90,26 @@ class CertificateTest : public CppUnit::TestFixture {
88 CPPUNIT_ASSERT_EQUAL(std::string("*.jabber.org"), testling->getXMPPAddresses()[0]); 90 CPPUNIT_ASSERT_EQUAL(std::string("*.jabber.org"), testling->getXMPPAddresses()[0]);
89 } 91 }
90 92
93 void testCreateCertificateChain() {
94 // The input chain contains a 2-certificate chain:
95 // the first certificate has:
96 // a subject of "O=messaging,CN=Mixer Messaging Configuration,CN=badger.isode.net"
97 // an issuer of "O=messaging, CN=New Messaging CA"
98 // the second certificate has:
99 // a subject of "O=messaging, CN=New Messaging CA"
100 // an issuer of "O=messaging, CN=New Messaging CA"
101 // i.e. it is a self-signed certificate
102 std::vector<std::shared_ptr<Certificate>> chain = certificateFactory->createCertificateChain(chainData);
103 CPPUNIT_ASSERT_EQUAL(2,static_cast<int>(chain.size()));
104 CPPUNIT_ASSERT_EQUAL(std::string("Mixer Messaging Configuration"), chain[0]->getCommonNames()[0]);
105 CPPUNIT_ASSERT_EQUAL(std::string("badger.isode.net"), chain[0]->getCommonNames()[1]);
106 CPPUNIT_ASSERT_EQUAL(std::string("New Messaging CA"), chain[1]->getCommonNames()[0]);
107 }
108
91 private: 109 private:
92 std::unique_ptr<PlatformApplicationPathProvider> pathProvider; 110 std::unique_ptr<PlatformApplicationPathProvider> pathProvider;
93 ByteArray certificateData; 111 ByteArray certificateData;
112 ByteArray chainData;
94 std::unique_ptr<CertificateFactory> certificateFactory; 113 std::unique_ptr<CertificateFactory> certificateFactory;
95}; 114};
96 115