diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-09-11 00:01:46 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-09-13 13:23:36 +0100 |
commit | c8f0fb73e49f6b6b6ac1690c585c25ab7dbd2b88 (patch) | |
tree | 226902d06f71c3330cd9c6f9c4a2cfefe4920862 | |
parent | de682ca8f4908e058d4821684b13e35369bcc493 (diff) | |
download | webstat-c8f0fb73e49f6b6b6ac1690c585c25ab7dbd2b88.tar.bz2 webstat-c8f0fb73e49f6b6b6ac1690c585c25ab7dbd2b88.tar.xz webstat-c8f0fb73e49f6b6b6ac1690c585c25ab7dbd2b88.zip |
Always pass API URL to curlGetUserAgentDetail
-rw-r--r-- | src/ingestor.hpp | 2 | ||||
-rw-r--r-- | src/uaLookup.hpp | 3 | ||||
-rw-r--r-- | test/test-ingest.cpp | 10 |
3 files changed, 9 insertions, 6 deletions
diff --git a/src/ingestor.hpp b/src/ingestor.hpp index d9d49a3..f181ea3 100644 --- a/src/ingestor.hpp +++ b/src/ingestor.hpp @@ -31,6 +31,8 @@ namespace WebStat { template<typename... T> void storeLogLine(DB::Connection *, const std::tuple<T...> &) const; + std::string userAgentAPI = "https://useragentstring.com"; + protected: size_t linesRead = 0; size_t linesParsed = 0; diff --git a/src/uaLookup.hpp b/src/uaLookup.hpp index 3c43371..5529a40 100644 --- a/src/uaLookup.hpp +++ b/src/uaLookup.hpp @@ -30,6 +30,5 @@ namespace WebStat { std::string result; }; - std::unique_ptr<CurlOperation> curlGetUserAgentDetail( - std::string_view uas, const char * baseUrl = "https://useragentstring.com"); + std::unique_ptr<CurlOperation> curlGetUserAgentDetail(std::string_view uas, const char * baseUrl); } diff --git a/test/test-ingest.cpp b/test/test-ingest.cpp index 9b21e44..3799aab 100644 --- a/test/test-ingest.cpp +++ b/test/test-ingest.cpp @@ -175,6 +175,7 @@ public: TestIngestor() : WebStat::Ingestor {WebStat::getTestUtsName("test-hostname"), std::make_shared<MockDBPool>("webstat")} { + userAgentAPI = FIXTURE_URL_BASE + "/userAgent.json"; } }; @@ -206,13 +207,11 @@ BOOST_AUTO_TEST_CASE(StoreLog, *boost::unit_test::depends_on("I/StoreLogLine")) BOOST_CHECK_EQUAL(linesDiscarded, 0); } -BOOST_AUTO_TEST_SUITE_END(); - BOOST_AUTO_TEST_CASE(FetchMockUserAgentDetail) { const auto uaDetailReq = WebStat::curlGetUserAgentDetail( R"(Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36)", - (FIXTURE_URL_BASE + "/userAgent.json").c_str()); + userAgentAPI.c_str()); BOOST_REQUIRE(uaDetailReq); BOOST_REQUIRE_EQUAL(CURLE_OK, curl_easy_perform(uaDetailReq->hnd.get())); @@ -223,10 +222,13 @@ BOOST_AUTO_TEST_CASE(FetchMockUserAgentDetail) } } +BOOST_AUTO_TEST_SUITE_END(); + BOOST_AUTO_TEST_CASE(FetchRealUserAgentDetail, *boost::unit_test::disabled()) { const auto uaDetailReq = WebStat::curlGetUserAgentDetail( - R"(Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36)"); + R"(Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36)", + "http://useragentstring.com"); BOOST_REQUIRE(uaDetailReq); BOOST_REQUIRE_EQUAL(CURLE_OK, curl_easy_perform(uaDetailReq->hnd.get())); |