summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-13 19:01:20 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-13 19:01:20 (GMT)
commit92614cf44bc98c3aae240a8089452fb950af5c7e (patch)
tree20b25f0bfcc96ddde992eaa8b0640ca68dfd0280 /Swiften/SASL/UnitTest
parent6ca206b0d0645e50a8a2c59ebd134f9c0f164b9b (diff)
downloadswift-92614cf44bc98c3aae240a8089452fb950af5c7e.zip
swift-92614cf44bc98c3aae240a8089452fb950af5c7e.tar.bz2
Added PLAIN SASL message parsing.
Diffstat (limited to 'Swiften/SASL/UnitTest')
-rw-r--r--Swiften/SASL/UnitTest/PLAINMessageTest.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/Swiften/SASL/UnitTest/PLAINMessageTest.cpp b/Swiften/SASL/UnitTest/PLAINMessageTest.cpp
index da9287a..6493bd5 100644
--- a/Swiften/SASL/UnitTest/PLAINMessageTest.cpp
+++ b/Swiften/SASL/UnitTest/PLAINMessageTest.cpp
@@ -8,22 +8,54 @@ using namespace Swift;
class PLAINMessageTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(PLAINMessageTest);
+ CPPUNIT_TEST(testGetValue_WithoutAuthzID);
+ CPPUNIT_TEST(testGetValue_WithAuthzID);
CPPUNIT_TEST(testConstructor_WithoutAuthzID);
CPPUNIT_TEST(testConstructor_WithAuthzID);
+ CPPUNIT_TEST(testConstructor_NoAuthcid);
+ CPPUNIT_TEST(testConstructor_NoPassword);
CPPUNIT_TEST_SUITE_END();
public:
PLAINMessageTest() {}
- void testConstructor_WithoutAuthzID() {
+ void testGetValue_WithoutAuthzID() {
PLAINMessage message("user", "pass");
CPPUNIT_ASSERT_EQUAL(message.getValue(), ByteArray("\0user\0pass", 10));
}
- void testConstructor_WithAuthzID() {
+ void testGetValue_WithAuthzID() {
PLAINMessage message("user", "pass", "authz");
CPPUNIT_ASSERT_EQUAL(message.getValue(), ByteArray("authz\0user\0pass", 15));
}
+
+ void testConstructor_WithoutAuthzID() {
+ PLAINMessage message(ByteArray("\0user\0pass", 10));
+
+ CPPUNIT_ASSERT_EQUAL(String(""), message.getAuthorizationID());
+ CPPUNIT_ASSERT_EQUAL(String("user"), message.getAuthenticationID());
+ CPPUNIT_ASSERT_EQUAL(String("pass"), message.getPassword());
+ }
+
+ void testConstructor_WithAuthzID() {
+ PLAINMessage message(ByteArray("authz\0user\0pass", 15));
+
+ CPPUNIT_ASSERT_EQUAL(String("authz"), message.getAuthorizationID());
+ CPPUNIT_ASSERT_EQUAL(String("user"), message.getAuthenticationID());
+ CPPUNIT_ASSERT_EQUAL(String("pass"), message.getPassword());
+ }
+
+ void testConstructor_NoAuthcid() {
+ PLAINMessage message(ByteArray("authzid", 7));
+
+ CPPUNIT_ASSERT_EQUAL(String(""), message.getAuthenticationID());
+ }
+
+ void testConstructor_NoPassword() {
+ PLAINMessage message(ByteArray("authzid\0authcid", 15));
+
+ CPPUNIT_ASSERT_EQUAL(String(""), message.getAuthenticationID());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(PLAINMessageTest);