summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTarun Gupta <tarun1995gupta@gmail.com>2015-07-22 22:21:20 (GMT)
committerNick Hudson <nick.hudson@isode.com>2015-08-03 14:06:04 (GMT)
commitaf3bb03053b9d83f4d38b31d66b292792206a327 (patch)
tree0e5826f6b1fbb638d899ee6aadca902a7c2fdb18 /test
parent32ef37b9059e21de19209a9a1ab4ef2564051918 (diff)
downloadstroke-af3bb03053b9d83f4d38b31d66b292792206a327.zip
stroke-af3bb03053b9d83f4d38b31d66b292792206a327.tar.bz2
Make SASL equivalent with Swiften.
Adds DIGESTMD5ClientAuthenticator, DIGESTMD5Properties, ExternalClientAuthenticator, PLAINMessage. Updates Client, ClientSession, CoreClient, ConnectDisconnect, StrokeGUI to reflect changes made in SASL. Updates ClientAuthenticator, SCRAMSHA1ClientAuthenticator, PBKDF2. License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details. Test-Information: Added tests for DIGESTMD5ClientAuthenticator, DIGESTMD5Properties, PLAINClientAuthenticator, PLAINMessage. Update test for SCRAMSHA1ClientAuthenticatorTest. All tests pass. Change-Id: I4fd38f922cab7e4c4548d9706f6ad3b9e1506e81
Diffstat (limited to 'test')
-rw-r--r--test/com/isode/stroke/pubsub/Client.java2
-rw-r--r--test/com/isode/stroke/pubsub/TestMain.java5
-rw-r--r--test/com/isode/stroke/sasl/DIGESTMD5ClientAuthenticatorTest.java72
-rw-r--r--test/com/isode/stroke/sasl/DIGESTMD5PropertiesTest.java60
-rw-r--r--test/com/isode/stroke/sasl/PLAINClientAuthenticatorTest.java43
-rw-r--r--test/com/isode/stroke/sasl/PLAINMessageTest.java69
-rw-r--r--test/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticatorTest.java107
7 files changed, 308 insertions, 50 deletions
diff --git a/test/com/isode/stroke/pubsub/Client.java b/test/com/isode/stroke/pubsub/Client.java
index c68ba96..5a0059d 100644
--- a/test/com/isode/stroke/pubsub/Client.java
+++ b/test/com/isode/stroke/pubsub/Client.java
@@ -22,7 +22,7 @@ public class Client {
static boolean debugInfo = false;
static boolean debugInfoXml = false;
- public Client(String name, JID jid, String password, JavaNetworkFactories networkFactories, final Slot connectCallback) {
+ public Client(String name, JID jid, SafeByteArray password, JavaNetworkFactories networkFactories, final Slot connectCallback) {
name_ = name;
connecting_ = true;
connected_ = false;
diff --git a/test/com/isode/stroke/pubsub/TestMain.java b/test/com/isode/stroke/pubsub/TestMain.java
index 2088898..40b46e0 100644
--- a/test/com/isode/stroke/pubsub/TestMain.java
+++ b/test/com/isode/stroke/pubsub/TestMain.java
@@ -40,15 +40,16 @@ import com.isode.stroke.jid.JID;
import com.isode.stroke.network.JavaNetworkFactories;
import com.isode.stroke.signals.Slot;
import com.isode.stroke.signals.Slot2;
+import com.isode.stroke.base.SafeByteArray;
public class TestMain {
/* begin test parameters */
static String _server = "stan.isode.net";
static String _pubJID = "test1@stan.isode.net";
- static String _pubPass = "password";
+ static SafeByteArray _pubPass = new SafeByteArray("password");
static String _subJID = "test2@stan.isode.net";
- static String _subPass = "password";
+ static SafeByteArray _subPass = new SafeByteArray("password");
static String _pubSubDomain = "pubsub.stan.isode.net";
static String _pubSubNode = "testnode";
/* end test parameters */
diff --git a/test/com/isode/stroke/sasl/DIGESTMD5ClientAuthenticatorTest.java b/test/com/isode/stroke/sasl/DIGESTMD5ClientAuthenticatorTest.java
new file mode 100644
index 0000000..92c8b7c
--- /dev/null
+++ b/test/com/isode/stroke/sasl/DIGESTMD5ClientAuthenticatorTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2010-2013 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.sasl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.junit.Before;
+import com.isode.stroke.sasl.DIGESTMD5ClientAuthenticator;
+import com.isode.stroke.base.ByteArray;
+import com.isode.stroke.base.SafeByteArray;
+import com.isode.stroke.crypto.CryptoProvider;
+import com.isode.stroke.crypto.JavaCryptoProvider;
+
+public class DIGESTMD5ClientAuthenticatorTest {
+
+ private CryptoProvider crypto;
+
+ @Before
+ public void setUp() {
+ crypto = new JavaCryptoProvider();
+ }
+
+ @Test
+ public void testGetInitialResponse() {
+ DIGESTMD5ClientAuthenticator testling = new DIGESTMD5ClientAuthenticator("xmpp.example.com", "abcdefgh", crypto);
+
+ assertNull(testling.getResponse());
+ }
+
+ @Test
+ public void testGetResponse() {
+ DIGESTMD5ClientAuthenticator testling = new DIGESTMD5ClientAuthenticator("xmpp.example.com", "abcdefgh", crypto);
+
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
+ testling.setChallenge(new ByteArray(
+ "realm=\"example.com\","
+ + "nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\","
+ + "qop=auth,charset=utf-8,algorithm=md5-sess"));
+
+ SafeByteArray response = testling.getResponse();
+
+ assertEquals(new SafeByteArray("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);
+ }
+
+ @Test
+ public void testGetResponse_WithAuthorizationID() {
+ DIGESTMD5ClientAuthenticator testling = new DIGESTMD5ClientAuthenticator("xmpp.example.com", "abcdefgh", crypto);
+
+ testling.setCredentials("user", new SafeByteArray("pass"), "myauthzid");
+ testling.setChallenge(new ByteArray(
+ "realm=\"example.com\","
+ + "nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\","
+ + "qop=auth,charset=utf-8,algorithm=md5-sess"));
+
+ SafeByteArray response = testling.getResponse();
+
+ assertEquals(new SafeByteArray("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);
+ }
+}
diff --git a/test/com/isode/stroke/sasl/DIGESTMD5PropertiesTest.java b/test/com/isode/stroke/sasl/DIGESTMD5PropertiesTest.java
new file mode 100644
index 0000000..1288b2f
--- /dev/null
+++ b/test/com/isode/stroke/sasl/DIGESTMD5PropertiesTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2010 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.sasl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.junit.Before;
+import com.isode.stroke.sasl.DIGESTMD5Properties;
+import com.isode.stroke.base.ByteArray;
+
+public class DIGESTMD5PropertiesTest {
+
+ @Test
+ public void testParse() {
+ DIGESTMD5Properties properties = DIGESTMD5Properties.parse(new ByteArray(
+ "realm=\"myrealm1\",realm=\"myrealm2\",nonce=\"mynonce\","
+ + "algorithm=md5-sess,charset=utf-8"));
+
+ assertNotNull(properties.getValue("realm"));
+ assertEquals(("myrealm1"), properties.getValue("realm"));
+ assertNotNull(properties.getValue("nonce"));
+ assertEquals(("mynonce"), properties.getValue("nonce"));
+ assertNotNull(properties.getValue("algorithm"));
+ assertEquals(("md5-sess"), properties.getValue("algorithm"));
+ assertNotNull(properties.getValue("charset"));
+ assertEquals(("utf-8"), properties.getValue("charset"));
+ }
+
+ @Test
+ public void testSerialize() {
+ DIGESTMD5Properties properties = new DIGESTMD5Properties();
+ 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 = new ByteArray("authzid=\"myauthzid\",charset=utf-8,cnonce=\"mycnonce\",digest-uri=\"mydigesturi\",nc=1,nonce=\"mynonce\",qop=auth,realm=\"myrealm\",response=myresponse,username=\"myuser\"");
+ assertEquals(expected.toString(), result.toString());
+ }
+} \ No newline at end of file
diff --git a/test/com/isode/stroke/sasl/PLAINClientAuthenticatorTest.java b/test/com/isode/stroke/sasl/PLAINClientAuthenticatorTest.java
new file mode 100644
index 0000000..2f9170b
--- /dev/null
+++ b/test/com/isode/stroke/sasl/PLAINClientAuthenticatorTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.sasl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.junit.Before;
+import com.isode.stroke.sasl.PLAINClientAuthenticator;
+import com.isode.stroke.base.SafeByteArray;
+
+public class PLAINClientAuthenticatorTest {
+
+ @Test
+ public void testGetResponse_WithoutAuthzID() {
+ PLAINClientAuthenticator testling = new PLAINClientAuthenticator();
+
+ testling.setCredentials("user", new SafeByteArray("pass"));
+
+ assertEquals(testling.getResponse(), new SafeByteArray("\0user\0pass"));
+ }
+
+ @Test
+ public void testGetResponse_WithAuthzID() {
+ PLAINClientAuthenticator testling = new PLAINClientAuthenticator();
+
+ testling.setCredentials("user", new SafeByteArray("pass"), "authz");
+
+ assertEquals(testling.getResponse(), new SafeByteArray("authz\0user\0pass"));
+ }
+} \ No newline at end of file
diff --git a/test/com/isode/stroke/sasl/PLAINMessageTest.java b/test/com/isode/stroke/sasl/PLAINMessageTest.java
new file mode 100644
index 0000000..de7f5ee
--- /dev/null
+++ b/test/com/isode/stroke/sasl/PLAINMessageTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2010 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.sasl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.junit.Before;
+import com.isode.stroke.sasl.PLAINMessage;
+import com.isode.stroke.base.SafeByteArray;
+
+public class PLAINMessageTest {
+
+ @Test
+ public void testGetValue_WithoutAuthzID() {
+ PLAINMessage message = new PLAINMessage("user", new SafeByteArray("pass"));
+ assertEquals(message.getValue(), new SafeByteArray("\0user\0pass"));
+ }
+
+ @Test
+ public void testGetValue_WithAuthzID() {
+ PLAINMessage message = new PLAINMessage("user", new SafeByteArray("pass"), "authz");
+ assertEquals(message.getValue(), new SafeByteArray("authz\0user\0pass"));
+ }
+
+ @Test
+ public void testConstructor_WithoutAuthzID() {
+ PLAINMessage message = new PLAINMessage(new SafeByteArray("\0user\0pass"));
+
+ assertEquals((""), message.getAuthorizationID());
+ assertEquals(("user"), message.getAuthenticationID());
+ assertEquals(new SafeByteArray("pass"), message.getPassword());
+ }
+
+ @Test
+ public void testConstructor_WithAuthzID() {
+ PLAINMessage message = new PLAINMessage(new SafeByteArray("authz\0user\0pass"));
+
+ assertEquals(("authz"), message.getAuthorizationID());
+ assertEquals(("user"), message.getAuthenticationID());
+ assertEquals(new SafeByteArray("pass"), message.getPassword());
+ }
+
+ @Test
+ public void testConstructor_NoAuthcid() {
+ PLAINMessage message = new PLAINMessage(new SafeByteArray("authzid"));
+
+ assertEquals((""), message.getAuthenticationID());
+ }
+
+ @Test
+ public void testConstructor_NoPassword() {
+ PLAINMessage message = new PLAINMessage(new SafeByteArray("authzid\0authcid"));
+
+ assertEquals((""), message.getAuthenticationID());
+ }
+}
diff --git a/test/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticatorTest.java b/test/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticatorTest.java
index 7217d8d..9969ebd 100644
--- a/test/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticatorTest.java
+++ b/test/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticatorTest.java
@@ -14,6 +14,10 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
+import com.isode.stroke.idn.IDNConverter;
+import com.isode.stroke.idn.ICUConverter;
+import com.isode.stroke.crypto.CryptoProvider;
+import com.isode.stroke.crypto.JavaCryptoProvider;
/**
*
@@ -21,107 +25,116 @@ import static org.junit.Assert.*;
*/
public class SCRAMSHA1ClientAuthenticatorTest {
+ private IDNConverter idnConverter;
+ private CryptoProvider crypto;
+
+ @Before
+ public void setUp() {
+ idnConverter = new ICUConverter();
+ crypto = new JavaCryptoProvider();
+ }
+
@Test
public void testGetInitialResponse() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH");
- testling.setCredentials("user", "pass", "");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH", false, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
SafeByteArray response = testling.getResponse();
- assertEquals(new ByteArray("n,,n=user,r=abcdefghABCDEFGH"), response);
+ assertEquals(new SafeByteArray("n,,n=user,r=abcdefghABCDEFGH"), response);
}
@Test
public void testGetInitialResponse_UsernameHasSpecialChars() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH");
- testling.setCredentials(",us=,er=", "pass", "");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH", false, idnConverter, crypto);
+ testling.setCredentials(",us=,er=", new SafeByteArray("pass"), "");
SafeByteArray response = testling.getResponse();
- assertEquals(new ByteArray("n,,n==2Cus=3D=2Cer=3D,r=abcdefghABCDEFGH"), response);
+ assertEquals(new SafeByteArray("n,,n==2Cus=3D=2Cer=3D,r=abcdefghABCDEFGH"), response);
}
@Test
public void testGetInitialResponse_WithAuthorizationID() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH");
- testling.setCredentials("user", "pass", "auth");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH", false, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "auth");
SafeByteArray response = testling.getResponse();
- assertEquals(new ByteArray("n,a=auth,n=user,r=abcdefghABCDEFGH"), response);
+ assertEquals(new SafeByteArray("n,a=auth,n=user,r=abcdefghABCDEFGH"), response);
}
@Test
public void testGetInitialResponse_WithAuthorizationIDWithSpecialChars() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH");
- testling.setCredentials("user", "pass", "a=u,th");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH", false, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "a=u,th");
SafeByteArray response = testling.getResponse();
- assertEquals(new ByteArray("n,a=a=3Du=2Cth,n=user,r=abcdefghABCDEFGH"), response);
+ assertEquals(new SafeByteArray("n,a=a=3Du=2Cth,n=user,r=abcdefghABCDEFGH"), response);
}
@Test
public void testGetInitialResponse_WithoutChannelBindingWithTLSChannelBindingData() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH", false);
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH", false, idnConverter, crypto);
testling.setTLSChannelBindingData(new ByteArray("xyza"));
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
SafeByteArray response = testling.getResponse();
- assertEquals(new ByteArray("y,,n=user,r=abcdefghABCDEFGH"), response);
+ assertEquals(new SafeByteArray("y,,n=user,r=abcdefghABCDEFGH"), response);
}
@Test
public void testGetInitialResponse_WithChannelBindingWithTLSChannelBindingData() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH", true);
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH", true, idnConverter, crypto);
testling.setTLSChannelBindingData(new ByteArray("xyza"));
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
SafeByteArray response = testling.getResponse();
- assertEquals(new ByteArray("p=tls-unique,,n=user,r=abcdefghABCDEFGH"), response);
+ assertEquals(new SafeByteArray("p=tls-unique,,n=user,r=abcdefghABCDEFGH"), response);
}
@Test
public void testGetFinalResponse() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh", false, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
assertTrue(testling.setChallenge(new ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096")));
SafeByteArray response = testling.getResponse();
- assertEquals(new ByteArray("c=biws,r=abcdefghABCDEFGH,p=CZbjGDpIteIJwQNBgO0P8pKkMGY="), response);
+ assertEquals(new SafeByteArray("c=biws,r=abcdefghABCDEFGH,p=CZbjGDpIteIJwQNBgO0P8pKkMGY="), response);
}
@Test
public void testGetFinalResponse_WithoutChannelBindingWithTLSChannelBindingData() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh", false);
- testling.setCredentials("user", "pass", "");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh", false, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
testling.setTLSChannelBindingData(new ByteArray("xyza"));
testling.setChallenge(new ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
SafeByteArray response = testling.getResponse();
- assertEquals(new ByteArray("c=eSws,r=abcdefghABCDEFGH,p=JNpsiFEcxZvNZ1+FFBBqrYvYxMk="), response);
+ assertEquals(new SafeByteArray("c=eSws,r=abcdefghABCDEFGH,p=JNpsiFEcxZvNZ1+FFBBqrYvYxMk="), response);
}
@Test
public void testGetFinalResponse_WithChannelBindingWithTLSChannelBindingData() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh", true);
- testling.setCredentials("user", "pass", "");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh", true, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
testling.setTLSChannelBindingData(new ByteArray("xyza"));
testling.setChallenge(new ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
SafeByteArray response = testling.getResponse();
- assertEquals(new ByteArray("c=cD10bHMtdW5pcXVlLCx4eXph,r=abcdefghABCDEFGH,p=i6Rghite81P1ype8XxaVAa5l7v0="), response);
+ assertEquals(new SafeByteArray("c=cD10bHMtdW5pcXVlLCx4eXph,r=abcdefghABCDEFGH,p=i6Rghite81P1ype8XxaVAa5l7v0="), response);
}
@Test
public void testSetFinalChallenge() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh", false, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
testling.setChallenge(new ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
boolean result = testling.setChallenge(new ByteArray("v=Dd+Q20knZs9jeeK0pi1Mx1Se+yo="));
@@ -131,8 +144,8 @@ public class SCRAMSHA1ClientAuthenticatorTest {
@Test
public void testSetChallenge() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh", false, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
boolean result = testling.setChallenge(new ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
@@ -141,8 +154,8 @@ public class SCRAMSHA1ClientAuthenticatorTest {
@Test
public void testSetChallenge_InvalidClientNonce() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh", false, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
boolean result = testling.setChallenge(new ByteArray("r=abcdefgiABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
@@ -151,8 +164,8 @@ public class SCRAMSHA1ClientAuthenticatorTest {
@Test
public void testSetChallenge_OnlyClientNonce() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh", false, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
boolean result = testling.setChallenge(new ByteArray("r=abcdefgh,s=MTIzNDU2NzgK,i=4096"));
@@ -161,8 +174,8 @@ public class SCRAMSHA1ClientAuthenticatorTest {
@Test
public void testSetChallenge_InvalidIterations() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh", false, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
boolean result = testling.setChallenge(new ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=bla"));
@@ -171,8 +184,8 @@ public class SCRAMSHA1ClientAuthenticatorTest {
@Test
public void testSetChallenge_MissingIterations() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh", false, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
boolean result = testling.setChallenge(new ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK"));
@@ -181,8 +194,8 @@ public class SCRAMSHA1ClientAuthenticatorTest {
@Test
public void testSetChallenge_ZeroIterations() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh", false, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
boolean result = testling.setChallenge(new ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=0"));
@@ -191,8 +204,8 @@ public class SCRAMSHA1ClientAuthenticatorTest {
@Test
public void testSetChallenge_NegativeIterations() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh", false, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
boolean result = testling.setChallenge(new ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=-1"));
@@ -201,8 +214,8 @@ public class SCRAMSHA1ClientAuthenticatorTest {
@Test
public void testSetFinalChallenge_InvalidChallenge() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh", false, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
testling.setChallenge(new ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
boolean result = testling.setChallenge(new ByteArray("v=e26kI69ICb6zosapLLxrER/631A="));
@@ -211,8 +224,8 @@ public class SCRAMSHA1ClientAuthenticatorTest {
@Test
public void testGetResponseAfterFinalChallenge() {
- SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefgh", false, idnConverter, crypto);
+ testling.setCredentials("user", new SafeByteArray("pass"), "");
testling.setChallenge(new ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
testling.setChallenge(new ByteArray("v=Dd+Q20knZs9jeeK0pi1Mx1Se+yo="));