diff options
Diffstat (limited to 'Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp')
-rw-r--r-- | Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp b/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp index d664f14..841f580 100644 --- a/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp +++ b/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp @@ -1,7 +1,7 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ #include <cppunit/extensions/HelperMacros.h> @@ -12,44 +12,44 @@ using namespace Swift; class DIGESTMD5PropertiesTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(DIGESTMD5PropertiesTest); - CPPUNIT_TEST(testParse); - CPPUNIT_TEST(testSerialize); - CPPUNIT_TEST_SUITE_END(); - - public: - void testParse() { - DIGESTMD5Properties properties = DIGESTMD5Properties::parse(createByteArray( - "realm=\"myrealm1\",realm=\"myrealm2\",nonce=\"mynonce\"," - "algorithm=md5-sess,charset=utf-8")); - - CPPUNIT_ASSERT(properties.getValue("realm")); - CPPUNIT_ASSERT_EQUAL(std::string("myrealm1"), *properties.getValue("realm")); - CPPUNIT_ASSERT(properties.getValue("nonce")); - CPPUNIT_ASSERT_EQUAL(std::string("mynonce"), *properties.getValue("nonce")); - CPPUNIT_ASSERT(properties.getValue("algorithm")); - CPPUNIT_ASSERT_EQUAL(std::string("md5-sess"), *properties.getValue("algorithm")); - CPPUNIT_ASSERT(properties.getValue("charset")); - CPPUNIT_ASSERT_EQUAL(std::string("utf-8"), *properties.getValue("charset")); - } - - void testSerialize() { - DIGESTMD5Properties properties; - 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(createByteArray("authzid=\"myauthzid\",charset=utf-8,cnonce=\"mycnonce\",digest-uri=\"mydigesturi\",nc=1,nonce=\"mynonce\",qop=auth,realm=\"myrealm\",response=myresponse,username=\"myuser\"")); - CPPUNIT_ASSERT_EQUAL(byteArrayToString(expected), byteArrayToString(result)); - } + CPPUNIT_TEST_SUITE(DIGESTMD5PropertiesTest); + CPPUNIT_TEST(testParse); + CPPUNIT_TEST(testSerialize); + CPPUNIT_TEST_SUITE_END(); + + public: + void testParse() { + DIGESTMD5Properties properties = DIGESTMD5Properties::parse(createByteArray( + "realm=\"myrealm1\",realm=\"myrealm2\",nonce=\"mynonce\"," + "algorithm=md5-sess,charset=utf-8")); + + CPPUNIT_ASSERT(properties.getValue("realm")); + CPPUNIT_ASSERT_EQUAL(std::string("myrealm1"), *properties.getValue("realm")); + CPPUNIT_ASSERT(properties.getValue("nonce")); + CPPUNIT_ASSERT_EQUAL(std::string("mynonce"), *properties.getValue("nonce")); + CPPUNIT_ASSERT(properties.getValue("algorithm")); + CPPUNIT_ASSERT_EQUAL(std::string("md5-sess"), *properties.getValue("algorithm")); + CPPUNIT_ASSERT(properties.getValue("charset")); + CPPUNIT_ASSERT_EQUAL(std::string("utf-8"), *properties.getValue("charset")); + } + + void testSerialize() { + DIGESTMD5Properties properties; + 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(createByteArray("authzid=\"myauthzid\",charset=utf-8,cnonce=\"mycnonce\",digest-uri=\"mydigesturi\",nc=1,nonce=\"mynonce\",qop=auth,realm=\"myrealm\",response=myresponse,username=\"myuser\"")); + CPPUNIT_ASSERT_EQUAL(byteArrayToString(expected), byteArrayToString(result)); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(DIGESTMD5PropertiesTest); |