summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2019-02-13 18:01:08 +0100
committerMichael Meeks <michael.meeks@collabora.com>2019-02-13 18:24:36 +0100
commitf98a7f05925da20a6a499a1d089a41678c017e17 (patch)
tree1facd268bde82d1e49aac15058ec2c743f41a66e
parente3b17cdc3c1a282473c0b34282e4b8fc99286e31 (diff)
Improve unit test / SSL handling & detection.
Change-Id: I6bd3116ac94d3d2c61e2ec543cb17896834ef2df
-rw-r--r--common/Unit.cpp4
-rw-r--r--test/helpers.hpp6
-rw-r--r--wsd/LOOLWSD.cpp11
-rw-r--r--wsd/LOOLWSD.hpp3
4 files changed, 21 insertions, 3 deletions
diff --git a/common/Unit.cpp b/common/Unit.cpp
index ae1c363a6..28dba3488 100644
--- a/common/Unit.cpp
+++ b/common/Unit.cpp
@@ -151,6 +151,8 @@ UnitWSD::~UnitWSD()
{
}
+static bool isSSL = false;
+
void UnitWSD::configure(Poco::Util::LayeredConfiguration &config)
{
if (isUnitTesting())
@@ -163,6 +165,8 @@ void UnitWSD::configure(Poco::Util::LayeredConfiguration &config)
config.setBool("logging.file[@enable]", false);
}
// else - a product run.
+
+ isSSL = config.getBool("ssl.enable", true) && !config.getBool("ssl.termination", false);
}
void UnitWSD::lookupTile(int part, int width, int height, int tilePosX, int tilePosY,
diff --git a/test/helpers.hpp b/test/helpers.hpp
index 13b351762..bc4818d98 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -160,10 +160,10 @@ 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());
+ if (uri.getScheme() == "https")
+ return new Poco::Net::HTTPSClientSession(uri.getHost(), uri.getPort());
#endif
+ return new Poco::Net::HTTPClientSession(uri.getHost(), uri.getPort());
}
inline
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index ba1d3f134..fccb86ef9 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3063,6 +3063,17 @@ private:
static LOOLWSDServer srv;
+std::string LOOLWSD::getServerURL()
+{
+ std::ostringstream oss;
+
+ oss << getLaunchBase("");
+ oss << LOOLWSD::ServiceRoot;
+ oss << LOOLWSD_TEST_LOLEAFLET_UI;
+
+ return oss.str();
+}
+
int LOOLWSD::innerMain()
{
#if !defined FUZZER && !MOBILEAPP
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index a0a43910e..9303f789a 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -157,6 +157,9 @@ public:
return AnonymizeUsernames ? Util::anonymize(username) : username;
}
+ /// get correct server URL with protocol + port number for this running server
+ static std::string getServerURL();
+
int innerMain();
protected: