Commit Graph

92 Commits (master)

Author SHA1 Message Date
Michael Meeks 1b6af5e28d killpoco: remove lots of redundant JSON includes.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I976c5b8d6763cbbf0ee5cadfa2f7335ec719fe85
2024-04-25 09:06:13 +02:00
Ashod Nakashian efa67ea216 wsd: test: refactor WopiTestServer to override uploading
Change-Id: Ie8fbad9825af874cb13a732c87337cdff5c27c1d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-03-05 12:21:50 +01:00
Ashod Nakashian 2e8561195c wsd: move deprecated logic under legacy_server config
We no longer send LOOL-WOPI headers, unless
the configuration specifically flags for
legacy servers. But we always send COOL-WOPI
even to legacy servers, to help them upgrade
seamlessly.

Change-Id: Ifc919ed8f6665cd8f846117ef4e8b7ef09fbd563
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-03-02 04:02:26 -05:00
Aron Budea 3b8f3d07f6 Replace Util::startsWith/endsWith w/ C++20 equivalent
Replace a few cases of Util::toString(...), too.

Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: I53c5dbbdf2f60710e94add9dd137aa9becb7bd3e
2024-02-22 08:08:32 +01:00
Michael Meeks 7031c3b0ce cool#8328 - config header fixup.
config.h should be included as the 1st line in each source file.
It should not be included in headers.

config_version.h which changes on every commit should not be
included widely - so remove it from the HttpRequest heeader to
save tinderbox's ccache.

Fetch version info from helper methods rather than in-lining via
defines, to better encapsulate.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: If449a36f1ac61940f04d70d5f4180db389d9b4c4
2024-02-21 09:35:25 +00:00
Michael Meeks 7183a3d3de spdx: improve machine and human readability of headers.
Change-Id: Ice934380029bf27054e830fffc07a5d037d1430f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-11-14 19:36:31 +00:00
Ashod Nakashian c3fb1d0dde wsd: helper to serialize pairs
Since we don't want to propagate Poco types
as well as our pair containers, it's best
to have these are named functions rather
than as operator<<.

Change-Id: I9772b8f314262147b6c445464bf3ce8cb598b56d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-24 21:33:02 -04:00
Caolán McNamara 62504735ea cid#318868 silence bogus Double free
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I4ef594a2274a6a2b646ce2a305cdab6263390ef7
2023-08-16 15:15:59 +02:00
Ashod Nakashian 75ae9894b9 wsd: Util::make_unique -> std::make_unique
Change-Id: I1063913f91571ea6ad95386a3da6a4072574d155
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-08-03 08:40:20 +02:00
Ashod Nakashian bc5e9f1ed0 wsd: test: use configCheckFileInfo instead of handleHttpRequest
Change-Id: Iff526bda55e112877df74d55f21bc8108bb384f2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-20 03:55:19 -04:00
Ashod Nakashian 6f0199f07f wsd: test: refactor assertCheckFileInfoRequest into the handler
Change-Id: I089706147b12d75d8dce8ffb740ffe738f1354ec
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-20 03:55:19 -04:00
Ashod Nakashian fc80fb66bf wsd: test: refactor assertGetFileRequest into the handler
Change-Id: I4a1a17bac9694f92ffab49d1c9143bab83f22835
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-20 03:55:19 -04:00
Ashod Nakashian 901ea7969a wsd: test: refactor the default CheckFileInfo payload
Change-Id: I357e5733cba12b1826d13ca0cdc6d5de3da0afd0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-20 03:55:19 -04:00
Ashod Nakashian 4f5bea53cf wsd: test: log resetting wopi event counters
Change-Id: I34c67b460803526b7d61fb357080e67ccf63551a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-31 07:40:11 -04:00
Ashod Nakashian 05ecebe482 wsd: cosmetics and header include fixups
Change-Id: I573e4336b57abfc7bcd77ff0a83042202147e53f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-02 19:54:31 -04:00
Ashod Nakashian 8c6d92bc46 wsd: test: ignore requests after testing has finished
Change-Id: Ifcb28bffb2aecd5c0d9c83fa7cdbd3a203b38f37
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-14 11:30:14 +01:00
Ashod Nakashian 38daf70f0a wsd: test: minor test server logging improvement
Change-Id: I509952c80be91dc6d0b97dfdb1df0a98d4051e24
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-06 08:43:37 -05:00
Ashod Nakashian fa069dca50 wsd: test: support controlling the response to LOCK/UNLOCK
Change-Id: Ie0d836a475f257bded5c73783398a6c300ac9d67
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-02-23 07:58:56 -05:00
Ashod Nakashian 57fe2061eb wsd: test: searchable prefix in test-server logs
Change-Id: I83cdb0f43e9681a763b964829179954e6d1b3c8a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-27 08:03:18 -04:00
Ashod Nakashian b9eb4111ae wsd: http: define named HTTP status codes
This replaces the hard-coded status-code
numbers with named compile-time constants.

