diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-08-26 20:21:52 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-08-26 20:21:52 (GMT) |
commit | 9a80a4b67f8fd86b3a2f5bccef3c0cd59dd83d75 (patch) | |
tree | a7304cd58652380926c2e1ebf225f7a9beed229b /Swiften/Queries/UnitTest | |
parent | 946a94332761a058c6842e543d7e625bc5e9c9e1 (diff) | |
download | swift-9a80a4b67f8fd86b3a2f5bccef3c0cd59dd83d75.zip swift-9a80a4b67f8fd86b3a2f5bccef3c0cd59dd83d75.tar.bz2 |
Don't consider Get and Set requests as Response results.
Release-Notes: Fixed a problem where we would treat incoming queries with IDs clashing with pending requests as errors.
Diffstat (limited to 'Swiften/Queries/UnitTest')
-rw-r--r-- | Swiften/Queries/UnitTest/RequestTest.cpp | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/Swiften/Queries/UnitTest/RequestTest.cpp b/Swiften/Queries/UnitTest/RequestTest.cpp index 34d07c9..46eb6fd 100644 --- a/Swiften/Queries/UnitTest/RequestTest.cpp +++ b/Swiften/Queries/UnitTest/RequestTest.cpp @@ -29,6 +29,8 @@ class RequestTest : public CppUnit::TestFixture { CPPUNIT_TEST(testHandleIQ_BeforeSend); CPPUNIT_TEST(testHandleIQ_DifferentPayload); CPPUNIT_TEST(testHandleIQ_RawXMLPayload); + CPPUNIT_TEST(testHandleIQ_GetWithSameID); + CPPUNIT_TEST(testHandleIQ_SetWithSameID); CPPUNIT_TEST_SUITE_END(); public: @@ -122,14 +124,14 @@ class RequestTest : public CppUnit::TestFixture { testling.send(); boost::shared_ptr<IQ> error = createError("test-id"); - boost::shared_ptr<Payload> errorPayload = boost::shared_ptr<ErrorPayload>(new ErrorPayload(ErrorPayload::FeatureNotImplemented)); + boost::shared_ptr<Payload> errorPayload = boost::shared_ptr<ErrorPayload>(new ErrorPayload(ErrorPayload::InternalServerError)); error->addPayload(errorPayload); channel_->onIQReceived(error); CPPUNIT_ASSERT_EQUAL(0, responsesReceived_); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(receivedErrors.size())); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size())); - CPPUNIT_ASSERT_EQUAL(ErrorPayload::FeatureNotImplemented, receivedErrors[0].getCondition()); + CPPUNIT_ASSERT_EQUAL(ErrorPayload::InternalServerError, receivedErrors[0].getCondition()); } void testHandleIQ_ErrorWithoutPayload() { @@ -182,6 +184,35 @@ class RequestTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size())); } + void testHandleIQ_GetWithSameID() { + MyRequest testling(IQ::Get, JID("foo@bar.com/baz"), payload_, router_); + testling.onResponse.connect(boost::bind(&RequestTest::handleResponse, this, _1, _2)); + testling.send(); + + boost::shared_ptr<IQ> response = createResponse("test-id"); + response->setType(IQ::Get); + channel_->onIQReceived(response); + + CPPUNIT_ASSERT_EQUAL(0, responsesReceived_); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(receivedErrors.size())); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(channel_->iqs_.size())); + } + + void testHandleIQ_SetWithSameID() { + MyRequest testling(IQ::Get, JID("foo@bar.com/baz"), payload_, router_); + testling.onResponse.connect(boost::bind(&RequestTest::handleResponse, this, _1, _2)); + testling.send(); + + boost::shared_ptr<IQ> response = createResponse("test-id"); + response->setType(IQ::Set); + channel_->onIQReceived(response); + + CPPUNIT_ASSERT_EQUAL(0, responsesReceived_); + CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(receivedErrors.size())); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(channel_->iqs_.size())); + } + + private: void handleResponse(boost::shared_ptr<Payload> p, ErrorPayload::ref e) { if (e) { |