summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-12-10 17:17:16 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-12-10 17:17:16 (GMT)
commit4b65bb3fc0cfa55cf0533406877da20fb4da9e7b (patch)
tree3b8cc23d4e7c6397de179850bf006683bc40fa6c /Swiften/SASL/UnitTest
parent08cc79dfe35b0735ef49108b82c52f94aab02e84 (diff)
downloadswift-4b65bb3fc0cfa55cf0533406877da20fb4da9e7b.zip
swift-4b65bb3fc0cfa55cf0533406877da20fb4da9e7b.tar.bz2
Added TLS channel binding support to SCRAMSHA1ClientAuthenticator.
Diffstat (limited to 'Swiften/SASL/UnitTest')
-rw-r--r--Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp
index b65cdd3..0d12bd3 100644
--- a/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp
+++ b/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp
@@ -18,7 +18,11 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
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);
@@ -71,6 +75,26 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(String("n,a=a=3Du=2Cth,n=user,r=abcdefghABCDEFGH"), response.toString());
}
+ void testGetInitialResponse_WithoutChannelBindingWithTLSChannelBindingData() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false);
+ testling.setTLSChannelBindingData("xyza");
+ testling.setCredentials("user", "pass", "");
+
+ ByteArray response = *testling.getResponse();
+
+ CPPUNIT_ASSERT_EQUAL(String("y,,n=user,r=abcdefghABCDEFGH"), response.toString());
+ }
+
+ void testGetInitialResponse_WithChannelBindingWithTLSChannelBindingData() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", true);
+ testling.setTLSChannelBindingData("xyza");
+ testling.setCredentials("user", "pass", "");
+
+ ByteArray response = *testling.getResponse();
+
+ CPPUNIT_ASSERT_EQUAL(String("p=tls-server-end-point,,n=user,r=abcdefghABCDEFGH"), response.toString());
+ }
+
void testGetFinalResponse() {
SCRAMSHA1ClientAuthenticator testling("abcdefgh");
testling.setCredentials("user", "pass", "");
@@ -81,6 +105,28 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(String("c=biws,r=abcdefghABCDEFGH,p=CZbjGDpIteIJwQNBgO0P8pKkMGY="), response.toString());
}
+ void testGetFinalResponse_WithoutChannelBindingWithTLSChannelBindingData() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefgh", false);
+ testling.setCredentials("user", "pass", "");
+ testling.setTLSChannelBindingData("xyza");
+ testling.setChallenge(ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
+
+ ByteArray response = *testling.getResponse();
+
+ CPPUNIT_ASSERT_EQUAL(String("c=eSws,r=abcdefghABCDEFGH,p=JNpsiFEcxZvNZ1+FFBBqrYvYxMk="), response.toString());
+ }
+
+ void testGetFinalResponse_WithChannelBindingWithTLSChannelBindingData() {
+ SCRAMSHA1ClientAuthenticator testling("abcdefgh", true);
+ testling.setCredentials("user", "pass", "");
+ testling.setTLSChannelBindingData("xyza");
+ testling.setChallenge(ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
+
+ ByteArray response = *testling.getResponse();
+
+ CPPUNIT_ASSERT_EQUAL(String("c=cD10bHMtc2VydmVyLWVuZC1wb2ludCwseHl6YQ==,r=abcdefghABCDEFGH,p=ycZyNs03w1HlRzFmXl8dlKx3NAU="), response.toString());
+ }
+
void testSetFinalChallenge() {
SCRAMSHA1ClientAuthenticator testling("abcdefgh");
testling.setCredentials("user", "pass", "");