2018-02-08 12:51:54 -06:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2021-03-25 08:47:10 -05:00
|
|
|
#include <config.h>
|
|
|
|
|
2022-02-05 17:14:38 -06:00
|
|
|
#include "WOPIUploadConflictCommon.hpp"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <Poco/Net/HTTPRequest.h>
|
2018-02-08 12:51:54 -06:00
|
|
|
|
2022-02-05 17:14:38 -06:00
|
|
|
#include "Util.hpp"
|
2018-02-08 12:51:54 -06:00
|
|
|
#include "Log.hpp"
|
|
|
|
#include "UnitHTTP.hpp"
|
|
|
|
#include "helpers.hpp"
|
2020-12-22 18:08:57 -06:00
|
|
|
#include "lokassert.hpp"
|
2018-02-08 12:51:54 -06:00
|
|
|
|
2022-02-05 17:14:38 -06:00
|
|
|
class UnitWOPIDocumentConflict : public WOPIUploadConflictCommon
|
2018-02-08 12:51:54 -06:00
|
|
|
{
|
2022-02-19 18:57:47 -06:00
|
|
|
using Base = WOPIUploadConflictCommon;
|
2018-02-08 12:51:54 -06:00
|
|
|
|
2022-02-19 18:57:47 -06:00
|
|
|
using Base::Phase;
|
|
|
|
using Base::Scenario;
|
|
|
|
|
|
|
|
using Base::ConflictingDocContent;
|
|
|
|
using Base::ModifiedOriginalDocContent;
|
|
|
|
using Base::OriginalDocContent;
|
2020-12-22 18:08:57 -06:00
|
|
|
|
2018-02-08 12:51:54 -06:00
|
|
|
public:
|
2020-10-21 06:37:34 -05:00
|
|
|
UnitWOPIDocumentConflict()
|
2022-02-19 18:57:47 -06:00
|
|
|
: Base("UnitWOPIDocumentConflict", OriginalDocContent)
|
2018-02-08 12:51:54 -06:00
|
|
|
{
|
|
|
|
}
|
2022-02-26 15:55:04 -06:00
|
|
|
|
2023-05-30 17:30:21 -05:00
|
|
|
std::unique_ptr<http::Response>
|
|
|
|
assertGetFileRequest(const Poco::Net::HTTPRequest& /*request*/) override
|
2022-02-16 19:07:23 -06:00
|
|
|
{
|
|
|
|
LOG_TST("Testing " << toString(_scenario));
|
|
|
|
LOK_ASSERT_STATE(_phase, Phase::WaitLoadStatus);
|
|
|
|
|
|
|
|
assertGetFileCount();
|
2023-05-30 17:30:21 -05:00
|
|
|
|
|
|
|
return nullptr; // Success.
|
2022-02-16 19:07:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<http::Response>
|
|
|
|
assertPutFileRequest(const Poco::Net::HTTPRequest& /*request*/) override
|
|
|
|
{
|
|
|
|
LOG_TST("Testing " << toString(_scenario));
|
|
|
|
LOK_ASSERT_STATE(_phase, Phase::WaitDocClose);
|
|
|
|
|
|
|
|
assertPutFileCount();
|
|
|
|
|
|
|
|
switch (_scenario)
|
|
|
|
{
|
|
|
|
case Scenario::Disconnect:
|
|
|
|
case Scenario::SaveDiscard:
|
|
|
|
case Scenario::CloseDiscard:
|
|
|
|
case Scenario::VerifyOverwrite:
|
|
|
|
LOK_ASSERT_FAIL("Unexpectedly overwritting the document in storage");
|
|
|
|
break;
|
|
|
|
case Scenario::SaveOverwrite:
|
|
|
|
LOG_TST("Closing the document to verify its contents after reloading");
|
|
|
|
WSD_CMD("closedocument");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2022-02-26 15:55:04 -06:00
|
|
|
void onDocBrokerDestroy(const std::string& docKey) override
|
|
|
|
{
|
|
|
|
LOG_TST("Testing " << toString(_scenario) << " with dockey [" << docKey << "] closed.");
|
|
|
|
LOK_ASSERT_STATE(_phase, Phase::WaitDocClose);
|
|
|
|
|
|
|
|
std::string expectedContents;
|
|
|
|
switch (_scenario)
|
|
|
|
{
|
|
|
|
case Scenario::Disconnect:
|
|
|
|
expectedContents = ConflictingDocContent; //TODO: save-as in this case.
|
|
|
|
break;
|
|
|
|
case Scenario::SaveDiscard:
|
|
|
|
expectedContents = ConflictingDocContent;
|
|
|
|
break;
|
|
|
|
case Scenario::CloseDiscard:
|
|
|
|
expectedContents = ConflictingDocContent;
|
|
|
|
break;
|
|
|
|
case Scenario::SaveOverwrite:
|
|
|
|
expectedContents = ModifiedOriginalDocContent;
|
|
|
|
break;
|
|
|
|
case Scenario::VerifyOverwrite:
|
|
|
|
expectedContents = OriginalDocContent;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
LOK_ASSERT_EQUAL_MESSAGE("Unexpected contents in storage", expectedContents,
|
|
|
|
getFileContent());
|
|
|
|
|
|
|
|
Base::onDocBrokerDestroy(docKey);
|
|
|
|
}
|
2018-02-08 12:51:54 -06:00
|
|
|
};
|
|
|
|
|
2020-12-22 18:08:57 -06:00
|
|
|
UnitBase* unit_create_wsd(void) { return new UnitWOPIDocumentConflict(); }
|
2018-02-08 12:51:54 -06:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|