010-upnp-support.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "catch.hpp"
  2. #include "test-utils.h"
  3. #include "proto/upnp_support.h"
  4. #include <boost/filesystem.hpp>
  5. #include <iostream>
  6. namespace sys = boost::system;
  7. namespace fs = boost::filesystem;
  8. using namespace syncspirit::proto;
  9. using namespace syncspirit::test;
  10. TEST_CASE("parse IGD description", "[support]") {
  11. auto xml = read_file("/data/49652gatedesc.xml");
  12. auto wan_service = parse_igd(xml.c_str(), xml.size());
  13. REQUIRE(wan_service);
  14. REQUIRE(wan_service.value().control_path == "/upnp/control/WANIPConn1");
  15. REQUIRE(wan_service.value().description_path == "/gateconnSCPD.xml");
  16. }
  17. TEST_CASE("parse external IP", "[support]") {
  18. auto xml = read_file("/data/external-ip.xml");
  19. auto ip = parse_external_ip(xml.c_str(), xml.size());
  20. REQUIRE(ip);
  21. REQUIRE(ip.value() == "81.31.113.9");
  22. }
  23. TEST_CASE("parse successful port mapping", "[support]") {
  24. auto xml = read_file("/data/port-mapping-success.xml");
  25. auto r = parse_mapping(xml.c_str(), xml.size());
  26. REQUIRE(r);
  27. REQUIRE(r.value() == true);
  28. }
  29. TEST_CASE("parse failede port mapping", "[support]") {
  30. auto xml = read_file("/data/soap-failure.xml");
  31. auto r = parse_mapping(xml.c_str(), xml.size());
  32. REQUIRE(r);
  33. REQUIRE(r.value() == false);
  34. }