diff --git a/tests/unit/sources/plugins/OrangeBusiness/urlManagerMock.cpp b/tests/unit/sources/plugins/OrangeBusiness/urlManagerMock.cpp index 8f17987ae7..b7dfaf8987 100644 --- a/tests/unit/sources/plugins/OrangeBusiness/urlManagerMock.cpp +++ b/tests/unit/sources/plugins/OrangeBusiness/urlManagerMock.cpp @@ -2,17 +2,16 @@ #include "urlManagerMock.h" urlManagerMock::urlManagerMock() - : RegisteredEquipments(shared::CDataContainer::make()), - DeviceInformation(shared::CDataContainer::make()), - DeviceMessages(shared::CDataContainer::make()) +: RegisteredEquipments(shared::CDataContainer::make()), + DeviceInformation(shared::CDataContainer::make()), + DeviceMessages(shared::CDataContainer::make()) { } -boost::shared_ptr urlManagerMock::getRegisteredEquipments( - const std::string& apikey, - const int page, - const bool activated, - int timeoutSeconds) +boost::shared_ptr urlManagerMock::getRegisteredEquipments(const std::string &apikey, + const int page, + const bool activated, + const boost::posix_time::time_duration& timeout) { return boost::make_shared(); } @@ -27,19 +26,17 @@ void urlManagerMock::addMessagesForEquipment(boost::shared_ptr urlManagerMock::getDeviceInformation( - const std::string& apikey, - const std::string& devEUI, - int timeoutSeconds) +boost::shared_ptr urlManagerMock::getDeviceInformation(const std::string &apikey, + const std::string &devEUI, + const boost::posix_time::time_duration& timeout) { return RegisteredEquipments; } -boost::shared_ptr urlManagerMock::listDeviceCommands( - const std::string& apikey, - const std::string& devEUI, - const int page, - int timeoutSeconds) +boost::shared_ptr urlManagerMock::listDeviceCommands(const std::string &apikey, + const std::string &devEUI, + const int page, + const boost::posix_time::time_duration& timeout) { return DeviceMessages; -} +} \ No newline at end of file diff --git a/tests/unit/sources/plugins/OrangeBusiness/urlManagerMock.h b/tests/unit/sources/plugins/OrangeBusiness/urlManagerMock.h index c17608f840..152497f8f9 100644 --- a/tests/unit/sources/plugins/OrangeBusiness/urlManagerMock.h +++ b/tests/unit/sources/plugins/OrangeBusiness/urlManagerMock.h @@ -20,40 +20,37 @@ class urlManagerMock : public IurlManager /// \brief get all equipments from the website /// \param[in] apikey the apiKey to access the web site /// \param[in] page the page of 20 equipments we want to read - /// \param[in] activated true, if we want to retrieve only activated equipments - /// \param[in] timeoutSeconds optional, the timeout (seconds) of the request + /// \param[in] activated true, if we want to retreive only activated equipments + /// \param[in] timeout optional, the timeout of the request /// \return the json response //-------------------------------------------------------------- - boost::shared_ptr getRegisteredEquipments( - const std::string& apikey, - int page, - bool activated, - int timeoutSeconds = shared::http::CHttpMethods::HttpRequestDefaultTimeoutSeconds) override; + boost::shared_ptr getRegisteredEquipments(const std::string &apikey, + const int page, + const bool activated, + const boost::posix_time::time_duration& timeout = shared::HttpRequestDefaultTimeout); //-------------------------------------------------------------- /// \brief get information from a specific device /// \param[in] apikey the apiKey to access the web site /// \param[in] devEUI the device unique ID - /// \param[in] timeoutSeconds optional, the timeout (seconds) of the request + /// \param[in] timeout optional, the timeout of the request /// \return the json response //-------------------------------------------------------------- - boost::shared_ptr getDeviceInformation( - const std::string& apikey, - const std::string& devEUI, - int timeoutSeconds = shared::http::CHttpMethods::HttpRequestDefaultTimeoutSeconds) override; + boost::shared_ptr getDeviceInformation(const std::string &apikey, + const std::string &devEUI, + const boost::posix_time::time_duration& timeout = shared::HttpRequestDefaultTimeout); //-------------------------------------------------------------- /// \brief list command information /// \param[in] apikey the apiKey to access the web site /// \param[in] devEUI the device unique ID - /// \param[in] timeoutSeconds optional, the timeout (seconds) of the request + /// \param[in] timeout optional, the timeout of the request /// \return the json response //-------------------------------------------------------------- - boost::shared_ptr listDeviceCommands( - const std::string& apikey, - const std::string& devEUI, - int page, - int timeoutSeconds = shared::http::CHttpMethods::HttpRequestDefaultTimeoutSeconds) override; + boost::shared_ptr listDeviceCommands(const std::string &apikey, + const std::string &devEUI, + const int page, + const boost::posix_time::time_duration& timeout = shared::HttpRequestDefaultTimeout); private: @@ -61,4 +58,4 @@ class urlManagerMock : public IurlManager boost::shared_ptr RegisteredEquipments; boost::shared_ptr DeviceInformation; boost::shared_ptr DeviceMessages; -}; +}; \ No newline at end of file diff --git a/tests/unit/sources/shared/event/TestEvent.cpp b/tests/unit/sources/shared/event/TestEvent.cpp index 4cb4c4e200..27e60ee0b6 100644 --- a/tests/unit/sources/shared/event/TestEvent.cpp +++ b/tests/unit/sources/shared/event/TestEvent.cpp @@ -267,7 +267,7 @@ BOOST_AUTO_TEST_CASE(EventWithBadData) BOOST_CHECK_EQUAL(evtHandler.waitForEvents(boost::date_time::min_date_time), idEvent); BOOST_CHECK(!evtHandler.isEventType()); - BOOST_REQUIRE_THROW(evtHandler.getEventData(), std::bad_cast); + BOOST_REQUIRE_THROW(evtHandler.getEventData(), shared::exception::CBadConversion); BOOST_CHECK(evtHandler.isEventType()); BOOST_REQUIRE_NO_THROW(evtHandler.getEventData()); @@ -279,7 +279,7 @@ BOOST_AUTO_TEST_CASE(EventWithBadData) BOOST_CHECK_EQUAL(evtHandler.waitForEvents(boost::date_time::min_date_time), idEvent); BOOST_CHECK(!evtHandler.isEventType()); - BOOST_REQUIRE_THROW(evtHandler.getEventData(), std::bad_cast); + BOOST_REQUIRE_THROW(evtHandler.getEventData(), shared::exception::CBadConversion); } //-------------------------------------------------------------- @@ -322,12 +322,12 @@ BOOST_AUTO_TEST_CASE(EventIdGetter) { shared::event::CEventHandler evtHandler; - BOOST_REQUIRE_THROW(evtHandler.getEventId(), std::runtime_error); + BOOST_REQUIRE_THROW(evtHandler.getEventId(), shared::exception::CNullReference); evtHandler.postEvent(idEvent); evtHandler.postEvent(idEvent + 1, CEventData(42, "Yadoms test")); - BOOST_REQUIRE_THROW(evtHandler.getEventId(), std::runtime_error); + BOOST_REQUIRE_THROW(evtHandler.getEventId(), shared::exception::CNullReference); BOOST_CHECK_EQUAL(evtHandler.waitForEvents(boost::date_time::min_date_time), idEvent); BOOST_CHECK_EQUAL(evtHandler.getEventId(), idEvent); @@ -337,7 +337,7 @@ BOOST_AUTO_TEST_CASE(EventIdGetter) BOOST_CHECK_EQUAL(evtHandler.getEventId(), idEvent + 1); // Can be called several times BOOST_CHECK_EQUAL(evtHandler.waitForEvents(boost::date_time::min_date_time), shared::event::kNoEvent); - BOOST_REQUIRE_THROW(evtHandler.getEventId(), std::runtime_error); + BOOST_REQUIRE_THROW(evtHandler.getEventId(), shared::exception::CNullReference); } //-------------------------------------------------------------- diff --git a/tests/unit/sources/shared/event/TestTimePoint.cpp b/tests/unit/sources/shared/event/TestTimePoint.cpp index 3411ff6406..46eac33408 100644 --- a/tests/unit/sources/shared/event/TestTimePoint.cpp +++ b/tests/unit/sources/shared/event/TestTimePoint.cpp @@ -2,6 +2,7 @@ #include // Includes needed to compile tested classes +#include "../../../../sources/shared/shared/exception/InvalidParameter.hpp" #include "../../../../sources/shared/shared/event/EventTimePoint.h" #include "../../../../sources/shared/shared/event/EventHandler.hpp" @@ -74,7 +75,7 @@ BOOST_AUTO_TEST_SUITE(TestTimePoint) useTimeMock(); const auto timePoint(shared::currentTime::Provider().now() - boost::posix_time::seconds(3)); const auto evtId = 123456; - BOOST_REQUIRE_THROW(shared::event::CEventTimePoint timer(evtId, timePoint), std::invalid_argument); + BOOST_REQUIRE_THROW(shared::event::CEventTimePoint timer(evtId, timePoint), shared::exception::CInvalidParameter); } //-------------------------------------------------------------- diff --git a/tests/unit/sources/shared/http/CMakeLists.txt b/tests/unit/sources/shared/http/CMakeLists.txt new file mode 100644 index 0000000000..dd3ac4100a --- /dev/null +++ b/tests/unit/sources/shared/http/CMakeLists.txt @@ -0,0 +1,7 @@ + +# List subdirectories here +add_subdirectory(ssdp) + + + +set (YADOMS_TESTS_SRC ${YADOMS_TESTS_SRC} PARENT_SCOPE) diff --git a/tests/unit/sources/shared/http/ssdp/CMakeLists.txt b/tests/unit/sources/shared/http/ssdp/CMakeLists.txt new file mode 100644 index 0000000000..e17a4507f7 --- /dev/null +++ b/tests/unit/sources/shared/http/ssdp/CMakeLists.txt @@ -0,0 +1,12 @@ +#dd current directory tests +IF(NOT DISABLE_TEST_HTTP_SSDP) + ADD_YADOMS_SOURCES( + shared/shared/http/ssdp/DiscoveredDevice.h + shared/shared/http/ssdp/DiscoveredDevice.cpp + ) + ADD_SOURCES(TestDiscoveredDevice.cpp) + +ENDIF() + + +set (YADOMS_TESTS_SRC ${YADOMS_TESTS_SRC} PARENT_SCOPE) diff --git a/tests/unit/sources/shared/http/ssdp/TestDiscoveredDevice.cpp b/tests/unit/sources/shared/http/ssdp/TestDiscoveredDevice.cpp new file mode 100644 index 0000000000..1cb3eb7f52 --- /dev/null +++ b/tests/unit/sources/shared/http/ssdp/TestDiscoveredDevice.cpp @@ -0,0 +1,209 @@ +#include "stdafx.h" +#include + +// Includes needed to compile tested classes +#include "../../../../sources/shared/shared/http/ssdp/DiscoveredDevice.h" +#include + +BOOST_AUTO_TEST_SUITE(TestDiscoveredDevice) + + BOOST_AUTO_TEST_CASE(InvalidContruction) + { + BOOST_CHECK_THROW(shared::http::ssdp::CDiscoveredDevice dd(""), std::runtime_error); + } + + BOOST_AUTO_TEST_CASE(Lametric) + { + static const auto ssdpAnswer = std::string( + "" + "" + "" + "1" + "0" + "" + "https://192.168.1.10:443" + "" + "urn:schemas-upnp-org:device:LaMetric:1" + "LaMetric Time (LM3989)" + "LaMetric Inc." + "http://www.lametric.com" + "LaMetric - internet connected clock and smart display" + "LaMetric Time" + "SA01" + "http://www.lametric.com" + "SA171202398900W00BS9" + "27539" + "27539" + "uuid:ca964fe6-117e-4880-a303-3b0c13c125fc" + "" + ""); + + const shared::http::ssdp::CDiscoveredDevice dd(ssdpAnswer); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.URLBase"), "https://192.168.1.10:443"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.deviceType"), + "urn:schemas-upnp-org:device:LaMetric:1"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.friendlyName"), "LaMetric Time (LM3989)"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturer"), "LaMetric Inc."); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturerURL"), "http://www.lametric.com"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelDescription"), + "LaMetric - internet connected clock and smart display"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelName"), "LaMetric Time"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelNumber"), "SA01"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelURL"), "http://www.lametric.com"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.serialNumber"), "SA171202398900W00BS9"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.serverId"), 27539); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.deviceId"), 27539); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.UDN"), + "uuid:ca964fe6-117e-4880-a303-3b0c13c125fc"); + } + + BOOST_AUTO_TEST_CASE(SynologyDS216IIPlusSsdp) + { + static const auto ssdpAnswer = std::string( + "\n\n\t\n\t\t1\n\t\t0\n\t\n\t\n\t\turn:schemas-upnp-org:device:Basic:1\n\t\tNAS (DS216+II)\n\t\tSynology\n\t\thttp://www.synology.com\n\t\tSynology NAS\n\t\tDS216+II\n\t\tDS216+II 6.2-25426\n\t\thttp://www.synology.com\n\t\tNAS\n\t\t0011325e4496\n\t\tuuid:73796E6F-6473-6D00-0000-0011325e4496\n\t\t\n\t\t\t\n\t\t\t\thttp://192.168.0.2:5000\n\t\t\t\turn:schemas-dummy-com:service:Dummy:1\n\t\t\t\turn:dummy-com:serviceId:dummy1\n\t\t\t\t/dummy\n\t\t\t\t/dummy\n\t\t\t\t/ssdp/dummy.xml\n\t\t\t\n\t\t\n\t\thttp://192.168.0.2:5000/\n\t\n\n\n"); + + const shared::http::ssdp::CDiscoveredDevice dd(ssdpAnswer); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.serviceList.service.URLBase"), + "http://192.168.0.2:5000"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.deviceType"), + "urn:schemas-upnp-org:device:Basic:1"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.friendlyName"), "NAS (DS216+II)"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturer"), "Synology"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturerURL"), "http://www.synology.com"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelDescription"), "Synology NAS"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelName"), "DS216+II"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelNumber"), "DS216+II 6.2-25426"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelURL"), "http://www.synology.com"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelType"), "NAS"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.serialNumber"), "0011325e4496"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.UDN"), + "uuid:73796E6F-6473-6D00-0000-0011325e4496"); + } + + BOOST_AUTO_TEST_CASE(SynologyDS216IIPlusDesc) + { + static const auto ssdpAnswer = std::string( + "\n\n\n\t1\n\t0\n\n\n\turn:schemas-upnp-org:device:MediaServer:1\n\tNAS\n\tSynology Inc.\n\thttp://www.synology.com/\n\tDS216+II\n\tSynology DLNA/UPnP Media Server\n\thttp://www.synology.com\n\t1650O6N558101\n\tuuid:0011325e-4496-0011-9644-96445e321100\n\thttp://192.168.0.2:5000/\n \n \n image/jpeg\n 120\n 120\n 24\n /tmp_icon/dmsicon120.jpg\n \n \n image/jpeg\n 48\n 48\n 24\n /tmp_icon/dmsicon48.jpg\n \n \n image/png\n 120\n 120\n 24\n /tmp_icon/dmsicon120.png\n \n \n image/png\n 48\n 48\n 24\n /tmp_icon/dmsicon48.png\n \n\n \n\n\t\n\t\t\n\t\t\turn:schemas-upnp-org:service:ConnectionManager:1\n\t\t\turn:upnp-org:serviceId:ConnectionManager\n\t\t\t/connmgrSCPD.xml\n\t\t\t/ConnectionManager/control\n\t\t\t/ConnectionManager/event\n\t\t\n\t\t\n\t\t\turn:schemas-upnp-org:service:ContentDirectory:1\n\t\t\turn:upnp-org:serviceId:ContentDirectory\n\t\t\t/cdsxSCPD.xml\n\t\t\t/ContentDirectory/control\n\t\t\t/ContentDirectory/event\n\t\t\n\t\t\n\t\t\turn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1\n\t\t\turn:microsoft.com:serviceId:X_MS_MediaReceiverRegistrar\n\t\t\t/msrrSCPD.xml\n\t\t\t/MediaReceiverRegistrar/event\n\t\t\t/MediaReceiverRegistrar/control\n\t\t\n\t\n\n\n"); + + const shared::http::ssdp::CDiscoveredDevice dd(ssdpAnswer); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.presentationURL"), "http://192.168.0.2:5000/"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.deviceType"), + "urn:schemas-upnp-org:device:MediaServer:1"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.friendlyName"), "NAS"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturer"), "Synology Inc."); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturerURL"), "http://www.synology.com/"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelDescription"), + "Synology DLNA/UPnP Media Server"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelName"), "DS216+II"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelURL"), "http://www.synology.com"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.serialNumber"), "1650O6N558101"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.UDN"), + "uuid:0011325e-4496-0011-9644-96445e321100"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.presentationURL"), "http://192.168.0.2:5000/"); + } + + BOOST_AUTO_TEST_CASE(NetgearDG834GV4) + { + static const auto ssdpAnswer = std::string( + "\n10urn:schemas-upnp-org:device:InternetGatewayDevice:1NETGEAR DG834GV4 RouterNETGEAR http://www.netgear.com/NETGEAR DG834GV4 RouterNETGEAR DG834GV4 Router5.01.16http://www.netgear.com/ uuid:824ff22b-8c7d-41c5-a131-44f534e12555urn:schemas-upnp-org:service:Layer3Forwarding:1urn:upnp-org:serviceId:Layer3Forwarding1/ctl/L3F/evt/L3F/L3F.xmlurn:schemas-upnp-org:device:WANDevice:1WANDeviceNETGEARhttp://www.netgear.com/WAN DeviceWAN Device20070827http://www.netgear.com/ uuid:824ff22b-8c7d-41c5-a131-44f534e12556DG834GV4urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1urn:upnp-org:serviceId:WANCommonIFC1/ctl/CmnIfCfg/evt/CmnIfCfg/WANCfg.xmlurn:schemas-upnp-org:device:WANConnectionDevice:1WANConnectionDeviceNETGEARhttp://www.netgear.com/Residential GatewayDG834GV420070827http://www.netgear.com/ uuid:824ff22b-8c7d-41c5-a131-44f534e12557DG834GV4urn:schemas-upnp-org:service:WANIPConnection:1urn:upnp-org:serviceId:WANIPConn1/ctl/IPConn/evt/IPConn/WANIPCn.xmlhttp://192.168.0.1/"); + + const shared::http::ssdp::CDiscoveredDevice dd(ssdpAnswer); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.presentationURL"), "http://192.168.0.1/"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.deviceType"), + "urn:schemas-upnp-org:device:InternetGatewayDevice:1"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.friendlyName"), "NETGEAR DG834GV4 Router"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturer"), "NETGEAR "); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturerURL"), "http://www.netgear.com/"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelDescription"), "NETGEAR DG834GV4 Router"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelName"), "NETGEAR DG834GV4 Router"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelNumber"), "5.01.16"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelURL"), "http://www.netgear.com/"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.serialNumber"), " "); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.UDN"), + "uuid:824ff22b-8c7d-41c5-a131-44f534e12555"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.presentationURL"), "http://192.168.0.1/"); + } + + BOOST_AUTO_TEST_CASE(TpLinkTLWA801N) + { + static const auto ssdpAnswer = std::string( + "\n\n \n 1\n 0\n \n \n urn:schemas-wifialliance-org:device:WFADevice:1\n WPS Access Point\n TP-LINK\n http://www.tp-link.com\n Wireless N Router\n TL-WA801N\n 2.0\n http://192.168.0.3:80\n 1.0\n uuid:00000000-0000-1000-0000-e894f6a317f3\n UPC here\n \n \n urn:schemas-wifialliance-org:service:WFAWLANConfig:1\n urn:wifialliance-org:serviceId:WFAWLANConfig1\n wps_scpd.xml\n wps_control\n wps_event\n \n \n\n\n"); + + const shared::http::ssdp::CDiscoveredDevice dd(ssdpAnswer); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelURL"), "http://192.168.0.3:80"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.deviceType"), + "urn:schemas-wifialliance-org:device:WFADevice:1"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.friendlyName"), "WPS Access Point"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturer"), "TP-LINK"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturerURL"), "http://www.tp-link.com"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelDescription"), "Wireless N Router"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelName"), "TL-WA801N"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelNumber"), "2.0"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.serialNumber"), "1.0"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.UDN"), + "uuid:00000000-0000-1000-0000-e894f6a317f3"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.UPC"), "UPC here"); + } + + BOOST_AUTO_TEST_CASE(Synology218plus) + { + static const auto ssdpAnswer = std::string( + "10urn:schemas-upnp-org:device:Basic:1odahds218plus (DS218+)Synologyhttp://www.synology.comSynology NASDS218+DS218+ 6.2-25426http://www.synology.comNAS001132ac3d49uuid:73796E6F-6473-6D00-0000-001132ac3d49http://192.168.1.168:5000urn:schemas-dummy-com:service:Dummy:1urn:dummy-com:serviceId:dummy1/dummy/dummy/ssdp/dummy.xmlhttp://192.168.1.168:5000/"); + const shared::http::ssdp::CDiscoveredDevice dd(ssdpAnswer); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.serviceList.service.URLBase"), + "http://192.168.1.168:5000"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.deviceType"), + "urn:schemas-upnp-org:device:Basic:1"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.friendlyName"), "odahds218plus (DS218+)"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturer"), "Synology"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturerURL"), "http://www.synology.com"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelDescription"), "Synology NAS"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelName"), "DS218+"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelNumber"), "DS218+ 6.2-25426"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelURL"), "http://www.synology.com"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelType"), "NAS"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.serialNumber"), "001132ac3d49"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.UDN"), + "uuid:73796E6F-6473-6D00-0000-001132ac3d49"); + } + + BOOST_AUTO_TEST_CASE(Synology218plusDesc) + { + static const auto ssdpAnswer = std::string( + "10urn:schemas-upnp-org:device:MediaServer:1odahds218plusSynology Inc.http://www.synology.com/DS218+Synology DLNA/UPnP Media Serverhttp://www.synology.com1940PCN762604uuid:001132ac-3d49-0011-493d-493dac321100http://192.168.1.168:5000/image/jpeg12012024/tmp_icon/dmsicon120.jpgimage/jpeg484824/tmp_icon/dmsicon48.jpgimage/png12012024/tmp_icon/dmsicon120.pngimage/png484824/tmp_icon/dmsicon48.pngurn:schemas-upnp-org:service:ConnectionManager:1urn:upnp-org:serviceId:ConnectionManager/connmgrSCPD.xml/ConnectionManager/control/ConnectionManager/eventurn:schemas-upnp-org:service:ContentDirectory:1urn:upnp-org:serviceId:ContentDirectory/cdsxSCPD.xml/ContentDirectory/control/ContentDirectory/eventurn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1urn:microsoft.com:serviceId:X_MS_MediaReceiverRegistrar/msrrSCPD.xml/MediaReceiverRegistrar/event/MediaReceiverRegistrar/control"); + const shared::http::ssdp::CDiscoveredDevice dd(ssdpAnswer); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.deviceType"), + "urn:schemas-upnp-org:device:MediaServer:1"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.friendlyName"), "odahds218plus"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturer"), "Synology Inc."); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturerURL"), "http://www.synology.com/"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelName"), "DS218+"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelDescription"), + "Synology DLNA/UPnP Media Server"); + + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelURL"), "http://www.synology.com"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.serialNumber"), "1940PCN762604"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.UDN"), + "uuid:001132ac-3d49-0011-493d-493dac321100"); + } + + BOOST_AUTO_TEST_CASE(SagemcomFast5656OFR) + { + static const auto ssdpAnswer = std::string( + "10urn:schemas-wifialliance-org:device:WFADevice:1WFADevice\n\tSagemcom \n\thttp://www.broadcom.comLivebox FibreSagemcomFast5656_OFRSG_LBF_1.1.40000001uuid:33343439-3542-f345-f632-383033343439urn:schemas-wifialliance-org:service:WFAWLANConfig:1urn:wifialliance-org:serviceId:WFAWLANConfig1/x_wfawlanconfig.xml/control?WFAWLANConfig/event?WFAWLANConfig"); + + const shared::http::ssdp::CDiscoveredDevice dd(ssdpAnswer); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.deviceType"), + "urn:schemas-wifialliance-org:device:WFADevice:1"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.friendlyName"), "WFADevice"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturer"), "Sagemcom "); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.manufacturerURL"), "http://www.broadcom.com"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelDescription"), "Livebox Fibre"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelName"), "SagemcomFast5656_OFR"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.modelNumber"), "SG_LBF_1.1.4"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.serialNumber"), "0000001"); + BOOST_CHECK_EQUAL(dd.xmlContent()->get("root.device.UDN"), + "uuid:33343439-3542-f345-f632-383033343439"); + } + +BOOST_AUTO_TEST_SUITE_END()