diff options
Diffstat (limited to 'Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp')
| -rw-r--r-- | Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp | 40 |
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 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2010 Isode Limited. | 2 | * Copyright (c) 2010-2015 Isode Limited. |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * See the COPYING file for more information. | 4 | * See the COPYING file for more information. |
| 5 | */ | 5 | */ |
| @@ -16,6 +16,8 @@ class StreamFeaturesParserTest : public CppUnit::TestFixture { | |||
| 16 | CPPUNIT_TEST_SUITE(StreamFeaturesParserTest); | 16 | CPPUNIT_TEST_SUITE(StreamFeaturesParserTest); |
| 17 | CPPUNIT_TEST(testParse); | 17 | CPPUNIT_TEST(testParse); |
| 18 | CPPUNIT_TEST(testParse_Empty); | 18 | CPPUNIT_TEST(testParse_Empty); |
| 19 | CPPUNIT_TEST(testParse_AuthenticationHostname); | ||
| 20 | CPPUNIT_TEST(testParse_AuthenticationHostnameEmpty); | ||
| 19 | CPPUNIT_TEST_SUITE_END(); | 21 | CPPUNIT_TEST_SUITE_END(); |
| 20 | 22 | ||
| 21 | public: | 23 | public: |
| @@ -49,6 +51,7 @@ class StreamFeaturesParserTest : public CppUnit::TestFixture { | |||
| 49 | CPPUNIT_ASSERT(element->hasAuthenticationMechanisms()); | 51 | CPPUNIT_ASSERT(element->hasAuthenticationMechanisms()); |
| 50 | CPPUNIT_ASSERT(element->hasAuthenticationMechanism("DIGEST-MD5")); | 52 | CPPUNIT_ASSERT(element->hasAuthenticationMechanism("DIGEST-MD5")); |
| 51 | CPPUNIT_ASSERT(element->hasAuthenticationMechanism("PLAIN")); | 53 | CPPUNIT_ASSERT(element->hasAuthenticationMechanism("PLAIN")); |
| 54 | CPPUNIT_ASSERT(!element->getAuthenticationHostname()); | ||
| 52 | CPPUNIT_ASSERT(element->hasStreamManagement()); | 55 | CPPUNIT_ASSERT(element->hasStreamManagement()); |
| 53 | CPPUNIT_ASSERT(element->hasRosterVersioning()); | 56 | CPPUNIT_ASSERT(element->hasRosterVersioning()); |
| 54 | } | 57 | } |
| @@ -65,6 +68,41 @@ class StreamFeaturesParserTest : public CppUnit::TestFixture { | |||
| 65 | CPPUNIT_ASSERT(!element->hasResourceBind()); | 68 | CPPUNIT_ASSERT(!element->hasResourceBind()); |
| 66 | CPPUNIT_ASSERT(!element->hasAuthenticationMechanisms()); | 69 | CPPUNIT_ASSERT(!element->hasAuthenticationMechanisms()); |
| 67 | } | 70 | } |
| 71 | |||
| 72 | void testParse_AuthenticationHostname() { | ||
| 73 | StreamFeaturesParser testling; | ||
| 74 | ElementParserTester parser(&testling); | ||
| 75 | std::string hostname("auth42.us.example.com"); | ||
| 76 | |||
| 77 | CPPUNIT_ASSERT(parser.parse( | ||
| 78 | "<stream:features xmlns:stream='http://etherx.jabber.org/streams'>" | ||
| 79 | "<mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" | ||
| 80 | "<mechanism>GSSAPI</mechanism>" | ||
| 81 | "<hostname xmlns=\"urn:xmpp:domain-based-name:1\">auth42.us.example.com</hostname>" | ||
| 82 | "</mechanisms>" | ||
| 83 | "</stream:features>")); | ||
| 84 | |||
| 85 | StreamFeatures::ref element = boost::dynamic_pointer_cast<StreamFeatures>(testling.getElement()); | ||
| 86 | CPPUNIT_ASSERT(element->hasAuthenticationMechanism("GSSAPI")); | ||
| 87 | CPPUNIT_ASSERT_EQUAL(*element->getAuthenticationHostname(), hostname); | ||
| 88 | } | ||
| 89 | |||
| 90 | void testParse_AuthenticationHostnameEmpty() { | ||
| 91 | StreamFeaturesParser testling; | ||
| 92 | ElementParserTester parser(&testling); | ||
| 93 | |||
| 94 | CPPUNIT_ASSERT(parser.parse( | ||
| 95 | "<stream:features xmlns:stream='http://etherx.jabber.org/streams'>" | ||
| 96 | "<mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" | ||
| 97 | "<mechanism>GSSAPI</mechanism>" | ||
| 98 | "<hostname xmlns=\"urn:xmpp:domain-based-name:1\"></hostname>" | ||
| 99 | "</mechanisms>" | ||
| 100 | "</stream:features>")); | ||
| 101 | |||
| 102 | StreamFeatures::ref element = boost::dynamic_pointer_cast<StreamFeatures>(testling.getElement()); | ||
| 103 | CPPUNIT_ASSERT(element->hasAuthenticationMechanism("GSSAPI")); | ||
| 104 | CPPUNIT_ASSERT(element->getAuthenticationHostname()->empty()); | ||
| 105 | } | ||
| 68 | }; | 106 | }; |
| 69 | 107 | ||
| 70 | CPPUNIT_TEST_SUITE_REGISTRATION(StreamFeaturesParserTest); | 108 | CPPUNIT_TEST_SUITE_REGISTRATION(StreamFeaturesParserTest); |
Swift