#include #include #include #include #include #include #include "catch2/interfaces/catch_interfaces_reporter.hpp" #include "slic3r/Utils/Http.hpp" namespace { // Finalizes the embedded interpreter once, after the last test case, and never between cases. // CPython cannot be reinitialized after Py_Finalize (a second init aborts inside _datetime), and // the app likewise finalizes it only at exit, so the per-test fixtures tear down only the // PluginManager. Running at the end of the run, rather than from a static destructor, also keeps // shutdown()'s logging ahead of boost::log's teardown. class PythonInterpreterRunEnd final : public Catch::EventListenerBase { public: using Catch::EventListenerBase::EventListenerBase; void testRunEnded(const Catch::TestRunStats&) override { if (!Slic3r::PythonInterpreter::instance().is_initialized()) return; Slic3r::PluginManager::instance().shutdown(); Slic3r::PythonInterpreter::instance().shutdown(); } }; } // namespace CATCH_REGISTER_LISTENER(PythonInterpreterRunEnd) TEST_CASE("Check SSL certificates paths", "[Http][NotWorking]") { Slic3r::Http g = Slic3r::Http::get("https://github.com/"); unsigned status = 0; g.on_error([&status](std::string, std::string, unsigned http_status) { status = http_status; }); g.on_complete([&status](std::string /* body */, unsigned http_status){ status = http_status; }); g.perform_sync(); REQUIRE(status == 200); } TEST_CASE("Http digest authentication", "[Http][NotWorking]") { Slic3r::Http g = Slic3r::Http::get("https://httpbingo.org/digest-auth/auth/guest/guest"); g.auth_digest("guest", "guest"); unsigned status = 0; g.on_error([&status](std::string, std::string, unsigned http_status) { status = http_status; }); g.on_complete([&status](std::string /* body */, unsigned http_status){ status = http_status; }); g.perform_sync(); REQUIRE(status == 200); } TEST_CASE("Http basic authentication", "[Http][NotWorking]") { Slic3r::Http g = Slic3r::Http::get("https://httpbingo.org/basic-auth/guest/guest"); g.auth_basic("guest", "guest"); unsigned status = 0; g.on_error([&status](std::string, std::string, unsigned http_status) { status = http_status; }); g.on_complete([&status](std::string /* body */, unsigned http_status){ status = http_status; }); g.perform_sync(); REQUIRE(status == 200); }