summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Queries')
-rw-r--r--Swiften/Queries/Request.cpp2
-rw-r--r--Swiften/Queries/UnitTest/RequestTest.cpp14
2 files changed, 15 insertions, 1 deletions
diff --git a/Swiften/Queries/Request.cpp b/Swiften/Queries/Request.cpp
index 0ffae26..7832c65 100644
--- a/Swiften/Queries/Request.cpp
+++ b/Swiften/Queries/Request.cpp
@@ -80,7 +80,7 @@ bool Request::isAccountJID(const JID& jid) {
if (!router_->getJID().isValid()) {
return true;
}
- return jid.isValid() ? router_->getJID().equals(jid, JID::WithoutResource) : true;
+ return jid.isValid() ? router_->getJID().toBare().equals(jid, JID::WithResource) : true;
}
}
diff --git a/Swiften/Queries/UnitTest/RequestTest.cpp b/Swiften/Queries/UnitTest/RequestTest.cpp
index b3925dd..75e0a1d 100644
--- a/Swiften/Queries/UnitTest/RequestTest.cpp
+++ b/Swiften/Queries/UnitTest/RequestTest.cpp
@@ -33,6 +33,7 @@ class RequestTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testHandleIQ_SetWithSameID);
CPPUNIT_TEST(testHandleIQ_IncorrectSender);
CPPUNIT_TEST(testHandleIQ_IncorrectSenderForServerQuery);
+ CPPUNIT_TEST(testHandleIQ_IncorrectOtherResourceSenderForServerQuery);
CPPUNIT_TEST(testHandleIQ_ServerRespondsWithDomain);
CPPUNIT_TEST(testHandleIQ_ServerRespondsWithBareJID);
CPPUNIT_TEST(testHandleIQ_ServerRespondsWithoutFrom);
@@ -243,6 +244,19 @@ class RequestTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size()));
}
+ void testHandleIQ_IncorrectOtherResourceSenderForServerQuery() {
+ MyRequest testling(IQ::Get, JID(), payload_, router_);
+ router_->setJID("alice@wonderland.lit/TeaParty");
+ testling.onResponse.connect(boost::bind(&RequestTest::handleResponse, this, _1, _2));
+ testling.send();
+
+ channel_->onIQReceived(createResponse(JID("alice@wonderland.lit/RabbitHole"), "test-id"));
+
+ CPPUNIT_ASSERT_EQUAL(0, responsesReceived_);
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(receivedErrors.size()));
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size()));
+ }
+
void testHandleIQ_ServerRespondsWithDomain() {
MyRequest testling(IQ::Get, JID(), payload_, router_);
router_->setJID("alice@wonderland.lit/TeaParty");