summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-10-01 11:47:34 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-10-01 11:47:34 (GMT)
commit0f9c50e7bf71d000f8576bd112bdfa25de1397eb (patch)
tree0a2e19cfdaf595b90f907720cf07fc0db972d8bc /Swiften
parent6e345232b3a88e51f45149b039e1a27230a0bc2a (diff)
parent6a4a15088e7c97b3f6c1de179eee1defa2720bdb (diff)
downloadswift-0f9c50e7bf71d000f8576bd112bdfa25de1397eb.zip
swift-0f9c50e7bf71d000f8576bd112bdfa25de1397eb.tar.bz2
Merge branch 'swift-1.x'
* swift-1.x: Fixed roster sender check. Conflicts: Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Roster/RosterPushResponder.h9
-rw-r--r--Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp14
2 files changed, 21 insertions, 2 deletions
diff --git a/Swiften/Roster/RosterPushResponder.h b/Swiften/Roster/RosterPushResponder.h
index 7200b2d..74d300c 100644
--- a/Swiften/Roster/RosterPushResponder.h
+++ b/Swiften/Roster/RosterPushResponder.h
@@ -21,8 +21,13 @@ namespace Swift {
private:
virtual bool handleSetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr<RosterPayload> payload) {
- onRosterReceived(payload);
- sendResponse(from, id, boost::shared_ptr<RosterPayload>());
+ if (getIQRouter()->isAccountJID(from)) {
+ onRosterReceived(payload);
+ sendResponse(from, id, boost::shared_ptr<RosterPayload>());
+ }
+ else {
+ sendError(from, id, ErrorPayload::NotAuthorized, ErrorPayload::Cancel);
+ }
return true;
}
};
diff --git a/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp b/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp
index cb9f46f..f1bdf86 100644
--- a/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp
+++ b/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp
@@ -31,6 +31,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testGet_ResponseWithoutNewVersion);
CPPUNIT_TEST(testGet_ResponseWithNewVersion);
CPPUNIT_TEST(testAdd);
+ CPPUNIT_TEST(testAddFromNonAccount);
CPPUNIT_TEST(testModify);
CPPUNIT_TEST(testRemove);
CPPUNIT_TEST(testRemove_RosterStorageUpdated);
@@ -41,6 +42,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture {
void setUp() {
channel_ = new DummyStanzaChannel();
router_ = new IQRouter(channel_);
+ router_->setJID("me@bla.com");
xmppRoster_ = new XMPPRosterImpl();
handler_ = new XMPPRosterSignalHandler(xmppRoster_);
rosterStorage_ = new RosterMemoryStorage();
@@ -200,6 +202,18 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(rosterStorage_->getRoster()->getItem(jid3_)->getGroups().size()));
}
+ void testAddFromNonAccount() {
+ boost::shared_ptr<XMPPRosterController> testling(createController());
+
+ boost::shared_ptr<RosterPayload> payload(new RosterPayload());
+ payload->addItem(RosterItemPayload(jid1_, "Bob", RosterItemPayload::Both));
+ IQ::ref request = IQ::createRequest(IQ::Set, JID(), "eou", payload);
+ request->setFrom(jid2_);
+ channel_->onIQReceived(request);
+
+ CPPUNIT_ASSERT_EQUAL(None, handler_->getLastEvent());
+ }
+
void testModify() {
XMPPRosterController controller(router_, xmppRoster_, rosterStorage_);
boost::shared_ptr<RosterPayload> payload1(new RosterPayload());