loolwsd/test/UnitAdmin.cpp | 36 +++++++++++++++++++----------------- loolwsd/test/helpers.hpp | 18 ++++++++++++------ loolwsd/test/run_unit.sh.in | 10 ++++++---- 3 files changed, 37 insertions(+), 27 deletions(-)
New commits: commit b3dd2f31f9870e14af0ca43ade39b56b3a58c428 Author: Jan Holesovsky <[email protected]> Date: Mon May 2 13:37:38 2016 +0200 Update the gdb command to match reality. diff --git a/loolwsd/test/run_unit.sh.in b/loolwsd/test/run_unit.sh.in index 072b3a8..f91bb80 100755 --- a/loolwsd/test/run_unit.sh.in +++ b/loolwsd/test/run_unit.sh.in @@ -80,9 +80,11 @@ else # newer unit tests. cat "$tst_log" echo "=============================================================" echo "Test failed on unit: $tst re-run with:" - echo " $ gdb --args ../loolwsd --systemplate=\"$systemplate_path\" --lotemplate=\"$lo_path\" \\" - echo " --childroot=\"$jails_path\" --unitlib=\".libs/$tst.so\"" - echo "=============================================================" - echo ":test-result: FAIL $tst" >> $test_output + echo " $ gdb --args ../loolwsd --systemplate=\"$systemplate_path\" \\" + echo " --lotemplate=\"$lo_path\" \\" + echo " --childroot=\"$jails_path\" --allowlocalstorage --admincreds="admin/admin" \\" + echo " --unitlib=\".libs/$tst.so\"" + echo "=============================================================" + echo ":test-result: FAIL $tst" >> $test_output fi fi commit 9df5ccc517d24caadd6bd67d2f5df755bbeea1f5 Author: Jan Holesovsky <[email protected]> Date: Mon May 2 12:26:48 2016 +0200 Make this unit test running without SSL too. diff --git a/loolwsd/test/UnitAdmin.cpp b/loolwsd/test/UnitAdmin.cpp index e231775..2383fd1 100644 --- a/loolwsd/test/UnitAdmin.cpp +++ b/loolwsd/test/UnitAdmin.cpp @@ -31,13 +31,15 @@ #include <Poco/StringTokenizer.h> #include <Poco/URI.h> +#include "helpers.hpp" + #define UNIT_URI "/loolwsd/unit-admin" using Poco::Net::HTTPBasicCredentials; using Poco::Net::HTTPCookie; using Poco::Net::HTTPRequest; using Poco::Net::HTTPResponse; -using Poco::Net::HTTPSClientSession; +using Poco::Net::HTTPClientSession; using Poco::StringTokenizer; // Inside the WSD process @@ -74,10 +76,10 @@ private: HTTPResponse response; std::string path(_uri.getPathAndQuery()); HTTPRequest request(HTTPRequest::HTTP_GET, path); - HTTPSClientSession session(_uri.getHost(), _uri.getPort()); + std::unique_ptr<HTTPClientSession> session(helpers::createSession(_uri)); - session.sendRequest(request); - session.receiveResponse(response); + session->sendRequest(request); + session->receiveResponse(response); TestResult res = TestResult::TEST_FAILED; if (response.getStatus() == HTTPResponse::HTTP_UNAUTHORIZED) res = TestResult::TEST_OK; @@ -91,12 +93,12 @@ private: HTTPResponse response; std::string path(_uri.getPathAndQuery()); HTTPRequest request(HTTPRequest::HTTP_GET, path); - HTTPSClientSession session(_uri.getHost(), _uri.getPort()); + std::unique_ptr<HTTPClientSession> session(helpers::createSession(_uri)); HTTPBasicCredentials credentials("admin", "admin"); credentials.authenticate(request); - session.sendRequest(request); - session.receiveResponse(response); + session->sendRequest(request); + session->receiveResponse(response); std::vector<HTTPCookie> cookies; response.getCookies(cookies); @@ -130,11 +132,11 @@ private: // try connecting without cookie; should result in exception HTTPResponse response; HTTPRequest request(HTTPRequest::HTTP_GET, "/adminws/"); - HTTPSClientSession session(_uri.getHost(), _uri.getPort()); + std::unique_ptr<HTTPClientSession> session(helpers::createSession(_uri)); bool authorized = true; try { - _adminWs = std::make_shared<Poco::Net::WebSocket>(session, request, response); + _adminWs = std::make_shared<Poco::Net::WebSocket>(*session, request, response); } catch (const Poco::Net::WebSocketException& exc) { @@ -155,7 +157,7 @@ private: { HTTPResponse response; HTTPRequest request(HTTPRequest::HTTP_GET, "/adminws/"); - HTTPSClientSession session(_uri.getHost(), _uri.getPort()); + std::unique_ptr<HTTPClientSession> session(helpers::createSession(_uri)); // set cookie assert(_jwtCookie != ""); @@ -167,7 +169,7 @@ private: bool authorized = true; try { - _adminWs = std::make_shared<Poco::Net::WebSocket>(session, request, response); + _adminWs = std::make_shared<Poco::Net::WebSocket>(*session, request, response); } catch (const Poco::Net::WebSocketException& exc) { @@ -195,10 +197,10 @@ private: HTTPResponse response1; const Poco::URI docUri1("https://127.0.0.1:" + std::to_string(DEFAULT_CLIENT_PORT_NUMBER)); const std::string loadMessage1 = "load url=" + documentURL1; - HTTPSClientSession session1(docUri1.getHost(), docUri1.getPort()); - HTTPSClientSession session2(docUri1.getHost(), docUri1.getPort()); - _docWs1 = std::make_shared<Poco::Net::WebSocket>(session1, request1, response1); - _docWs2 = std::make_shared<Poco::Net::WebSocket>(session2, request1, response1); + std::unique_ptr<HTTPClientSession> session1(helpers::createSession(docUri1)); + std::unique_ptr<HTTPClientSession> session2(helpers::createSession(docUri1)); + _docWs1 = std::make_shared<Poco::Net::WebSocket>(*session1, request1, response1); + _docWs2 = std::make_shared<Poco::Net::WebSocket>(*session2, request1, response1); { _messageReceived.clear(); @@ -265,8 +267,8 @@ private: HTTPResponse response2; const Poco::URI docUri2("https://127.0.0.1:" + std::to_string(DEFAULT_CLIENT_PORT_NUMBER)); const std::string loadMessage2 = "load url=" + documentURL2; - HTTPSClientSession session3(docUri2.getHost(), docUri2.getPort()); - _docWs3 = std::make_shared<Poco::Net::WebSocket>(session3, request2, response2); + std::unique_ptr<HTTPClientSession> session3(helpers::createSession(docUri1)); + _docWs3 = std::make_shared<Poco::Net::WebSocket>(*session3, request2, response2); { _messageReceived.clear(); diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp index 9da8e69..a0adaeb 100644 --- a/loolwsd/test/helpers.hpp +++ b/loolwsd/test/helpers.hpp @@ -122,6 +122,15 @@ bool isDocumentLoaded(Poco::Net::WebSocket& ws, std::string name = "") return isLoaded; } +inline +Poco::Net::HTTPClientSession* createSession(const Poco::URI& uri) +{ +#if ENABLE_SSL + return new Poco::Net::HTTPSClientSession(uri.getHost(), uri.getPort()); +#else + return new Poco::Net::HTTPClientSession(uri.getHost(), uri.getPort()); +#endif +} // Connecting to a Kit process is managed by document broker, that it does several // jobs to establish the bridge connection between the Client and Kit process, @@ -142,13 +151,10 @@ connectLOKit(Poco::URI uri, do { -#if ENABLE_SSL - Poco::Net::HTTPSClientSession session(uri.getHost(), uri.getPort()); -#else - Poco::Net::HTTPClientSession session(uri.getHost(), uri.getPort()); -#endif + std::unique_ptr<Poco::Net::HTTPClientSession> session(createSession(uri)); + std::cerr << "Connecting... "; - ws = std::make_shared<Poco::Net::WebSocket>(session, request, response); + ws = std::make_shared<Poco::Net::WebSocket>(*session, request, response); do { _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
