diff --git a/src/discoinforesponder.cpp b/src/discoinforesponder.cpp index 2ca5746c..91f6b494 100644 --- a/src/discoinforesponder.cpp +++ b/src/discoinforesponder.cpp @@ -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 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); diff --git a/src/tests/settingsadhoccommand.cpp b/src/tests/settingsadhoccommand.cpp index 3e9602be..1ad98518 100644 --- a/src/tests/settingsadhoccommand.cpp +++ b/src/tests/settingsadhoccommand.cpp @@ -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()->getIdentities()[0].getType()); } + void getInfoBare() { + boost::shared_ptr payload(new Swift::DiscoInfo()); + payload->setNode("http://jabber.org/protocol/commands"); + boost::shared_ptr 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(getStanza(received[0]))); + CPPUNIT_ASSERT_EQUAL(Swift::IQ::Result, dynamic_cast(getStanza(received[0]))->getType()); + CPPUNIT_ASSERT(getStanza(received[0])->getPayload()); + CPPUNIT_ASSERT_EQUAL(std::string("automation"), getStanza(received[0])->getPayload()->getIdentities()[0].getCategory()); + CPPUNIT_ASSERT_EQUAL(std::string("command-list"), getStanza(received[0])->getPayload()->getIdentities()[0].getType()); + } + void executeNotRegistered() { boost::shared_ptr payload(new Swift::Command("settings")); boost::shared_ptr iq = Swift::IQ::createRequest(Swift::IQ::Set, Swift::JID("localhost"), "id", payload);