summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-08-28 13:47:15 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-08-28 13:47:15 (GMT)
commit7d406bb0c9b36921e5e9fffd3f4e62982c0956ca (patch)
tree7b978a66ba5b40e737068e64c0543fd86ca639b0 /Swiften
parent4d9d6d7148c8ff271d67196874c15d4b7ccef869 (diff)
parent17c78efa9452fc0619cbd73e124b66bc1f89fa5e (diff)
downloadswift-contrib-7d406bb0c9b36921e5e9fffd3f4e62982c0956ca.zip
swift-contrib-7d406bb0c9b36921e5e9fffd3f4e62982c0956ca.tar.bz2
Merge branch 'swift-1.x'
* swift-1.x: Check whether disco#info responses are null.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Disco/CapsManager.cpp4
-rw-r--r--Swiften/Disco/UnitTest/CapsManagerTest.cpp13
2 files changed, 15 insertions, 2 deletions
diff --git a/Swiften/Disco/CapsManager.cpp b/Swiften/Disco/CapsManager.cpp
index a24d88d..66eb47e 100644
--- a/Swiften/Disco/CapsManager.cpp
+++ b/Swiften/Disco/CapsManager.cpp
@@ -51,8 +51,8 @@ void CapsManager::handleStanzaChannelAvailableChanged(bool available) {
void CapsManager::handleDiscoInfoReceived(const JID& from, const std::string& hash, DiscoInfo::ref discoInfo, ErrorPayload::ref error) {
requestedDiscoInfos.erase(hash);
- if (error || CapsInfoGenerator("").generateCapsInfo(*discoInfo.get()).getVersion() != hash) {
- if (warnOnInvalidHash && !error) {
+ if (error || !discoInfo || CapsInfoGenerator("").generateCapsInfo(*discoInfo.get()).getVersion() != hash) {
+ if (warnOnInvalidHash && !error && discoInfo) {
std::cerr << "Warning: Caps from " << from.toString() << " do not verify" << std::endl;
}
failingCaps.insert(std::make_pair(from, hash));
diff --git a/Swiften/Disco/UnitTest/CapsManagerTest.cpp b/Swiften/Disco/UnitTest/CapsManagerTest.cpp
index 699e96f..52b4bf1 100644
--- a/Swiften/Disco/UnitTest/CapsManagerTest.cpp
+++ b/Swiften/Disco/UnitTest/CapsManagerTest.cpp
@@ -32,6 +32,7 @@ class CapsManagerTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testReceiveSuccesfulDiscoStoresCaps);
CPPUNIT_TEST(testReceiveIncorrectVerificationDiscoDoesNotStoreCaps);
CPPUNIT_TEST(testReceiveFailingDiscoFallsBack);
+ CPPUNIT_TEST(testReceiveNoDiscoFallsBack);
CPPUNIT_TEST(testReceiveFailingFallbackDiscoFallsBack);
CPPUNIT_TEST(testReceiveSameHashFromFailingUserAfterReconnectRequestsDisco);
CPPUNIT_TEST(testReconnectResetsFallback);
@@ -183,6 +184,18 @@ class CapsManagerTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL("http://node2.im#" + capsInfo1alt->getVersion(), discoInfo->getNode());
}
+ void testReceiveNoDiscoFallsBack() {
+ std::auto_ptr<CapsManager> testling = createManager();
+ sendPresenceWithCaps(user1, capsInfo1);
+ sendPresenceWithCaps(user2, capsInfo1alt);
+ stanzaChannel->onIQReceived(IQ::createResult(JID("baz@fum.com/dum"), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID(), boost::shared_ptr<DiscoInfo>()));
+
+ CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<DiscoInfo>(1, user2, IQ::Get));
+ boost::shared_ptr<DiscoInfo> discoInfo(stanzaChannel->sentStanzas[1]->getPayload<DiscoInfo>());
+ CPPUNIT_ASSERT(discoInfo);
+ CPPUNIT_ASSERT_EQUAL("http://node2.im#" + capsInfo1alt->getVersion(), discoInfo->getNode());
+ }
+
void testReceiveFailingFallbackDiscoFallsBack() {
boost::shared_ptr<CapsManager> testling = createManager();
sendPresenceWithCaps(user1, capsInfo1);