summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-06-03 18:11:02 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-06-03 18:11:02 (GMT)
commitc3fa606c7ac060c4929e7082e0e24531b093112f (patch)
tree394cf72c0b43fa706319592dfdb1438335b6116a /Swiften/SASL/UnitTest
parent8406d818fcb2a511b1e4264a10fd9069ec020d72 (diff)
downloadswift-c3fa606c7ac060c4929e7082e0e24531b093112f.zip
swift-c3fa606c7ac060c4929e7082e0e24531b093112f.tar.bz2
Distinguish an empty SASL message from no SASL message.
Diffstat (limited to 'Swiften/SASL/UnitTest')
-rw-r--r--Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp8
-rw-r--r--Swiften/SASL/UnitTest/PLAINClientAuthenticatorTest.cpp4
-rw-r--r--Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp24
3 files changed, 16 insertions, 20 deletions
diff --git a/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp
index e16c202..8daea4f 100644
--- a/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp
+++ b/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp
@@ -25,9 +25,7 @@ class DIGESTMD5ClientAuthenticatorTest : public CppUnit::TestFixture {
void testGetInitialResponse() {
DIGESTMD5ClientAuthenticator testling("xmpp.example.com", "abcdefgh");
- ByteArray response = testling.getResponse();
-
- CPPUNIT_ASSERT(response.isEmpty());
+ CPPUNIT_ASSERT(!testling.getResponse());
}
void testGetResponse() {
@@ -39,7 +37,7 @@ class DIGESTMD5ClientAuthenticatorTest : public CppUnit::TestFixture {
"nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\","
"qop=auth,charset=utf-8,algorithm=md5-sess"));
- ByteArray response = testling.getResponse();
+ ByteArray response = *testling.getResponse();
CPPUNIT_ASSERT_EQUAL(String("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.toString());
}
@@ -53,7 +51,7 @@ class DIGESTMD5ClientAuthenticatorTest : public CppUnit::TestFixture {
"nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\","
"qop=auth,charset=utf-8,algorithm=md5-sess"));
- ByteArray response = testling.getResponse();
+ ByteArray response = *testling.getResponse();
CPPUNIT_ASSERT_EQUAL(String("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.toString());
}
diff --git a/Swiften/SASL/UnitTest/PLAINClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/PLAINClientAuthenticatorTest.cpp
index 818e02e..7784898 100644
--- a/Swiften/SASL/UnitTest/PLAINClientAuthenticatorTest.cpp
+++ b/Swiften/SASL/UnitTest/PLAINClientAuthenticatorTest.cpp
@@ -23,7 +23,7 @@ class PLAINClientAuthenticatorTest : public CppUnit::TestFixture {
testling.setCredentials("user", "pass");
- CPPUNIT_ASSERT_EQUAL(testling.getResponse(), ByteArray("\0user\0pass", 10));
+ CPPUNIT_ASSERT_EQUAL(*testling.getResponse(), ByteArray("\0user\0pass", 10));
}
void testGetResponse_WithAuthzID() {
@@ -31,7 +31,7 @@ class PLAINClientAuthenticatorTest : public CppUnit::TestFixture {
testling.setCredentials("user", "pass", "authz");
- CPPUNIT_ASSERT_EQUAL(testling.getResponse(), ByteArray("authz\0user\0pass", 15));
+ CPPUNIT_ASSERT_EQUAL(*testling.getResponse(), ByteArray("authz\0user\0pass", 15));
}
};
diff --git a/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp
index 0fce39a..b65cdd3 100644
--- a/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp
+++ b/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp
@@ -39,36 +39,36 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH");
testling.setCredentials("user", "pass", "");
- ByteArray response = testling.getResponse();
+ ByteArray response = *testling.getResponse();
- CPPUNIT_ASSERT_EQUAL(String("n,,n=user,r=abcdefghABCDEFGH"), testling.getResponse().toString());
+ CPPUNIT_ASSERT_EQUAL(String("n,,n=user,r=abcdefghABCDEFGH"), response.toString());
}
void testGetInitialResponse_UsernameHasSpecialChars() {
SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH");
testling.setCredentials(",us=,er=", "pass", "");
- ByteArray response = testling.getResponse();
+ ByteArray response = *testling.getResponse();
- CPPUNIT_ASSERT_EQUAL(String("n,,n==2Cus=3D=2Cer=3D,r=abcdefghABCDEFGH"), testling.getResponse().toString());
+ CPPUNIT_ASSERT_EQUAL(String("n,,n==2Cus=3D=2Cer=3D,r=abcdefghABCDEFGH"), response.toString());
}
void testGetInitialResponse_WithAuthorizationID() {
SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH");
testling.setCredentials("user", "pass", "auth");
- ByteArray response = testling.getResponse();
+ ByteArray response = *testling.getResponse();
- CPPUNIT_ASSERT_EQUAL(String("n,a=auth,n=user,r=abcdefghABCDEFGH"), testling.getResponse().toString());
+ CPPUNIT_ASSERT_EQUAL(String("n,a=auth,n=user,r=abcdefghABCDEFGH"), response.toString());
}
void testGetInitialResponse_WithAuthorizationIDWithSpecialChars() {
SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH");
testling.setCredentials("user", "pass", "a=u,th");
- ByteArray response = testling.getResponse();
+ ByteArray response = *testling.getResponse();
- CPPUNIT_ASSERT_EQUAL(String("n,a=a=3Du=2Cth,n=user,r=abcdefghABCDEFGH"), testling.getResponse().toString());
+ CPPUNIT_ASSERT_EQUAL(String("n,a=a=3Du=2Cth,n=user,r=abcdefghABCDEFGH"), response.toString());
}
void testGetFinalResponse() {
@@ -76,9 +76,9 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
testling.setCredentials("user", "pass", "");
testling.setChallenge(ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
- ByteArray response = testling.getResponse();
+ ByteArray response = *testling.getResponse();
- CPPUNIT_ASSERT_EQUAL(String("c=biws,r=abcdefghABCDEFGH,p=CZbjGDpIteIJwQNBgO0P8pKkMGY="), testling.getResponse().toString());
+ CPPUNIT_ASSERT_EQUAL(String("c=biws,r=abcdefghABCDEFGH,p=CZbjGDpIteIJwQNBgO0P8pKkMGY="), response.toString());
}
void testSetFinalChallenge() {
@@ -169,9 +169,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
testling.setChallenge(ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
testling.setChallenge(ByteArray("v=Dd+Q20knZs9jeeK0pi1Mx1Se+yo="));
- ByteArray result = testling.getResponse();
-
- CPPUNIT_ASSERT_EQUAL(ByteArray(), result);
+ CPPUNIT_ASSERT(!testling.getResponse());
}
};