summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
committerTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
commitcfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch)
tree18d94153a302445196fc0c18586abf44a1ce4a38 /Swiften/SASL/UnitTest
parent1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff)
downloadswift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip
swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines in the process. Changed CheckTabs.py tool to disallow hard tabs in source files. Test-Information: Manually checked 30 random files that the conversion worked as expected. Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swiften/SASL/UnitTest')
-rw-r--r--Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp96
-rw-r--r--Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp76
-rw-r--r--Swiften/SASL/UnitTest/PLAINClientAuthenticatorTest.cpp30
-rw-r--r--Swiften/SASL/UnitTest/PLAINMessageTest.cpp98
-rw-r--r--Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp304
-rw-r--r--Swiften/SASL/UnitTest/WindowsServicePrincipalNameTest.cpp284
6 files changed, 444 insertions, 444 deletions
diff --git a/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp
index e8c613f..04e2df5 100644
--- a/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp
+++ b/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp
@@ -17,54 +17,54 @@
using namespace Swift;
class DIGESTMD5ClientAuthenticatorTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(DIGESTMD5ClientAuthenticatorTest);
- CPPUNIT_TEST(testGetInitialResponse);
- CPPUNIT_TEST(testGetResponse);
- CPPUNIT_TEST(testGetResponse_WithAuthorizationID);
- //CPPUNIT_TEST(testSetChallenge);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void setUp() {
- crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
- }
-
- void testGetInitialResponse() {
- DIGESTMD5ClientAuthenticator testling("xmpp.example.com", "abcdefgh", crypto.get());
-
- CPPUNIT_ASSERT(!testling.getResponse());
- }
-
- void testGetResponse() {
- DIGESTMD5ClientAuthenticator testling("xmpp.example.com", "abcdefgh", crypto.get());
-
- testling.setCredentials("user", createSafeByteArray("pass"), "");
- testling.setChallenge(createByteArray(
- "realm=\"example.com\","
- "nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\","
- "qop=auth,charset=utf-8,algorithm=md5-sess"));
-
- SafeByteArray response = *testling.getResponse();
-
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray("charset=utf-8,cnonce=\"abcdefgh\",digest-uri=\"xmpp/xmpp.example.com\",nc=00000001,nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\",qop=auth,realm=\"example.com\",response=088891c800ecff1b842159ad6459104a,username=\"user\""), response);
- }
-
- void testGetResponse_WithAuthorizationID() {
- DIGESTMD5ClientAuthenticator testling("xmpp.example.com", "abcdefgh", crypto.get());
-
- testling.setCredentials("user", createSafeByteArray("pass"), "myauthzid");
- testling.setChallenge(createByteArray(
- "realm=\"example.com\","
- "nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\","
- "qop=auth,charset=utf-8,algorithm=md5-sess"));
-
- SafeByteArray response = *testling.getResponse();
-
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray("authzid=\"myauthzid\",charset=utf-8,cnonce=\"abcdefgh\",digest-uri=\"xmpp/xmpp.example.com\",nc=00000001,nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\",qop=auth,realm=\"example.com\",response=4293834432b6e7889a2dee7e8fe7dd06,username=\"user\""), response);
- }
-
- private:
- boost::shared_ptr<CryptoProvider> crypto;
+ CPPUNIT_TEST_SUITE(DIGESTMD5ClientAuthenticatorTest);
+ CPPUNIT_TEST(testGetInitialResponse);
+ CPPUNIT_TEST(testGetResponse);
+ CPPUNIT_TEST(testGetResponse_WithAuthorizationID);
+ //CPPUNIT_TEST(testSetChallenge);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void setUp() {
+ crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
+ }
+
+ void testGetInitialResponse() {
+ DIGESTMD5ClientAuthenticator testling("xmpp.example.com", "abcdefgh", crypto.get());
+
+ CPPUNIT_ASSERT(!testling.getResponse());
+ }
+
+ void testGetResponse() {
+ DIGESTMD5ClientAuthenticator testling("xmpp.example.com", "abcdefgh", crypto.get());
+
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
+ testling.setChallenge(createByteArray(
+ "realm=\"example.com\","
+ "nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\","
+ "qop=auth,charset=utf-8,algorithm=md5-sess"));
+
+ SafeByteArray response = *testling.getResponse();
+
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray("charset=utf-8,cnonce=\"abcdefgh\",digest-uri=\"xmpp/xmpp.example.com\",nc=00000001,nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\",qop=auth,realm=\"example.com\",response=088891c800ecff1b842159ad6459104a,username=\"user\""), response);
+ }
+
+ void testGetResponse_WithAuthorizationID() {
+ DIGESTMD5ClientAuthenticator testling("xmpp.example.com", "abcdefgh", crypto.get());
+
+ testling.setCredentials("user", createSafeByteArray("pass"), "myauthzid");
+ testling.setChallenge(createByteArray(
+ "realm=\"example.com\","
+ "nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\","
+ "qop=auth,charset=utf-8,algorithm=md5-sess"));
+
+ SafeByteArray response = *testling.getResponse();
+
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray("authzid=\"myauthzid\",charset=utf-8,cnonce=\"abcdefgh\",digest-uri=\"xmpp/xmpp.example.com\",nc=00000001,nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\",qop=auth,realm=\"example.com\",response=4293834432b6e7889a2dee7e8fe7dd06,username=\"user\""), response);
+ }
+
+ private:
+ boost::shared_ptr<CryptoProvider> crypto;
};
CPPUNIT_TEST_SUITE_REGISTRATION(DIGESTMD5ClientAuthenticatorTest);
diff --git a/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp b/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp
index d47a1ee..841f580 100644
--- a/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp
+++ b/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp
@@ -12,44 +12,44 @@
using namespace Swift;
class DIGESTMD5PropertiesTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(DIGESTMD5PropertiesTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParse() {
- DIGESTMD5Properties properties = DIGESTMD5Properties::parse(createByteArray(
- "realm=\"myrealm1\",realm=\"myrealm2\",nonce=\"mynonce\","
- "algorithm=md5-sess,charset=utf-8"));
-
- CPPUNIT_ASSERT(properties.getValue("realm"));
- CPPUNIT_ASSERT_EQUAL(std::string("myrealm1"), *properties.getValue("realm"));
- CPPUNIT_ASSERT(properties.getValue("nonce"));
- CPPUNIT_ASSERT_EQUAL(std::string("mynonce"), *properties.getValue("nonce"));
- CPPUNIT_ASSERT(properties.getValue("algorithm"));
- CPPUNIT_ASSERT_EQUAL(std::string("md5-sess"), *properties.getValue("algorithm"));
- CPPUNIT_ASSERT(properties.getValue("charset"));
- CPPUNIT_ASSERT_EQUAL(std::string("utf-8"), *properties.getValue("charset"));
- }
-
- void testSerialize() {
- DIGESTMD5Properties properties;
- properties.setValue("authzid", "myauthzid");
- properties.setValue("charset", "utf-8");
- properties.setValue("cnonce", "mycnonce");
- properties.setValue("digest-uri", "mydigesturi");
- properties.setValue("nc", "1");
- properties.setValue("nonce", "mynonce");
- properties.setValue("qop", "auth");
- properties.setValue("realm", "myrealm");
- properties.setValue("response", "myresponse");
- properties.setValue("username", "myuser");
-
- ByteArray result = properties.serialize();
- ByteArray expected(createByteArray("authzid=\"myauthzid\",charset=utf-8,cnonce=\"mycnonce\",digest-uri=\"mydigesturi\",nc=1,nonce=\"mynonce\",qop=auth,realm=\"myrealm\",response=myresponse,username=\"myuser\""));
- CPPUNIT_ASSERT_EQUAL(byteArrayToString(expected), byteArrayToString(result));
- }
+ CPPUNIT_TEST_SUITE(DIGESTMD5PropertiesTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse() {
+ DIGESTMD5Properties properties = DIGESTMD5Properties::parse(createByteArray(
+ "realm=\"myrealm1\",realm=\"myrealm2\",nonce=\"mynonce\","
+ "algorithm=md5-sess,charset=utf-8"));
+
+ CPPUNIT_ASSERT(properties.getValue("realm"));
+ CPPUNIT_ASSERT_EQUAL(std::string("myrealm1"), *properties.getValue("realm"));
+ CPPUNIT_ASSERT(properties.getValue("nonce"));
+ CPPUNIT_ASSERT_EQUAL(std::string("mynonce"), *properties.getValue("nonce"));
+ CPPUNIT_ASSERT(properties.getValue("algorithm"));
+ CPPUNIT_ASSERT_EQUAL(std::string("md5-sess"), *properties.getValue("algorithm"));
+ CPPUNIT_ASSERT(properties.getValue("charset"));
+ CPPUNIT_ASSERT_EQUAL(std::string("utf-8"), *properties.getValue("charset"));
+ }
+
+ void testSerialize() {
+ DIGESTMD5Properties properties;
+ properties.setValue("authzid", "myauthzid");
+ properties.setValue("charset", "utf-8");
+ properties.setValue("cnonce", "mycnonce");
+ properties.setValue("digest-uri", "mydigesturi");
+ properties.setValue("nc", "1");
+ properties.setValue("nonce", "mynonce");
+ properties.setValue("qop", "auth");
+ properties.setValue("realm", "myrealm");
+ properties.setValue("response", "myresponse");
+ properties.setValue("username", "myuser");
+
+ ByteArray result = properties.serialize();
+ ByteArray expected(createByteArray("authzid=\"myauthzid\",charset=utf-8,cnonce=\"mycnonce\",digest-uri=\"mydigesturi\",nc=1,nonce=\"mynonce\",qop=auth,realm=\"myrealm\",response=myresponse,username=\"myuser\""));
+ CPPUNIT_ASSERT_EQUAL(byteArrayToString(expected), byteArrayToString(result));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(DIGESTMD5PropertiesTest);
diff --git a/Swiften/SASL/UnitTest/PLAINClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/PLAINClientAuthenticatorTest.cpp
index 67e5d75..070b4d9 100644
--- a/Swiften/SASL/UnitTest/PLAINClientAuthenticatorTest.cpp
+++ b/Swiften/SASL/UnitTest/PLAINClientAuthenticatorTest.cpp
@@ -14,27 +14,27 @@
using namespace Swift;
class PLAINClientAuthenticatorTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(PLAINClientAuthenticatorTest);
- CPPUNIT_TEST(testGetResponse_WithoutAuthzID);
- CPPUNIT_TEST(testGetResponse_WithAuthzID);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(PLAINClientAuthenticatorTest);
+ CPPUNIT_TEST(testGetResponse_WithoutAuthzID);
+ CPPUNIT_TEST(testGetResponse_WithAuthzID);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testGetResponse_WithoutAuthzID() {
- PLAINClientAuthenticator testling;
+ public:
+ void testGetResponse_WithoutAuthzID() {
+ PLAINClientAuthenticator testling;
- testling.setCredentials("user", createSafeByteArray("pass"));
+ testling.setCredentials("user", createSafeByteArray("pass"));
- CPPUNIT_ASSERT_EQUAL(*testling.getResponse(), createSafeByteArray("\0user\0pass", 10));
- }
+ CPPUNIT_ASSERT_EQUAL(*testling.getResponse(), createSafeByteArray("\0user\0pass", 10));
+ }
- void testGetResponse_WithAuthzID() {
- PLAINClientAuthenticator testling;
+ void testGetResponse_WithAuthzID() {
+ PLAINClientAuthenticator testling;
- testling.setCredentials("user", createSafeByteArray("pass"), "authz");
+ testling.setCredentials("user", createSafeByteArray("pass"), "authz");
- CPPUNIT_ASSERT_EQUAL(*testling.getResponse(), createSafeByteArray("authz\0user\0pass", 15));
- }
+ CPPUNIT_ASSERT_EQUAL(*testling.getResponse(), createSafeByteArray("authz\0user\0pass", 15));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(PLAINClientAuthenticatorTest);
diff --git a/Swiften/SASL/UnitTest/PLAINMessageTest.cpp b/Swiften/SASL/UnitTest/PLAINMessageTest.cpp
index b885eea..271b827 100644
--- a/Swiften/SASL/UnitTest/PLAINMessageTest.cpp
+++ b/Swiften/SASL/UnitTest/PLAINMessageTest.cpp
@@ -16,55 +16,55 @@ using namespace Swift;
class PLAINMessageTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(PLAINMessageTest);
- CPPUNIT_TEST(testGetValue_WithoutAuthzID);
- CPPUNIT_TEST(testGetValue_WithAuthzID);
- CPPUNIT_TEST(testConstructor_WithoutAuthzID);
- CPPUNIT_TEST(testConstructor_WithAuthzID);
- CPPUNIT_TEST(testConstructor_NoAuthcid);
- CPPUNIT_TEST(testConstructor_NoPassword);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- PLAINMessageTest() {}
-
- void testGetValue_WithoutAuthzID() {
- PLAINMessage message("user", createSafeByteArray("pass"));
- CPPUNIT_ASSERT_EQUAL(message.getValue(), createSafeByteArray("\0user\0pass", 10));
- }
-
- void testGetValue_WithAuthzID() {
- PLAINMessage message("user", createSafeByteArray("pass"), "authz");
- CPPUNIT_ASSERT_EQUAL(message.getValue(), createSafeByteArray("authz\0user\0pass", 15));
- }
-
- void testConstructor_WithoutAuthzID() {
- PLAINMessage message(createSafeByteArray("\0user\0pass", 10));
-
- CPPUNIT_ASSERT_EQUAL(std::string(""), message.getAuthorizationID());
- CPPUNIT_ASSERT_EQUAL(std::string("user"), message.getAuthenticationID());
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray("pass"), message.getPassword());
- }
-
- void testConstructor_WithAuthzID() {
- PLAINMessage message(createSafeByteArray("authz\0user\0pass", 15));
-
- CPPUNIT_ASSERT_EQUAL(std::string("authz"), message.getAuthorizationID());
- CPPUNIT_ASSERT_EQUAL(std::string("user"), message.getAuthenticationID());
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray("pass"), message.getPassword());
- }
-
- void testConstructor_NoAuthcid() {
- PLAINMessage message(createSafeByteArray("authzid", 7));
-
- CPPUNIT_ASSERT_EQUAL(std::string(""), message.getAuthenticationID());
- }
-
- void testConstructor_NoPassword() {
- PLAINMessage message(createSafeByteArray("authzid\0authcid", 15));
-
- CPPUNIT_ASSERT_EQUAL(std::string(""), message.getAuthenticationID());
- }
+ CPPUNIT_TEST_SUITE(PLAINMessageTest);
+ CPPUNIT_TEST(testGetValue_WithoutAuthzID);
+ CPPUNIT_TEST(testGetValue_WithAuthzID);
+ CPPUNIT_TEST(testConstructor_WithoutAuthzID);
+ CPPUNIT_TEST(testConstructor_WithAuthzID);
+ CPPUNIT_TEST(testConstructor_NoAuthcid);
+ CPPUNIT_TEST(testConstructor_NoPassword);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ PLAINMessageTest() {}
+
+ void testGetValue_WithoutAuthzID() {
+ PLAINMessage message("user", createSafeByteArray("pass"));
+ CPPUNIT_ASSERT_EQUAL(message.getValue(), createSafeByteArray("\0user\0pass", 10));
+ }
+
+ void testGetValue_WithAuthzID() {
+ PLAINMessage message("user", createSafeByteArray("pass"), "authz");
+ CPPUNIT_ASSERT_EQUAL(message.getValue(), createSafeByteArray("authz\0user\0pass", 15));
+ }
+
+ void testConstructor_WithoutAuthzID() {
+ PLAINMessage message(createSafeByteArray("\0user\0pass", 10));
+
+ CPPUNIT_ASSERT_EQUAL(std::string(""), message.getAuthorizationID());
+ CPPUNIT_ASSERT_EQUAL(std::string("user"), message.getAuthenticationID());
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray("pass"), message.getPassword());
+ }
+
+ void testConstructor_WithAuthzID() {
+ PLAINMessage message(createSafeByteArray("authz\0user\0pass", 15));
+
+ CPPUNIT_ASSERT_EQUAL(std::string("authz"), message.getAuthorizationID());
+ CPPUNIT_ASSERT_EQUAL(std::string("user"), message.getAuthenticationID());
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray("pass"), message.getPassword());
+ }
+
+ void testConstructor_NoAuthcid() {
+ PLAINMessage message(createSafeByteArray("authzid", 7));
+
+ CPPUNIT_ASSERT_EQUAL(std::string(""), message.getAuthenticationID());
+ }
+
+ void testConstructor_NoPassword() {
+ PLAINMessage message(createSafeByteArray("authzid\0authcid", 15));
+
+ CPPUNIT_ASSERT_EQUAL(std::string(""), message.getAuthenticationID());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(PLAINMessageTest);
diff --git a/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp
index 8b219af..3d5d161 100644
--- a/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp
+++ b/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp
@@ -19,215 +19,215 @@
using namespace Swift;
class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(SCRAMSHA1ClientAuthenticatorTest);
- CPPUNIT_TEST(testGetInitialResponse);
- CPPUNIT_TEST(testGetInitialResponse_UsernameHasSpecialChars);
- CPPUNIT_TEST(testGetInitialResponse_WithAuthorizationID);
- CPPUNIT_TEST(testGetInitialResponse_WithAuthorizationIDWithSpecialChars);
- CPPUNIT_TEST(testGetInitialResponse_WithoutChannelBindingWithTLSChannelBindingData);
- CPPUNIT_TEST(testGetInitialResponse_WithChannelBindingWithTLSChannelBindingData);
- CPPUNIT_TEST(testGetFinalResponse);
- CPPUNIT_TEST(testGetFinalResponse_WithoutChannelBindingWithTLSChannelBindingData);
- CPPUNIT_TEST(testGetFinalResponse_WithChannelBindingWithTLSChannelBindingData);
- CPPUNIT_TEST(testSetChallenge);
- CPPUNIT_TEST(testSetChallenge_InvalidClientNonce);
- CPPUNIT_TEST(testSetChallenge_OnlyClientNonce);
- CPPUNIT_TEST(testSetChallenge_InvalidIterations);
- CPPUNIT_TEST(testSetChallenge_ZeroIterations);
- CPPUNIT_TEST(testSetChallenge_NegativeIterations);
- CPPUNIT_TEST(testSetChallenge_MissingIterations);
- CPPUNIT_TEST(testSetFinalChallenge);
- CPPUNIT_TEST(testSetFinalChallenge_InvalidChallenge);
- CPPUNIT_TEST(testGetResponseAfterFinalChallenge);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(SCRAMSHA1ClientAuthenticatorTest);
+ CPPUNIT_TEST(testGetInitialResponse);
+ CPPUNIT_TEST(testGetInitialResponse_UsernameHasSpecialChars);
+ CPPUNIT_TEST(testGetInitialResponse_WithAuthorizationID);
+ CPPUNIT_TEST(testGetInitialResponse_WithAuthorizationIDWithSpecialChars);
+ CPPUNIT_TEST(testGetInitialResponse_WithoutChannelBindingWithTLSChannelBindingData);
+ CPPUNIT_TEST(testGetInitialResponse_WithChannelBindingWithTLSChannelBindingData);
+ CPPUNIT_TEST(testGetFinalResponse);
+ CPPUNIT_TEST(testGetFinalResponse_WithoutChannelBindingWithTLSChannelBindingData);
+ CPPUNIT_TEST(testGetFinalResponse_WithChannelBindingWithTLSChannelBindingData);
+ CPPUNIT_TEST(testSetChallenge);
+ CPPUNIT_TEST(testSetChallenge_InvalidClientNonce);
+ CPPUNIT_TEST(testSetChallenge_OnlyClientNonce);
+ CPPUNIT_TEST(testSetChallenge_InvalidIterations);
+ CPPUNIT_TEST(testSetChallenge_ZeroIterations);
+ CPPUNIT_TEST(testSetChallenge_NegativeIterations);
+ CPPUNIT_TEST(testSetChallenge_MissingIterations);
+ CPPUNIT_TEST(testSetFinalChallenge);
+ CPPUNIT_TEST(testSetFinalChallenge_InvalidChallenge);
+ CPPUNIT_TEST(testGetResponseAfterFinalChallenge);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void setUp() {
- idnConverter = boost::shared_ptr<IDNConverter>(PlatformIDNConverter::create());
- crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
- }
+ public:
+ void setUp() {
+ idnConverter = boost::shared_ptr<IDNConverter>(PlatformIDNConverter::create());
+ crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
+ }
- void testGetInitialResponse() {
- SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "");
+ void testGetInitialResponse() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
- SafeByteArray response = *testling.getResponse();
+ SafeByteArray response = *testling.getResponse();
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray("n,,n=user,r=abcdefghABCDEFGH"), response);
- }
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray("n,,n=user,r=abcdefghABCDEFGH"), response);
+ }
- void testGetInitialResponse_UsernameHasSpecialChars() {
- SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false, idnConverter.get(), crypto.get());
- testling.setCredentials(",us=,er=", createSafeByteArray("pass"), "");
+ void testGetInitialResponse_UsernameHasSpecialChars() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false, idnConverter.get(), crypto.get());
+ testling.setCredentials(",us=,er=", createSafeByteArray("pass"), "");
- SafeByteArray response = *testling.getResponse();
+ SafeByteArray response = *testling.getResponse();
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray("n,,n==2Cus=3D=2Cer=3D,r=abcdefghABCDEFGH"), response);
- }
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray("n,,n==2Cus=3D=2Cer=3D,r=abcdefghABCDEFGH"), response);
+ }
- void testGetInitialResponse_WithAuthorizationID() {
- SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "auth");
+ void testGetInitialResponse_WithAuthorizationID() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "auth");
- SafeByteArray response = *testling.getResponse();
+ SafeByteArray response = *testling.getResponse();
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray("n,a=auth,n=user,r=abcdefghABCDEFGH"), response);
- }
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray("n,a=auth,n=user,r=abcdefghABCDEFGH"), response);
+ }
- void testGetInitialResponse_WithAuthorizationIDWithSpecialChars() {
- SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "a=u,th");
+ void testGetInitialResponse_WithAuthorizationIDWithSpecialChars() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "a=u,th");
- SafeByteArray response = *testling.getResponse();
+ SafeByteArray response = *testling.getResponse();
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray("n,a=a=3Du=2Cth,n=user,r=abcdefghABCDEFGH"), response);
- }
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray("n,a=a=3Du=2Cth,n=user,r=abcdefghABCDEFGH"), response);
+ }
- void testGetInitialResponse_WithoutChannelBindingWithTLSChannelBindingData() {
- SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false, idnConverter.get(), crypto.get());
- testling.setTLSChannelBindingData(createByteArray("xyza"));
- testling.setCredentials("user", createSafeByteArray("pass"), "");
+ void testGetInitialResponse_WithoutChannelBindingWithTLSChannelBindingData() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false, idnConverter.get(), crypto.get());
+ testling.setTLSChannelBindingData(createByteArray("xyza"));
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
- SafeByteArray response = *testling.getResponse();
+ SafeByteArray response = *testling.getResponse();
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray("y,,n=user,r=abcdefghABCDEFGH"), response);
- }
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray("y,,n=user,r=abcdefghABCDEFGH"), response);
+ }
- void testGetInitialResponse_WithChannelBindingWithTLSChannelBindingData() {
- SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", true, idnConverter.get(), crypto.get());
- testling.setTLSChannelBindingData(createByteArray("xyza"));
- testling.setCredentials("user", createSafeByteArray("pass"), "");
+ void testGetInitialResponse_WithChannelBindingWithTLSChannelBindingData() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", true, idnConverter.get(), crypto.get());
+ testling.setTLSChannelBindingData(createByteArray("xyza"));
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
- SafeByteArray response = *testling.getResponse();
+ SafeByteArray response = *testling.getResponse();
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray("p=tls-unique,,n=user,r=abcdefghABCDEFGH"), response);
- }
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray("p=tls-unique,,n=user,r=abcdefghABCDEFGH"), response);
+ }
- void testGetFinalResponse() {
- SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "");
- testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
+ void testGetFinalResponse() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
+ testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
- SafeByteArray response = *testling.getResponse();
+ SafeByteArray response = *testling.getResponse();
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray("c=biws,r=abcdefghABCDEFGH,p=CZbjGDpIteIJwQNBgO0P8pKkMGY="), response);
- }
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray("c=biws,r=abcdefghABCDEFGH,p=CZbjGDpIteIJwQNBgO0P8pKkMGY="), response);
+ }
- void testGetFinalResponse_WithoutChannelBindingWithTLSChannelBindingData() {
- SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "");
- testling.setTLSChannelBindingData(createByteArray("xyza"));
- testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
+ void testGetFinalResponse_WithoutChannelBindingWithTLSChannelBindingData() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
+ testling.setTLSChannelBindingData(createByteArray("xyza"));
+ testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
- SafeByteArray response = *testling.getResponse();
+ SafeByteArray response = *testling.getResponse();
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray("c=eSws,r=abcdefghABCDEFGH,p=JNpsiFEcxZvNZ1+FFBBqrYvYxMk="), response);
- }
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray("c=eSws,r=abcdefghABCDEFGH,p=JNpsiFEcxZvNZ1+FFBBqrYvYxMk="), response);
+ }
- void testGetFinalResponse_WithChannelBindingWithTLSChannelBindingData() {
- SCRAMSHA1ClientAuthenticator testling("abcdefgh", true, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "");
- testling.setTLSChannelBindingData(createByteArray("xyza"));
- testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
+ void testGetFinalResponse_WithChannelBindingWithTLSChannelBindingData() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefgh", true, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
+ testling.setTLSChannelBindingData(createByteArray("xyza"));
+ testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
- SafeByteArray response = *testling.getResponse();
+ SafeByteArray response = *testling.getResponse();
- CPPUNIT_ASSERT_EQUAL(createSafeByteArray("c=cD10bHMtdW5pcXVlLCx4eXph,r=abcdefghABCDEFGH,p=i6Rghite81P1ype8XxaVAa5l7v0="), response);
- }
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray("c=cD10bHMtdW5pcXVlLCx4eXph,r=abcdefghABCDEFGH,p=i6Rghite81P1ype8XxaVAa5l7v0="), response);
+ }
- void testSetFinalChallenge() {
- SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "");
- testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
+ void testSetFinalChallenge() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
+ testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
- bool result = testling.setChallenge(createByteArray("v=Dd+Q20knZs9jeeK0pi1Mx1Se+yo="));
+ bool result = testling.setChallenge(createByteArray("v=Dd+Q20knZs9jeeK0pi1Mx1Se+yo="));
- CPPUNIT_ASSERT(result);
- }
+ CPPUNIT_ASSERT(result);
+ }
- void testSetChallenge() {
- SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "");
+ void testSetChallenge() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
- bool result = testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
+ bool result = testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
- CPPUNIT_ASSERT(result);
- }
+ CPPUNIT_ASSERT(result);
+ }
- void testSetChallenge_InvalidClientNonce() {
- SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "");
+ void testSetChallenge_InvalidClientNonce() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
- bool result = testling.setChallenge(createByteArray("r=abcdefgiABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
+ bool result = testling.setChallenge(createByteArray("r=abcdefgiABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
- CPPUNIT_ASSERT(!result);
- }
+ CPPUNIT_ASSERT(!result);
+ }
- void testSetChallenge_OnlyClientNonce() {
- SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "");
+ void testSetChallenge_OnlyClientNonce() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
- bool result = testling.setChallenge(createByteArray("r=abcdefgh,s=MTIzNDU2NzgK,i=4096"));
+ bool result = testling.setChallenge(createByteArray("r=abcdefgh,s=MTIzNDU2NzgK,i=4096"));
- CPPUNIT_ASSERT(!result);
- }
+ CPPUNIT_ASSERT(!result);
+ }
- void testSetChallenge_InvalidIterations() {
- SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "");
+ void testSetChallenge_InvalidIterations() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
- bool result = testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=bla"));
+ bool result = testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=bla"));
- CPPUNIT_ASSERT(!result);
- }
+ CPPUNIT_ASSERT(!result);
+ }
- void testSetChallenge_MissingIterations() {
- SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "");
+ void testSetChallenge_MissingIterations() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
- bool result = testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK"));
+ bool result = testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK"));
- CPPUNIT_ASSERT(!result);
- }
+ CPPUNIT_ASSERT(!result);
+ }
- void testSetChallenge_ZeroIterations() {
- SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "");
+ void testSetChallenge_ZeroIterations() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
- bool result = testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=0"));
+ bool result = testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=0"));
- CPPUNIT_ASSERT(!result);
- }
+ CPPUNIT_ASSERT(!result);
+ }
- void testSetChallenge_NegativeIterations() {
- SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "");
+ void testSetChallenge_NegativeIterations() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
- bool result = testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=-1"));
+ bool result = testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=-1"));
- CPPUNIT_ASSERT(!result);
- }
+ CPPUNIT_ASSERT(!result);
+ }
- void testSetFinalChallenge_InvalidChallenge() {
- SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "");
- testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
- bool result = testling.setChallenge(createByteArray("v=e26kI69ICb6zosapLLxrER/631A="));
+ void testSetFinalChallenge_InvalidChallenge() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
+ testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
+ bool result = testling.setChallenge(createByteArray("v=e26kI69ICb6zosapLLxrER/631A="));
- CPPUNIT_ASSERT(!result);
- }
+ CPPUNIT_ASSERT(!result);
+ }
- void testGetResponseAfterFinalChallenge() {
- SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
- testling.setCredentials("user", createSafeByteArray("pass"), "");
- testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
- testling.setChallenge(createByteArray("v=Dd+Q20knZs9jeeK0pi1Mx1Se+yo="));
+ void testGetResponseAfterFinalChallenge() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefgh", false, idnConverter.get(), crypto.get());
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
+ testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
+ testling.setChallenge(createByteArray("v=Dd+Q20knZs9jeeK0pi1Mx1Se+yo="));
- CPPUNIT_ASSERT(!testling.getResponse());
- }
+ CPPUNIT_ASSERT(!testling.getResponse());
+ }
- boost::shared_ptr<IDNConverter> idnConverter;
- boost::shared_ptr<CryptoProvider> crypto;
+ boost::shared_ptr<IDNConverter> idnConverter;
+ boost::shared_ptr<CryptoProvider> crypto;
};
CPPUNIT_TEST_SUITE_REGISTRATION(SCRAMSHA1ClientAuthenticatorTest);
diff --git a/Swiften/SASL/UnitTest/WindowsServicePrincipalNameTest.cpp b/Swiften/SASL/UnitTest/WindowsServicePrincipalNameTest.cpp
index 1b0e6f6..fa07052 100644
--- a/Swiften/SASL/UnitTest/WindowsServicePrincipalNameTest.cpp
+++ b/Swiften/SASL/UnitTest/WindowsServicePrincipalNameTest.cpp
@@ -11,151 +11,151 @@
using namespace Swift;
class WindowsServicePrincipalNameTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(WindowsServicePrincipalNameTest);
- CPPUNIT_TEST(testServiceClass);
- CPPUNIT_TEST(testServiceName);
- CPPUNIT_TEST(testInstanceName);
- CPPUNIT_TEST(testInstancePort);
- CPPUNIT_TEST(testReferrer);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testServiceClass() {
- WindowsServicePrincipalName spn("mlink.adlon.isode.net");
-
- CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/mlink.adlon.isode.net"));
-
- spn.setServiceClass("ldap");
- CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("ldap/mlink.adlon.isode.net"));
-
- spn.setServiceClass("中文");
- CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("中文/mlink.adlon.isode.net"));
-
- try {
- spn.setServiceClass("");
- spn.toString();
- CPPUNIT_ASSERT(false);
- } catch (std::runtime_error) {
- /* expected */
- }
-
- try {
- spn.setServiceClass("xm/pp"); /* Foward slash not allowed */
- spn.toString();
- CPPUNIT_ASSERT(false);
- } catch (std::runtime_error) {
- /* expected */
- }
- }
-
- void testServiceName() {
- try {
- WindowsServicePrincipalName spn("");
- spn.toString();
- CPPUNIT_ASSERT(false);
- } catch (std::runtime_error) {
- /* expected */
- }
-
- try {
- WindowsServicePrincipalName spn2("mlink/adlon.isode.net"); /* Foward slash not allowed */
- spn2.toString();
- CPPUNIT_ASSERT(false);
- } catch (std::runtime_error) {
- /* expected */
- }
-
- WindowsServicePrincipalName spn3("mlinkÄ.adlon.isode.net");
- CPPUNIT_ASSERT_EQUAL(spn3.toString(), std::string("xmpp/mlinkÄ.adlon.isode.net"));
- }
-
- void testInstanceName() {
- WindowsServicePrincipalName spn("adlon.isode.net");
-
- spn.setInstanceName("mlink.adlon.isode.net");
- CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/mlink.adlon.isode.net/adlon.isode.net"));
-
- spn.setInstanceName("127.0.0.1");
- CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/127.0.0.1/adlon.isode.net"));
-
- spn.setInstanceName("");
- CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/adlon.isode.net"));
-
- spn.setInstanceName("cañón.adlon.isode.net");
- CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/cañón.adlon.isode.net/adlon.isode.net"));
-
- try {
- spn.setInstanceName("mlink/adlon.isode.net"); /* Foward slash not allowed */
- spn.toString();
- CPPUNIT_ASSERT(false);
- } catch (std::runtime_error) {
- /* expected */
- }
- }
-
- void testInstancePort() {
- WindowsServicePrincipalName spn("adlon.isode.net");
-
- spn.setInstanceName("mlink.adlon.isode.net");
- spn.setInstancePort(6222);
- CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/mlink.adlon.isode.net:6222/adlon.isode.net"));
-
- spn.setInstancePort(0);
- CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/mlink.adlon.isode.net/adlon.isode.net"));
-
- WindowsServicePrincipalName spn2("mlink.adlon.isode.net");
-
- spn2.setInstancePort(6222);
- CPPUNIT_ASSERT_EQUAL(spn2.toString(), std::string("xmpp/mlink.adlon.isode.net:6222"));
-
- spn2.setInstancePort(0);
- CPPUNIT_ASSERT_EQUAL(spn2.toString(), std::string("xmpp/mlink.adlon.isode.net"));
- }
-
- void testReferrer() {
- WindowsServicePrincipalName spn("127.0.0.1");
-
- spn.setReferrer("referrer.net");
- CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/127.0.0.1/referrer.net"));
-
- spn.setInstancePort(6222);
- CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/127.0.0.1:6222/referrer.net"));
-
- spn.setReferrer("हिन्दी.net");
- CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/127.0.0.1:6222/हिन्दी.net"));
-
- try {
- spn.setReferrer("referrer/net"); /* Foward slash not allowed */
- spn.toString();
- CPPUNIT_ASSERT(false);
- } catch (std::runtime_error) {
- /* expected */
- }
-
- try {
- spn.setReferrer(""); /* seems like you must have referrer with an IP */
- spn.toString();
- CPPUNIT_ASSERT(false);
- } catch (std::runtime_error) {
- /* expected */
- }
-
- WindowsServicePrincipalName spn2("mlink.adlon.isode.net");
-
- spn2.setReferrer("referrer.net"); /* Referrer ignored if service name is not IP */
- CPPUNIT_ASSERT_EQUAL(spn2.toString(), std::string("xmpp/mlink.adlon.isode.net"));
-
- spn2.setReferrer("referrer/net"); /* Referrer ignored if service name is not IP */
- CPPUNIT_ASSERT_EQUAL(spn2.toString(), std::string("xmpp/mlink.adlon.isode.net"));
+ CPPUNIT_TEST_SUITE(WindowsServicePrincipalNameTest);
+ CPPUNIT_TEST(testServiceClass);
+ CPPUNIT_TEST(testServiceName);
+ CPPUNIT_TEST(testInstanceName);
+ CPPUNIT_TEST(testInstancePort);
+ CPPUNIT_TEST(testReferrer);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testServiceClass() {
+ WindowsServicePrincipalName spn("mlink.adlon.isode.net");
+
+ CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/mlink.adlon.isode.net"));
+
+ spn.setServiceClass("ldap");
+ CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("ldap/mlink.adlon.isode.net"));
+
+ spn.setServiceClass("中文");
+ CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("中文/mlink.adlon.isode.net"));
+
+ try {
+ spn.setServiceClass("");
+ spn.toString();
+ CPPUNIT_ASSERT(false);
+ } catch (std::runtime_error) {
+ /* expected */
+ }
+
+ try {
+ spn.setServiceClass("xm/pp"); /* Foward slash not allowed */
+ spn.toString();
+ CPPUNIT_ASSERT(false);
+ } catch (std::runtime_error) {
+ /* expected */
+ }
+ }
+
+ void testServiceName() {
+ try {
+ WindowsServicePrincipalName spn("");
+ spn.toString();
+ CPPUNIT_ASSERT(false);
+ } catch (std::runtime_error) {
+ /* expected */
+ }
+
+ try {
+ WindowsServicePrincipalName spn2("mlink/adlon.isode.net"); /* Foward slash not allowed */
+ spn2.toString();
+ CPPUNIT_ASSERT(false);
+ } catch (std::runtime_error) {
+ /* expected */
+ }
+
+ WindowsServicePrincipalName spn3("mlinkÄ.adlon.isode.net");
+ CPPUNIT_ASSERT_EQUAL(spn3.toString(), std::string("xmpp/mlinkÄ.adlon.isode.net"));
+ }
+
+ void testInstanceName() {
+ WindowsServicePrincipalName spn("adlon.isode.net");
+
+ spn.setInstanceName("mlink.adlon.isode.net");
+ CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/mlink.adlon.isode.net/adlon.isode.net"));
+
+ spn.setInstanceName("127.0.0.1");
+ CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/127.0.0.1/adlon.isode.net"));
+
+ spn.setInstanceName("");
+ CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/adlon.isode.net"));
+
+ spn.setInstanceName("cañón.adlon.isode.net");
+ CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/cañón.adlon.isode.net/adlon.isode.net"));
+
+ try {
+ spn.setInstanceName("mlink/adlon.isode.net"); /* Foward slash not allowed */
+ spn.toString();
+ CPPUNIT_ASSERT(false);
+ } catch (std::runtime_error) {
+ /* expected */
+ }
+ }
+
+ void testInstancePort() {
+ WindowsServicePrincipalName spn("adlon.isode.net");
+
+ spn.setInstanceName("mlink.adlon.isode.net");
+ spn.setInstancePort(6222);
+ CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/mlink.adlon.isode.net:6222/adlon.isode.net"));
+
+ spn.setInstancePort(0);
+ CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/mlink.adlon.isode.net/adlon.isode.net"));
+
+ WindowsServicePrincipalName spn2("mlink.adlon.isode.net");
+
+ spn2.setInstancePort(6222);
+ CPPUNIT_ASSERT_EQUAL(spn2.toString(), std::string("xmpp/mlink.adlon.isode.net:6222"));
+
+ spn2.setInstancePort(0);
+ CPPUNIT_ASSERT_EQUAL(spn2.toString(), std::string("xmpp/mlink.adlon.isode.net"));
+ }
+
+ void testReferrer() {
+ WindowsServicePrincipalName spn("127.0.0.1");
+
+ spn.setReferrer("referrer.net");
+ CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/127.0.0.1/referrer.net"));
+
+ spn.setInstancePort(6222);
+ CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/127.0.0.1:6222/referrer.net"));
+
+ spn.setReferrer("हिन्दी.net");
+ CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/127.0.0.1:6222/हिन्दी.net"));
+
+ try {
+ spn.setReferrer("referrer/net"); /* Foward slash not allowed */
+ spn.toString();
+ CPPUNIT_ASSERT(false);
+ } catch (std::runtime_error) {
+ /* expected */
+ }
+
+ try {
+ spn.setReferrer(""); /* seems like you must have referrer with an IP */
+ spn.toString();
+ CPPUNIT_ASSERT(false);
+ } catch (std::runtime_error) {
+ /* expected */
+ }
+
+ WindowsServicePrincipalName spn2("mlink.adlon.isode.net");
+
+ spn2.setReferrer("referrer.net"); /* Referrer ignored if service name is not IP */
+ CPPUNIT_ASSERT_EQUAL(spn2.toString(), std::string("xmpp/mlink.adlon.isode.net"));
+
+ spn2.setReferrer("referrer/net"); /* Referrer ignored if service name is not IP */
+ CPPUNIT_ASSERT_EQUAL(spn2.toString(), std::string("xmpp/mlink.adlon.isode.net"));
- WindowsServicePrincipalName spn3("adlon.isode.net");
+ WindowsServicePrincipalName spn3("adlon.isode.net");
- spn3.setInstanceName("mlink.adlon.isode.net");
- spn3.setInstancePort(6222);
- spn3.setReferrer("referrer.net"); /* Referrer ignored if service name is not IP */
- CPPUNIT_ASSERT_EQUAL(spn3.toString(), std::string("xmpp/mlink.adlon.isode.net:6222/adlon.isode.net"));
+ spn3.setInstanceName("mlink.adlon.isode.net");
+ spn3.setInstancePort(6222);
+ spn3.setReferrer("referrer.net"); /* Referrer ignored if service name is not IP */
+ CPPUNIT_ASSERT_EQUAL(spn3.toString(), std::string("xmpp/mlink.adlon.isode.net:6222/adlon.isode.net"));
- }
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(WindowsServicePrincipalNameTest);