summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMili Verma <mili.verma@isode.com>2015-06-23 09:08:56 (GMT)
committerKevin Smith <kevin.smith@isode.com>2015-06-29 14:51:46 (GMT)
commitea41bd07a0e014c12cce144b421abac9f21d1269 (patch)
treef6c5b44863d8cb7949bfe5ce29da90f07878efe9 /Swiften/Parser/UnitTest
parent595fdfa75d4757d5654bf3189c23c85a66ec6836 (diff)
downloadswift-ea41bd07a0e014c12cce144b421abac9f21d1269.zip
swift-ea41bd07a0e014c12cce144b421abac9f21d1269.tar.bz2
Parse hostname for xep-0233
Test-information: Verified with M-Link. Unit tests pass. Change-Id: Ic675c8d7cd70e01be61c51c0280e1d7208b364ba
Diffstat (limited to 'Swiften/Parser/UnitTest')
-rw-r--r--Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp b/Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp
index 8dd3a22..f6c9336 100644
--- a/Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp
+++ b/Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -16,6 +16,8 @@ class StreamFeaturesParserTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(StreamFeaturesParserTest);
CPPUNIT_TEST(testParse);
CPPUNIT_TEST(testParse_Empty);
+ CPPUNIT_TEST(testParse_AuthenticationHostname);
+ CPPUNIT_TEST(testParse_AuthenticationHostnameEmpty);
CPPUNIT_TEST_SUITE_END();
public:
@@ -49,6 +51,7 @@ class StreamFeaturesParserTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT(element->hasAuthenticationMechanisms());
CPPUNIT_ASSERT(element->hasAuthenticationMechanism("DIGEST-MD5"));
CPPUNIT_ASSERT(element->hasAuthenticationMechanism("PLAIN"));
+ CPPUNIT_ASSERT(!element->getAuthenticationHostname());
CPPUNIT_ASSERT(element->hasStreamManagement());
CPPUNIT_ASSERT(element->hasRosterVersioning());
}
@@ -65,6 +68,41 @@ class StreamFeaturesParserTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT(!element->hasResourceBind());
CPPUNIT_ASSERT(!element->hasAuthenticationMechanisms());
}
+
+ void testParse_AuthenticationHostname() {
+ StreamFeaturesParser testling;
+ ElementParserTester parser(&testling);
+ std::string hostname("auth42.us.example.com");
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<stream:features xmlns:stream='http://etherx.jabber.org/streams'>"
+ "<mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "<mechanism>GSSAPI</mechanism>"
+ "<hostname xmlns=\"urn:xmpp:domain-based-name:1\">auth42.us.example.com</hostname>"
+ "</mechanisms>"
+ "</stream:features>"));
+
+ StreamFeatures::ref element = boost::dynamic_pointer_cast<StreamFeatures>(testling.getElement());
+ CPPUNIT_ASSERT(element->hasAuthenticationMechanism("GSSAPI"));
+ CPPUNIT_ASSERT_EQUAL(*element->getAuthenticationHostname(), hostname);
+ }
+
+ void testParse_AuthenticationHostnameEmpty() {
+ StreamFeaturesParser testling;
+ ElementParserTester parser(&testling);
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<stream:features xmlns:stream='http://etherx.jabber.org/streams'>"
+ "<mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "<mechanism>GSSAPI</mechanism>"
+ "<hostname xmlns=\"urn:xmpp:domain-based-name:1\"></hostname>"
+ "</mechanisms>"
+ "</stream:features>"));
+
+ StreamFeatures::ref element = boost::dynamic_pointer_cast<StreamFeatures>(testling.getElement());
+ CPPUNIT_ASSERT(element->hasAuthenticationMechanism("GSSAPI"));
+ CPPUNIT_ASSERT(element->getAuthenticationHostname()->empty());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(StreamFeaturesParserTest);