summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2022-02-10 08:35:46 -0500
committerAshod Nakashian <Ashod@users.noreply.github.com>2022-02-17 18:52:48 -0500
commit11dc26b9dc98756a50ffc732482729c0eb0108a8 (patch)
treeb98e598229328cd02530fa6a44c1cf73e7b53a3a /test
parentwsd: test: remove inherited logic from UnitWOPIDocumentConflict (diff)
downloadonline-11dc26b9dc98756a50ffc732482729c0eb0108a8.tar.gz
online-11dc26b9dc98756a50ffc732482729c0eb0108a8.zip
wsd: test: make WopiTestServer less public
Change-Id: Idf28f0a93cab0abcfdf3e518fa08bb06d6eaedd6 Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Diffstat (limited to 'test')
-rw-r--r--test/UnitWOPIHttpRedirect.cpp10
-rw-r--r--test/UnitWOPISlow.cpp4
-rw-r--r--test/WopiTestServer.hpp9
3 files changed, 11 insertions, 12 deletions
diff --git a/test/UnitWOPIHttpRedirect.cpp b/test/UnitWOPIHttpRedirect.cpp
index 86b8698423..d260fac85b 100644
--- a/test/UnitWOPIHttpRedirect.cpp
+++ b/test/UnitWOPIHttpRedirect.cpp
@@ -85,21 +85,21 @@ public:
const std::string fileName(uriReq.getPath() == "/wopi/files/3" ? "he%llo.txt" : "hello.txt");
Poco::JSON::Object::Ptr fileInfo = new Poco::JSON::Object();
fileInfo->set("BaseFileName", fileName);
- fileInfo->set("Size", _fileContent.size());
+ fileInfo->set("Size", getFileContent().size());
fileInfo->set("Version", "1.0");
fileInfo->set("OwnerId", "test");
fileInfo->set("UserId", "test");
fileInfo->set("UserFriendlyName", "test");
fileInfo->set("UserCanWrite", "true");
fileInfo->set("PostMessageOrigin", "localhost");
- fileInfo->set("LastModifiedTime", Util::getIso8601FracformatTime(_fileLastModifiedTime));
+ fileInfo->set("LastModifiedTime", Util::getIso8601FracformatTime(getFileLastModifiedTime()));
fileInfo->set("EnableOwnerTermination", "true");
std::ostringstream jsonStream;
fileInfo->stringify(jsonStream);
http::Response httpResponse(http::StatusLine(200));
- httpResponse.set("Last-Modified", Util::getHttpTime(_fileLastModifiedTime));
+ httpResponse.set("Last-Modified", Util::getHttpTime(getFileLastModifiedTime()));
httpResponse.setBody(jsonStream.str(), "application/json; charset=utf-8");
socket->sendAndShutdown(httpResponse);
@@ -136,8 +136,8 @@ public:
_phase = Phase::Loaded;
http::Response httpResponse(http::StatusLine(200));
- httpResponse.set("Last-Modified", Util::getHttpTime(_fileLastModifiedTime));
- httpResponse.setBody(_fileContent, "text/plain; charset=utf-8");
+ httpResponse.set("Last-Modified", Util::getHttpTime(getFileLastModifiedTime()));
+ httpResponse.setBody(getFileContent(), "text/plain; charset=utf-8");
socket->sendAndShutdown(httpResponse);
exitTest(TestResult::Ok);
diff --git a/test/UnitWOPISlow.cpp b/test/UnitWOPISlow.cpp
index 8f7a764621..75ee7d5d0c 100644
--- a/test/UnitWOPISlow.cpp
+++ b/test/UnitWOPISlow.cpp
@@ -94,7 +94,7 @@ public:
fileInfo->set("UserCanWrite", "true");
fileInfo->set("PostMessageOrigin", "localhost");
fileInfo->set("LastModifiedTime",
- Util::getIso8601FracformatTime(_fileLastModifiedTime));
+ Util::getIso8601FracformatTime(getFileLastModifiedTime()));
fileInfo->set("EnableOwnerTermination", "true");
std::ostringstream jsonStream;
@@ -144,7 +144,7 @@ public:
{
// By default we return success.
const std::string body = "{\"LastModifiedTime\": \"" +
- Util::getIso8601FracformatTime(_fileLastModifiedTime) +
+ Util::getIso8601FracformatTime(getFileLastModifiedTime()) +
"\" }";
LOG_TST("Fake wopi host (default) response to POST " << uriReq.getPath()
<< ": 200 OK " << body);
diff --git a/test/WopiTestServer.hpp b/test/WopiTestServer.hpp
index c7610d3d25..6bd211ed2e 100644
--- a/test/WopiTestServer.hpp
+++ b/test/WopiTestServer.hpp
@@ -25,26 +25,27 @@
class WopiTestServer : public UnitWSD
{
+private:
+
enum class COOLStatusCode
{
DocChanged = 1010
};
-private:
/// The WOPISrc URL.
std::string _wopiSrc;
/// Websockets to communicate.
std::vector< std::unique_ptr<UnitWebSocket> > _wsList;
-protected:
-
/// Content of the file.
std::string _fileContent;
/// Last modified time of the file
std::chrono::system_clock::time_point _fileLastModifiedTime;
+protected:
+
const std::string& getWopiSrc() const { return _wopiSrc; }
const std::unique_ptr<UnitWebSocket>& getWs() const { return _wsList.at(0); }
@@ -72,7 +73,6 @@ protected:
return _fileLastModifiedTime;
}
-public:
WopiTestServer(std::string testname, const std::string& fileContent = "Hello, world")
: UnitWSD(std::move(testname))
{
@@ -131,7 +131,6 @@ public:
config.setBool("storage.ssl.as_scheme", false);
}
-protected:
/// Here we act as a WOPI server, so that we have a server that responds to
/// the wopi requests without additional expensive setup.
virtual bool handleHttpRequest(const Poco::Net::HTTPRequest& request,