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/Serializer/UnitTest
parent8406d818fcb2a511b1e4264a10fd9069ec020d72 (diff)
downloadswift-c3fa606c7ac060c4929e7082e0e24531b093112f.zip
swift-c3fa606c7ac060c4929e7082e0e24531b093112f.tar.bz2
Distinguish an empty SASL message from no SASL message.
Diffstat (limited to 'Swiften/Serializer/UnitTest')
-rw-r--r--Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp55
-rw-r--r--Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp55
-rw-r--r--Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp55
-rw-r--r--Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp55
4 files changed, 220 insertions, 0 deletions
diff --git a/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp
new file mode 100644
index 0000000..dc828e0
--- /dev/null
+++ b/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include "Swiften/Serializer/AuthChallengeSerializer.h"
+#include "Swiften/Elements/AuthChallenge.h"
+
+using namespace Swift;
+
+class AuthChallengeSerializerTest : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(AuthChallengeSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_NoMessage);
+ CPPUNIT_TEST(testSerialize_EmptyMessage);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize() {
+ AuthChallengeSerializer testling;
+ boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge());
+ authChallenge->setValue("foo");
+
+ CPPUNIT_ASSERT_EQUAL(String(
+ "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "Zm9v"
+ "</challenge>"), testling.serialize(authChallenge));
+ }
+
+ void testSerialize_NoMessage() {
+ AuthChallengeSerializer testling;
+ boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge());
+
+ CPPUNIT_ASSERT_EQUAL(String(
+ "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "</challenge>"), testling.serialize(authChallenge));
+ }
+
+ void testSerialize_EmptyMessage() {
+ AuthChallengeSerializer testling;
+ boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge());
+ authChallenge->setValue(ByteArray());
+
+ CPPUNIT_ASSERT_EQUAL(String(
+ "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "="
+ "</challenge>"), testling.serialize(authChallenge));
+ }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(AuthChallengeSerializerTest);
diff --git a/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp
new file mode 100644
index 0000000..f63db90
--- /dev/null
+++ b/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include "Swiften/Serializer/AuthRequestSerializer.h"
+#include "Swiften/Elements/AuthRequest.h"
+
+using namespace Swift;
+
+class AuthRequestSerializerTest : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(AuthRequestSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_NoMessage);
+ CPPUNIT_TEST(testSerialize_EmptyMessage);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize() {
+ AuthRequestSerializer testling;
+ boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN"));
+ authRequest->setMessage("foo");
+
+ CPPUNIT_ASSERT_EQUAL(String(
+ "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">"
+ "Zm9v"
+ "</auth>"), testling.serialize(authRequest));
+ }
+
+ void testSerialize_NoMessage() {
+ AuthRequestSerializer testling;
+ boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN"));
+
+ CPPUNIT_ASSERT_EQUAL(String(
+ "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">"
+ "</auth>"), testling.serialize(authRequest));
+ }
+
+ void testSerialize_EmptyMessage() {
+ AuthRequestSerializer testling;
+ boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN"));
+ authRequest->setMessage(ByteArray());
+
+ CPPUNIT_ASSERT_EQUAL(String(
+ "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">"
+ "="
+ "</auth>"), testling.serialize(authRequest));
+ }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(AuthRequestSerializerTest);
diff --git a/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp
new file mode 100644
index 0000000..fabe834
--- /dev/null
+++ b/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include "Swiften/Serializer/AuthResponseSerializer.h"
+#include "Swiften/Elements/AuthResponse.h"
+
+using namespace Swift;
+
+class AuthResponseSerializerTest : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(AuthResponseSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_NoMessage);
+ CPPUNIT_TEST(testSerialize_EmptyMessage);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize() {
+ AuthResponseSerializer testling;
+ boost::shared_ptr<AuthResponse> authResponse(new AuthResponse());
+ authResponse->setValue("foo");
+
+ CPPUNIT_ASSERT_EQUAL(String(
+ "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "Zm9v"
+ "</response>"), testling.serialize(authResponse));
+ }
+
+ void testSerialize_NoMessage() {
+ AuthResponseSerializer testling;
+ boost::shared_ptr<AuthResponse> authResponse(new AuthResponse());
+
+ CPPUNIT_ASSERT_EQUAL(String(
+ "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "</response>"), testling.serialize(authResponse));
+ }
+
+ void testSerialize_EmptyMessage() {
+ AuthResponseSerializer testling;
+ boost::shared_ptr<AuthResponse> authResponse(new AuthResponse());
+ authResponse->setValue(ByteArray());
+
+ CPPUNIT_ASSERT_EQUAL(String(
+ "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "="
+ "</response>"), testling.serialize(authResponse));
+ }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(AuthResponseSerializerTest);
diff --git a/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp
new file mode 100644
index 0000000..a9b602f
--- /dev/null
+++ b/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include "Swiften/Serializer/AuthSuccessSerializer.h"
+#include "Swiften/Elements/AuthSuccess.h"
+
+using namespace Swift;
+
+class AuthSuccessSerializerTest : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(AuthSuccessSerializerTest);
+ CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_NoMessage);
+ CPPUNIT_TEST(testSerialize_EmptyMessage);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize() {
+ AuthSuccessSerializer testling;
+ boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess());
+ authSuccess->setValue("foo");
+
+ CPPUNIT_ASSERT_EQUAL(String(
+ "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "Zm9v"
+ "</success>"), testling.serialize(authSuccess));
+ }
+
+ void testSerialize_NoMessage() {
+ AuthSuccessSerializer testling;
+ boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess());
+
+ CPPUNIT_ASSERT_EQUAL(String(
+ "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "</success>"), testling.serialize(authSuccess));
+ }
+
+ void testSerialize_EmptyMessage() {
+ AuthSuccessSerializer testling;
+ boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess());
+ authSuccess->setValue(ByteArray());
+
+ CPPUNIT_ASSERT_EQUAL(String(
+ "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "="
+ "</success>"), testling.serialize(authSuccess));
+ }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(AuthSuccessSerializerTest);