summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/TLS/UnitTest/ServerIdentityVerifierTest.cpp')
-rw-r--r--Swiften/TLS/UnitTest/ServerIdentityVerifierTest.cpp40
1 files changed, 24 insertions, 16 deletions
diff --git a/Swiften/TLS/UnitTest/ServerIdentityVerifierTest.cpp b/Swiften/TLS/UnitTest/ServerIdentityVerifierTest.cpp
index bd68c84..e974eb7 100644
--- a/Swiften/TLS/UnitTest/ServerIdentityVerifierTest.cpp
+++ b/Swiften/TLS/UnitTest/ServerIdentityVerifierTest.cpp
@@ -12,6 +12,8 @@
#include <Swiften/TLS/ServerIdentityVerifier.h>
#include <Swiften/TLS/SimpleCertificate.h>
+#include <Swiften/IDN/IDNConverter.h>
+#include <Swiften/IDN/PlatformIDNConverter.h>
using namespace Swift;
@@ -36,8 +38,12 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE_END();
public:
+ void setUp() {
+ idnConverter = boost::shared_ptr<IDNConverter>(PlatformIDNConverter::create());
+ }
+
void testCertificateVerifies_WithoutMatchingDNSName() {
- ServerIdentityVerifier testling(JID("foo@bar.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@bar.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addDNSName("foo.com");
@@ -45,7 +51,7 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
}
void testCertificateVerifies_WithMatchingDNSName() {
- ServerIdentityVerifier testling(JID("foo@bar.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@bar.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addDNSName("bar.com");
@@ -53,7 +59,7 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
}
void testCertificateVerifies_WithSecondMatchingDNSName() {
- ServerIdentityVerifier testling(JID("foo@bar.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@bar.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addDNSName("foo.com");
certificate->addDNSName("bar.com");
@@ -62,7 +68,7 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
}
void testCertificateVerifies_WithMatchingInternationalDNSName() {
- ServerIdentityVerifier testling(JID("foo@tron\xc3\xa7on.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@tron\xc3\xa7on.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addDNSName("xn--tronon-zua.com");
@@ -70,7 +76,7 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
}
void testCertificateVerifies_WithMatchingDNSNameWithWildcard() {
- ServerIdentityVerifier testling(JID("foo@im.bar.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@im.bar.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addDNSName("*.bar.com");
@@ -78,7 +84,7 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
}
void testCertificateVerifies_WithMatchingDNSNameWithWildcardMatchingNoComponents() {
- ServerIdentityVerifier testling(JID("foo@bar.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@bar.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addDNSName("*.bar.com");
@@ -86,7 +92,7 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
}
void testCertificateVerifies_WithDNSNameWithWildcardMatchingTwoComponents() {
- ServerIdentityVerifier testling(JID("foo@xmpp.im.bar.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@xmpp.im.bar.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addDNSName("*.bar.com");
@@ -94,7 +100,7 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
}
void testCertificateVerifies_WithMatchingSRVNameWithoutService() {
- ServerIdentityVerifier testling(JID("foo@bar.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@bar.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addSRVName("bar.com");
@@ -102,7 +108,7 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
}
void testCertificateVerifies_WithMatchingSRVNameWithService() {
- ServerIdentityVerifier testling(JID("foo@bar.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@bar.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addSRVName("_xmpp-client.bar.com");
@@ -110,7 +116,7 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
}
void testCertificateVerifies_WithMatchingSRVNameWithServiceAndWildcard() {
- ServerIdentityVerifier testling(JID("foo@im.bar.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@im.bar.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addSRVName("_xmpp-client.*.bar.com");
@@ -118,7 +124,7 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
}
void testCertificateVerifies_WithMatchingSRVNameWithDifferentService() {
- ServerIdentityVerifier testling(JID("foo@bar.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@bar.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addSRVName("_xmpp-server.bar.com");
@@ -126,7 +132,7 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
}
void testCertificateVerifies_WithMatchingXmppAddr() {
- ServerIdentityVerifier testling(JID("foo@bar.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@bar.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addXMPPAddress("bar.com");
@@ -134,7 +140,7 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
}
void testCertificateVerifies_WithMatchingXmppAddrWithWildcard() {
- ServerIdentityVerifier testling(JID("foo@im.bar.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@im.bar.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addXMPPAddress("*.bar.com");
@@ -142,7 +148,7 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
}
void testCertificateVerifies_WithMatchingInternationalXmppAddr() {
- ServerIdentityVerifier testling(JID("foo@tron\xc3\xa7.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@tron\xc3\xa7.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addXMPPAddress("tron\xc3\xa7.com");
@@ -150,7 +156,7 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
}
void testCertificateVerifies_WithMatchingCNWithoutSAN() {
- ServerIdentityVerifier testling(JID("foo@bar.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@bar.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addCommonName("bar.com");
@@ -158,13 +164,15 @@ class ServerIdentityVerifierTest : public CppUnit::TestFixture {
}
void testCertificateVerifies_WithMatchingCNWithSAN() {
- ServerIdentityVerifier testling(JID("foo@bar.com/baz"));
+ ServerIdentityVerifier testling(JID("foo@bar.com/baz"), idnConverter.get());
SimpleCertificate::ref certificate(new SimpleCertificate());
certificate->addSRVName("foo.com");
certificate->addCommonName("bar.com");
CPPUNIT_ASSERT(!testling.certificateVerifies(certificate));
}
+
+ boost::shared_ptr<IDNConverter> idnConverter;
};
CPPUNIT_TEST_SUITE_REGISTRATION(ServerIdentityVerifierTest);