Answer disco#info request with http://jabber.org/protocol/commands node
This commit is contained in:
parent
7142ccb570
commit
69023fc025
2 changed files with 23 additions and 0 deletions
|
@ -110,6 +110,12 @@ bool DiscoInfoResponder::handleGetRequest(const Swift::JID& from, const Swift::J
|
|||
res->setNode(info->getNode());
|
||||
sendResponse(from, to, id, res);
|
||||
}
|
||||
else if (info->getNode() == "http://jabber.org/protocol/commands") {
|
||||
boost::shared_ptr<DiscoInfo> res(new DiscoInfo());
|
||||
res->addIdentity(DiscoInfo::Identity("Commands", "automation", "command-list"));
|
||||
res->setNode(info->getNode());
|
||||
sendResponse(from, to, id, res);
|
||||
}
|
||||
else {
|
||||
if (!info->getNode().empty()) {
|
||||
sendError(from, id, ErrorPayload::ItemNotFound, ErrorPayload::Cancel);
|
||||
|
|
|
@ -27,6 +27,7 @@ class SettingsAdHocCommandTest : public CPPUNIT_NS :: TestFixture, public BasicT
|
|||
CPPUNIT_TEST_SUITE(SettingsAdHocCommandTest);
|
||||
CPPUNIT_TEST(getItems);
|
||||
CPPUNIT_TEST(getInfo);
|
||||
CPPUNIT_TEST(getInfoBare);
|
||||
CPPUNIT_TEST(execute);
|
||||
CPPUNIT_TEST(executeBadSessionID);
|
||||
CPPUNIT_TEST(executeNotRegistered);
|
||||
|
@ -87,6 +88,22 @@ class SettingsAdHocCommandTest : public CPPUNIT_NS :: TestFixture, public BasicT
|
|||
CPPUNIT_ASSERT_EQUAL(std::string("command-node"), getStanza(received[0])->getPayload<Swift::DiscoInfo>()->getIdentities()[0].getType());
|
||||
}
|
||||
|
||||
void getInfoBare() {
|
||||
boost::shared_ptr<Swift::DiscoInfo> payload(new Swift::DiscoInfo());
|
||||
payload->setNode("http://jabber.org/protocol/commands");
|
||||
boost::shared_ptr<Swift::IQ> iq = Swift::IQ::createRequest(Swift::IQ::Get, Swift::JID("localhost"), "id", payload);
|
||||
iq->setFrom("user@localhost");
|
||||
injectIQ(iq);
|
||||
loop->processEvents();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, (int) received.size());
|
||||
CPPUNIT_ASSERT(dynamic_cast<Swift::IQ *>(getStanza(received[0])));
|
||||
CPPUNIT_ASSERT_EQUAL(Swift::IQ::Result, dynamic_cast<Swift::IQ *>(getStanza(received[0]))->getType());
|
||||
CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::DiscoInfo>());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("automation"), getStanza(received[0])->getPayload<Swift::DiscoInfo>()->getIdentities()[0].getCategory());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("command-list"), getStanza(received[0])->getPayload<Swift::DiscoInfo>()->getIdentities()[0].getType());
|
||||
}
|
||||
|
||||
void executeNotRegistered() {
|
||||
boost::shared_ptr<Swift::Command> payload(new Swift::Command("settings"));
|
||||
boost::shared_ptr<Swift::IQ> iq = Swift::IQ::createRequest(Swift::IQ::Set, Swift::JID("localhost"), "id", payload);
|
||||
|
|
Loading…
Add table
Reference in a new issue