Change-Id: Ibe678fb2c533b29efd696e4430f5377523eeb298
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-24 07:58:07 -05:00
Ashod Nakashian c707b4dc58 wsd: test: better assertion of test target
Change-Id: I9a13ff49aa6c9fb76e5c43b1934322b97727dddc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-12 08:00:05 -05:00
Ashod Nakashian b9a3115833 wsd: test: add decodeURIComponent
This decodes strings encoded using
encodeURIComponent.

For now, it wraps Poco::URI::decode,
which should be replaced in the future.

Change-Id: I608b327be81aeda37d2afc4dfd29828658e92dc8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-12 08:00:05 -05:00
Ashod Nakashian 543f55f9c4 wsd: test: non-numeric filenames in WopiTestServer
Change-Id: I371c603e040466bfb6d0c5f7e9d52bd7b1d999fe
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian 5892bcba1e wsd: test: refactor client connection management
The client connection management had nothing to
do with the WopiTestServer and it was there
for convenience. The issue was that it was
not available to tests that do not need
the custom WopiTestServer and depending
on it would make them unnecessarily
complicated.

This adds a new intermediary class to manage
client connections in tests. The reason
this logic didn't move to UnitWSD or even
UnitBase is simply because the client
connection logic depends on the helpers
namespace and other test-specific code
that isn't available in COOLWSD. In short,
UnitBase and UnitWSD are primarily an
interface that COOLWSD and co depend on
and cannot contain test-specific logic
that isn't linked to coolwsd.

We also move the UnitWebSocket helper class.

Change-Id: I79567774164e137349dc162482529578f150353c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-14 18:15:39 -05:00
Ashod Nakashian 6b3566c4ff wsd: test: header and forward declaration cleanup
Change-Id: I3161c61695a2c1daa505e8276899e0a2d6d26d18
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-14 18:15:39 -05:00
Ashod Nakashian 9adacb12e2 wsd: test: move assertLockRequest to WopiTestServer
Also, don't rely on the timing to have only one
(editing) session by the time we disconnect.
Instead, make the second connection read-only
so that disconnecting the first will always
result in unlocking the document.

Change-Id: Ibbe8164b22d44b52e7b89ad2a677cb196904cac3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-12 19:42:30 -05:00
Andras Timar cf6e22c22c Fix typos in comments
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I813f652b516c79f350b46317e589b91e0ef39a1a
2022-08-23 18:37:44 +02:00
Ashod Nakashian a8cb6a660b wsd: test: track tests in URLs
This helps detect when tests cross-connect.

A rare, and very hard to find, issue went
like this:

A test (a random one) would recieve a request
that it didn't expect. This would cause it
to fail. It was clear that this was coming
from a different test--but which?

Meanwhile, another test (UnitWOPIHttpRedirect)
was in connectLOKit retry loop due to repeated
failure to connect.

With this patch, it was easy to see what was
happening, once the source was found. The
idea is to stamp the test sending the
request so the test-server can validate.
Upon failure, we can see the source test.

The source test (UnitWOPIHttpRedirect),
in the case in question, is a
server-side test. It flagged to exit once
it verified that the redirection worked
(in the GetFile serving the document).
Unfortunately, exiting didn't stop the
connection attempts in the same test. In
most cases the document would load before
DocBroker is stopped. But every so often
everything would shutdown and the test
would keep trying to connectLOKit.
Since we shutdown everything, we also
closed the listening port, which is now
available for other tests to re-use.
This is how UnitWOPIHttpRedirect requests
ended up at different tests, causing them
to fail sporadically.

The subsequent test fixes the retry logic.
The fix is left separate since this patch
is useful on its own, and independent of
the issue and the fix. This is just a tool.

