wsd: test: refactor test filename

Change-Id: Ida6c181afc98928e6a5dca5b6928f900668a5ea7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This commit is contained in:
Ashod Nakashian 2022-04-30 12:29:23 -04:00 committed by Michael Meeks
parent 9fee4ef9fa
commit 2be50b7e17
2 changed files with 26 additions and 3 deletions

View file

@ -63,6 +63,17 @@ public:
setFileContent(Util::toString(data));
}
/// Given a URI, returns the filename.
std::string getFilename(const Poco::URI& uri) const override
{
if (uri.getPath() == (getRootPath() + LargeDocumentFilename))
{
return LargeDocumentFilename;
}
return WopiTestServer::getFilename(uri);
}
bool handleHttpRequest(const Poco::Net::HTTPRequest& request, Poco::MemoryInputStream& message,
std::shared_ptr<StreamSocket>& socket) override
{
@ -84,7 +95,7 @@ public:
assertCheckFileInfoRequest(request);
Poco::JSON::Object::Ptr fileInfo = new Poco::JSON::Object();
fileInfo->set("BaseFileName", LargeDocumentFilename);
fileInfo->set("BaseFileName", getFilename(uriReq));
fileInfo->set("Size", getFileContent().size());
fileInfo->set("Version", "1.0");
fileInfo->set("OwnerId", "test");

View file

@ -163,6 +163,19 @@ protected:
{
}
/// Given a URI, returns the filename.
virtual std::string getFilename(const Poco::URI& uri) const
{
return uri.getPath() == (getRootPath() + "3") ? "he%llo.txt" : "hello.txt";
}
/// Returns the virtual root-path that we serve.
static const std::string& getRootPath()
{
static const std::string RootPath = "/wopi/files/";
return RootPath;
}
void configure(Poco::Util::LayeredConfiguration& config) override
{
UnitWSD::configure(config);
@ -201,9 +214,8 @@ protected:
assertCheckFileInfoRequest(request);
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("BaseFileName", getFilename(uriReq));
fileInfo->set("Size", getFileContent().size());
fileInfo->set("Version", "1.0");
fileInfo->set("OwnerId", "test");