diff options
author | Tarun Gupta <tarun1995gupta@gmail.com> | 2015-07-16 21:51:13 (GMT) |
---|---|---|
committer | Nick Hudson <nick.hudson@isode.com> | 2015-07-28 10:41:23 (GMT) |
commit | 6f84f6a65b8b80e2f599dff76da0cd13fbead611 (patch) | |
tree | 9a4b503a82d58cfc4884817945fcd26a0c0f9ba4 /test | |
parent | 9a419f5fff0701e672e241a515ce3e91438b3e1b (diff) | |
download | stroke-6f84f6a65b8b80e2f599dff76da0cd13fbead611.zip stroke-6f84f6a65b8b80e2f599dff76da0cd13fbead611.tar.bz2 |
Update Serializers and Parsers.
Updates Serializers and Parsers along with one minor change in XMPPlayer.
Update Non Payload Serializers to return SafeByteArray.
Updates SafeByteArray to return SafeByteArray on append and plus method.
License:
This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Test-Information:
None.
Change-Id: I6fe665a26b10cac37b3e3acd9ec15c211ac9b8ab
Diffstat (limited to 'test')
6 files changed, 44 insertions, 38 deletions
diff --git a/test/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticatorTest.java b/test/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticatorTest.java index 44a179e..7217d8d 100644 --- a/test/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticatorTest.java +++ b/test/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticatorTest.java @@ -9,6 +9,7 @@ package com.isode.stroke.sasl; import com.isode.stroke.base.ByteArray; +import com.isode.stroke.base.SafeByteArray; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -25,7 +26,7 @@ public class SCRAMSHA1ClientAuthenticatorTest { SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH"); testling.setCredentials("user", "pass", ""); - ByteArray response = testling.getResponse(); + SafeByteArray response = testling.getResponse(); assertEquals(new ByteArray("n,,n=user,r=abcdefghABCDEFGH"), response); } @@ -35,7 +36,7 @@ public class SCRAMSHA1ClientAuthenticatorTest { SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH"); testling.setCredentials(",us=,er=", "pass", ""); - ByteArray response = testling.getResponse(); + SafeByteArray response = testling.getResponse(); assertEquals(new ByteArray("n,,n==2Cus=3D=2Cer=3D,r=abcdefghABCDEFGH"), response); } @@ -45,7 +46,7 @@ public class SCRAMSHA1ClientAuthenticatorTest { SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH"); testling.setCredentials("user", "pass", "auth"); - ByteArray response = testling.getResponse(); + SafeByteArray response = testling.getResponse(); assertEquals(new ByteArray("n,a=auth,n=user,r=abcdefghABCDEFGH"), response); } @@ -55,7 +56,7 @@ public class SCRAMSHA1ClientAuthenticatorTest { SCRAMSHA1ClientAuthenticator testling = new SCRAMSHA1ClientAuthenticator("abcdefghABCDEFGH"); testling.setCredentials("user", "pass", "a=u,th"); - ByteArray response = testling.getResponse(); + SafeByteArray response = testling.getResponse(); assertEquals(new ByteArray("n,a=a=3Du=2Cth,n=user,r=abcdefghABCDEFGH"), response); } @@ -66,7 +67,7 @@ public class SCRAMSHA1ClientAuthenticatorTest { testling.setTLSChannelBindingData(new ByteArray("xyza")); testling.setCredentials("user", "pass", ""); - ByteArray response = testling.getResponse(); + SafeByteArray response = testling.getResponse(); assertEquals(new ByteArray("y,,n=user,r=abcdefghABCDEFGH"), response); } @@ -77,7 +78,7 @@ public class SCRAMSHA1ClientAuthenticatorTest { testling.setTLSChannelBindingData(new ByteArray("xyza")); testling.setCredentials("user", "pass", ""); - ByteArray response = testling.getResponse(); + SafeByteArray response = testling.getResponse(); assertEquals(new ByteArray("p=tls-unique,,n=user,r=abcdefghABCDEFGH"), response); } @@ -88,7 +89,7 @@ public class SCRAMSHA1ClientAuthenticatorTest { testling.setCredentials("user", "pass", ""); assertTrue(testling.setChallenge(new ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"))); - ByteArray response = testling.getResponse(); + SafeByteArray response = testling.getResponse(); assertEquals(new ByteArray("c=biws,r=abcdefghABCDEFGH,p=CZbjGDpIteIJwQNBgO0P8pKkMGY="), response); } @@ -100,7 +101,7 @@ public class SCRAMSHA1ClientAuthenticatorTest { testling.setTLSChannelBindingData(new ByteArray("xyza")); testling.setChallenge(new ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096")); - ByteArray response = testling.getResponse(); + SafeByteArray response = testling.getResponse(); assertEquals(new ByteArray("c=eSws,r=abcdefghABCDEFGH,p=JNpsiFEcxZvNZ1+FFBBqrYvYxMk="), response); } @@ -112,7 +113,7 @@ public class SCRAMSHA1ClientAuthenticatorTest { testling.setTLSChannelBindingData(new ByteArray("xyza")); testling.setChallenge(new ByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096")); - ByteArray response = testling.getResponse(); + SafeByteArray response = testling.getResponse(); assertEquals(new ByteArray("c=cD10bHMtdW5pcXVlLCx4eXph,r=abcdefghABCDEFGH,p=i6Rghite81P1ype8XxaVAa5l7v0="), response); } diff --git a/test/com/isode/stroke/serializer/AuthChallengeSerializerTest.java b/test/com/isode/stroke/serializer/AuthChallengeSerializerTest.java index 44ed1b8..cc1523b 100644 --- a/test/com/isode/stroke/serializer/AuthChallengeSerializerTest.java +++ b/test/com/isode/stroke/serializer/AuthChallengeSerializerTest.java @@ -16,6 +16,7 @@ import org.junit.Test; import com.isode.stroke.serializer.AuthChallengeSerializer; import com.isode.stroke.elements.AuthChallenge; import com.isode.stroke.base.ByteArray; +import com.isode.stroke.base.SafeByteArray; public class AuthChallengeSerializerTest { @@ -33,9 +34,9 @@ public class AuthChallengeSerializerTest { authChallenge.setValue(new ByteArray("foo")); assertEquals( - "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + + new SafeByteArray("<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + "Zm9v" + - "</challenge>", testling.serialize(authChallenge)); + "</challenge>"), testling.serialize(authChallenge)); } @Test @@ -44,7 +45,7 @@ public class AuthChallengeSerializerTest { AuthChallenge authChallenge = new AuthChallenge(); assertEquals( - "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"></challenge>", testling.serialize(authChallenge)); + new SafeByteArray("<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"></challenge>"), testling.serialize(authChallenge)); } @Test @@ -54,8 +55,8 @@ public class AuthChallengeSerializerTest { authChallenge.setValue(new ByteArray()); assertEquals( - "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + + new SafeByteArray("<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + "=" + - "</challenge>", testling.serialize(authChallenge)); + "</challenge>"), testling.serialize(authChallenge)); } }
\ No newline at end of file diff --git a/test/com/isode/stroke/serializer/AuthRequestSerializerTest.java b/test/com/isode/stroke/serializer/AuthRequestSerializerTest.java index eae4354..69d4442 100644 --- a/test/com/isode/stroke/serializer/AuthRequestSerializerTest.java +++ b/test/com/isode/stroke/serializer/AuthRequestSerializerTest.java @@ -16,6 +16,7 @@ import org.junit.Test; import com.isode.stroke.serializer.AuthRequestSerializer; import com.isode.stroke.elements.AuthRequest; import com.isode.stroke.base.ByteArray; +import com.isode.stroke.base.SafeByteArray; public class AuthRequestSerializerTest { @@ -30,12 +31,12 @@ public class AuthRequestSerializerTest { public void testSerialize() { AuthRequestSerializer testling = new AuthRequestSerializer(); AuthRequest authRequest = new AuthRequest("PLAIN"); - authRequest.setMessage(new ByteArray("foo")); + authRequest.setMessage(new SafeByteArray("foo")); assertEquals( - "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">" + + new SafeByteArray("<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">" + "Zm9v" + - "</auth>", testling.serialize(authRequest)); + "</auth>"), testling.serialize(authRequest)); } @Test @@ -44,19 +45,19 @@ public class AuthRequestSerializerTest { AuthRequest authRequest = new AuthRequest("PLAIN"); assertEquals( - "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">" + - "</auth>", testling.serialize(authRequest)); + new SafeByteArray("<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">" + + "</auth>"), testling.serialize(authRequest)); } @Test public void testSerialize_EmptyMessage() { AuthRequestSerializer testling = new AuthRequestSerializer(); AuthRequest authRequest = new AuthRequest("PLAIN"); - authRequest.setMessage(new ByteArray()); + authRequest.setMessage(new SafeByteArray()); assertEquals( - "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">" + + new SafeByteArray("<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">" + "=" + - "</auth>", testling.serialize(authRequest)); + "</auth>"), testling.serialize(authRequest)); } }
\ No newline at end of file diff --git a/test/com/isode/stroke/serializer/AuthResponseSerializerTest.java b/test/com/isode/stroke/serializer/AuthResponseSerializerTest.java index 9b0fe71..a80dc81 100644 --- a/test/com/isode/stroke/serializer/AuthResponseSerializerTest.java +++ b/test/com/isode/stroke/serializer/AuthResponseSerializerTest.java @@ -16,6 +16,7 @@ import org.junit.Test; import com.isode.stroke.serializer.AuthResponseSerializer; import com.isode.stroke.elements.AuthResponse; import com.isode.stroke.base.ByteArray; +import com.isode.stroke.base.SafeByteArray; public class AuthResponseSerializerTest { @@ -30,12 +31,12 @@ public class AuthResponseSerializerTest { public void testSerialize() { AuthResponseSerializer testling = new AuthResponseSerializer(); AuthResponse authResponse = new AuthResponse(); - authResponse.setValue(new ByteArray("foo")); + authResponse.setValue(new SafeByteArray("foo")); assertEquals( - "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + + new SafeByteArray("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + "Zm9v" + - "</response>", testling.serialize(authResponse)); + "</response>"), testling.serialize(authResponse)); } @Test @@ -44,19 +45,19 @@ public class AuthResponseSerializerTest { AuthResponse authResponse = new AuthResponse(); assertEquals( - "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + - "</response>", testling.serialize(authResponse)); + new SafeByteArray("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + + "</response>"), testling.serialize(authResponse)); } @Test public void testSerialize_EmptyMessage() { AuthResponseSerializer testling = new AuthResponseSerializer(); AuthResponse authResponse = new AuthResponse(); - authResponse.setValue(new ByteArray()); + authResponse.setValue(new SafeByteArray()); assertEquals( - "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + + new SafeByteArray("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + "" + - "</response>", testling.serialize(authResponse)); + "</response>"), testling.serialize(authResponse)); } }
\ No newline at end of file diff --git a/test/com/isode/stroke/serializer/AuthSuccessSerializerTest.java b/test/com/isode/stroke/serializer/AuthSuccessSerializerTest.java index ee9b595..198080b 100644 --- a/test/com/isode/stroke/serializer/AuthSuccessSerializerTest.java +++ b/test/com/isode/stroke/serializer/AuthSuccessSerializerTest.java @@ -16,6 +16,7 @@ import org.junit.Test; import com.isode.stroke.serializer.AuthSuccessSerializer; import com.isode.stroke.elements.AuthSuccess; import com.isode.stroke.base.ByteArray; +import com.isode.stroke.base.SafeByteArray; public class AuthSuccessSerializerTest { @@ -33,9 +34,9 @@ public class AuthSuccessSerializerTest { authSuccess.setValue(new ByteArray("foo")); assertEquals( - "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + + new SafeByteArray("<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + "Zm9v" + - "</success>", testling.serialize(authSuccess)); + "</success>"), testling.serialize(authSuccess)); } @Test @@ -44,8 +45,8 @@ public class AuthSuccessSerializerTest { AuthSuccess authSuccess = new AuthSuccess(); assertEquals( - "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + - "</success>", testling.serialize(authSuccess)); + new SafeByteArray("<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + + "</success>"), testling.serialize(authSuccess)); } @Test @@ -55,8 +56,8 @@ public class AuthSuccessSerializerTest { authSuccess.setValue(new ByteArray()); assertEquals( - "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + + new SafeByteArray("<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + "=" + - "</success>", testling.serialize(authSuccess)); + "</success>"), testling.serialize(authSuccess)); } }
\ No newline at end of file diff --git a/test/com/isode/stroke/serializer/StreamFeaturesSerializerTest.java b/test/com/isode/stroke/serializer/StreamFeaturesSerializerTest.java index 67d9bb0..76696b5 100644 --- a/test/com/isode/stroke/serializer/StreamFeaturesSerializerTest.java +++ b/test/com/isode/stroke/serializer/StreamFeaturesSerializerTest.java @@ -15,6 +15,7 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import com.isode.stroke.serializer.StreamFeaturesSerializer; import com.isode.stroke.elements.StreamFeatures; +import com.isode.stroke.base.SafeByteArray; public class StreamFeaturesSerializerTest { @@ -40,7 +41,7 @@ public class StreamFeaturesSerializerTest { streamFeatures.setHasRosterVersioning(); assertEquals( - "<stream:features>" + new SafeByteArray("<stream:features>" + "<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>" + "<compression xmlns=\"http://jabber.org/features/compress\">" + "<method>zlib</method>" @@ -54,6 +55,6 @@ public class StreamFeaturesSerializerTest { + "<session xmlns=\"urn:ietf:params:xml:ns:xmpp-session\"/>" + "<sm xmlns=\"urn:xmpp:sm:2\"/>" + "<ver xmlns=\"urn:xmpp:features:rosterver\"/>" - + "</stream:features>", testling.serialize(streamFeatures)); + + "</stream:features>"), testling.serialize(streamFeatures)); } }
\ No newline at end of file |