Change-Id: I2848cc578a102fc0bd981e1ac71aaabc25f1a403
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 09:24:46 -04:00
Ashod Nakashian 60e64ec8c9 wsd: test: remove COOLWebSocket from WopiTestServer
Change-Id: Ia56c2a7f34503907fb1257b966125e4d94a61645
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-02 09:24:46 -04:00
Ashod Nakashian 7e7c2131cf wsd: test: support loading arbitrary docs in wopi tests
Change-Id: I8e707d16b456eb39ac134577db24fe4120da4b2c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-10 13:14:35 +01:00
Ashod Nakashian 26f7d95f67 wsd: test: WopiTestServer now loads contents from test files
Change-Id: I4daf14d01654517e18145500ed01099e350e63ac
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-10 13:14:35 +01:00
Ashod Nakashian 5095da017a wsd: test: simplify UnitWOPISlow
Change-Id: Ibb75531284654aa185a21820b1701ac5282064c2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-10 13:14:35 +01:00
Ashod Nakashian cb6383fae2 wsd: test: simplify and unify parsing of test URI
Change-Id: Idf26ac62695a1cfe067a9ddecc1cda7d07891c82
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-10 13:14:35 +01:00
Ashod Nakashian 6a01fc9bb7 wsd: test: refactor WopiTestServer
Change-Id: I7a3219f09250109f936cfadfe559c7f064ee0f94
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-10 13:14:35 +01:00
Ashod Nakashian 2be50b7e17 wsd: test: refactor test filename
Change-Id: Ida6c181afc98928e6a5dca5b6928f900668a5ea7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-10 13:14:35 +01:00
Ashod Nakashian 9fee4ef9fa wsd: test: make WopiTestServer and UnitWOPISlow consistent
Change-Id: Ifcf36de81a2a500c6c0ef128901c53b540345dc9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-10 13:14:35 +01:00
Ashod Nakashian 9a69adf766 wsd: test: always set the test name
Change-Id: Ibce5cf049ad1a1df7b11412ed7160d280ece60f3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-05-06 14:45:34 +01:00
Ashod Nakashian b90638d436 wsd: test: ingest the doc content only when PutFile succeeds
Change-Id: I4d4accba34c2883b1cb4d6d43a40c89d2eb8a48f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-09 19:24:40 -05:00
Ashod Nakashian 6b0d550b5b wsd: test: validate the number of wopi requests
We track the number of wopi requests done
during tests and compare with the expected,
in each test scenario. This ensures we don't
miss any expected/required wopi operation,
but also that we don't do more than the
necessary minimum.

Change-Id: I2474f54987a6a12c396b6c0566324772ee3300e6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-09 19:24:40 -05:00
Ashod Nakashian 9b9b8202f7 wsd: test: minor cleanup COOL test socket helpers
Change-Id: Ib9f297963bf319e01c603c7c64f632a5e5278328
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-24 07:38:13 -05:00
Ashod Nakashian 73c5bdf04e wsd: test: minor cleanup in UnitWOPILock
Change-Id: I945716d314b98af4dbb6dd123e1406e2e6f94db8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-24 07:38:13 -05:00
Ashod Nakashian 52f2600cf9 wsd: test: embue all tests with a name and unify logs
Now the remaining tests that didn't have a name
get one and the logs are unified between old-
and new-style tests. Mostly.

This makes sure that all logs and assertions
properly log the test name and make test
failures easier to debug and fix.

Change-Id: Id159ffacc81642a6ec594c5143498408adab67cf
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Ashod Nakashian 6bf5771376 wsd: test: track wopi operations
Change-Id: Ibd65d3cc29e665510379e72abd7ff1e0f214cc91
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Ashod Nakashian 11dc26b9dc wsd: test: make WopiTestServer less public
Change-Id: Idf28f0a93cab0abcfdf3e518fa08bb06d6eaedd6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00
Ashod Nakashian f4aa05cbf9 test: modernize http response in tests and simplify
And improve some test logs.

Change-Id: Ia65de99b5682abe55f677c6afca40289087f45e5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-04 10:26:49 -05:00
Ashod Nakashian 5cab06bd88 wsd: test: improve lock tests
Change-Id: Ia864e094daf5d794ffdac411d5ea22c98049afa4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-01-27 12:58:18 +03:00
Ashod Nakashian cdccf4d820 wsd: test: improved test state machine
This adds a better automatic test state
enum, with support for transitions.

It is intended to be used only in tests,
to simplify the writing of tests around
a state-machine.

Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit bf5e8a2d9f)

Change-Id: I8805dad57ca3c71c26cc30236d4832710e1717f9
2022-01-11 09:28:03 +01:00
Ashod Nakashian aad22ee83c wsd: test: better logging
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit ec3613ba2d)

Change-Id: I5e245d0ac5c185943586d6aec651f606f8e23bb8
2022-01-11 09:28:03 +01:00
Ashod Nakashian f780209ad7 wsd: test: use dynamic memory for large buffers
Change-Id: I8ebcf0a9393366ca5b3005ab719d9ee093a12e83
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit b34c46cb2a)
2022-01-11 09:28:03 +01:00
Andras Timar f07ff8c7e0 rename: remaining lool->cool changes
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Ib7d4e804bebe52dead8d53b0e0bbaed0f08bf3d0
2021-11-18 14:14:11 +01:00