summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-11-09 20:25:49 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-11-09 21:41:52 (GMT)
commite9be6f9bb696da4e1bcf750afd7015de4fe9220a (patch)
tree3a062f59f1c06d9c792f680c6c6e2105cfeaba87 /Swiften/QA/OpenSSLTest/OpenSSLCertificateTest.cpp
parentb23637e59839f5f28258f518ac234b2ff62b6da2 (diff)
downloadswift-e9be6f9bb696da4e1bcf750afd7015de4fe9220a.zip
swift-e9be6f9bb696da4e1bcf750afd7015de4fe9220a.tar.bz2
Implement DER conversion to/from certificates.
Diffstat (limited to 'Swiften/QA/OpenSSLTest/OpenSSLCertificateTest.cpp')
-rw-r--r--Swiften/QA/OpenSSLTest/OpenSSLCertificateTest.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/Swiften/QA/OpenSSLTest/OpenSSLCertificateTest.cpp b/Swiften/QA/OpenSSLTest/OpenSSLCertificateTest.cpp
new file mode 100644
index 0000000..43519d7
--- /dev/null
+++ b/Swiften/QA/OpenSSLTest/OpenSSLCertificateTest.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <boost/bind.hpp>
+
+#include "Swiften/TLS/OpenSSL/OpenSSLCertificate.h"
+#include "SwifTools/Application/PlatformApplicationPathProvider.h"
+
+using namespace Swift;
+
+class OpenSSLCertificateTest : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(OpenSSLCertificateTest);
+ CPPUNIT_TEST(testConstructFromDER);
+ CPPUNIT_TEST(testToDER);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void setUp() {
+ pathProvider = new PlatformApplicationPathProvider("FileReadBytestreamTest");
+ }
+
+ void tearDown() {
+ delete pathProvider;
+ }
+
+ void testConstructFromDER() {
+ ByteArray in;
+ in.readFromFile((pathProvider->getExecutableDir() / "jabber_org.crt").string());
+ OpenSSLCertificate testling(in);
+
+ CPPUNIT_ASSERT_EQUAL(String("*.jabber.org"), testling.getCommonName());
+ }
+
+ void testToDER() {
+ ByteArray in;
+ in.readFromFile((pathProvider->getExecutableDir() / "jabber_org.crt").string());
+ OpenSSLCertificate testling(in);
+
+ CPPUNIT_ASSERT_EQUAL(in, testling.toDER());
+ }
+
+ private:
+ PlatformApplicationPathProvider* pathProvider;
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(OpenSSLCertificateTest);