summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/QA')
-rw-r--r--Swiften/QA/OpenSSLTest/.gitignore1
-rw-r--r--Swiften/QA/OpenSSLTest/OpenSSLCertificateTest.cpp51
-rw-r--r--Swiften/QA/OpenSSLTest/SConscript18
-rw-r--r--Swiften/QA/OpenSSLTest/jabber_org.crtbin0 -> 2081 bytes
-rw-r--r--Swiften/QA/SConscript5
5 files changed, 75 insertions, 0 deletions
diff --git a/Swiften/QA/OpenSSLTest/.gitignore b/Swiften/QA/OpenSSLTest/.gitignore
new file mode 100644
index 0000000..27154e7
--- /dev/null
+++ b/Swiften/QA/OpenSSLTest/.gitignore
@@ -0,0 +1 @@
+OpenSSLTest
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);
diff --git a/Swiften/QA/OpenSSLTest/SConscript b/Swiften/QA/OpenSSLTest/SConscript
new file mode 100644
index 0000000..a3309f2
--- /dev/null
+++ b/Swiften/QA/OpenSSLTest/SConscript
@@ -0,0 +1,18 @@
+import os
+
+Import("env")
+
+if env["TEST"] :
+ myenv = env.Clone()
+ myenv.MergeFlags(myenv["CHECKER_FLAGS"])
+ myenv.MergeFlags(myenv["SWIFTOOLS_FLAGS"])
+ myenv.MergeFlags(myenv["SWIFTEN_FLAGS"])
+ myenv.MergeFlags(myenv["CPPUNIT_FLAGS"])
+ myenv.MergeFlags(myenv["BOOST_FLAGS"])
+ myenv.MergeFlags(myenv["LIBIDN_FLAGS"])
+ myenv.MergeFlags(myenv["OPENSSL_FLAGS"])
+
+ tester = myenv.Program("OpenSSLTest", [
+ "OpenSSLCertificateTest.cpp",
+ ])
+ myenv.Test(tester, "system")
diff --git a/Swiften/QA/OpenSSLTest/jabber_org.crt b/Swiften/QA/OpenSSLTest/jabber_org.crt
new file mode 100644
index 0000000..5a9ddaa
--- /dev/null
+++ b/Swiften/QA/OpenSSLTest/jabber_org.crt
Binary files differ
diff --git a/Swiften/QA/SConscript b/Swiften/QA/SConscript
index 8fb7c24..97b6ed0 100644
--- a/Swiften/QA/SConscript
+++ b/Swiften/QA/SConscript
@@ -1,3 +1,5 @@
+Import("swiften_env")
+
SConscript(dirs = [
"NetworkTest",
# "ReconnectTest",
@@ -5,3 +7,6 @@ SConscript(dirs = [
# "DNSSDTest",
"StorageTest",
])
+
+if swiften_env.get("HAVE_OPENSSL", False) :
+ SConscript(dirs = ["OpenSSLTest"])