These tests require network setup and therefore
can be problematic for `make run`.
Change-Id: I8747a505e15edc91964b290a5476a24069b7d538
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This reduces the execution time of some
long-running tests and improves stability.
A full debug build of Core and Online
now finishes on my machine in under 3 minutes,
down from slightly over 4 minutes. A significant
saving when running the tests frequently and
repeatedly.
Change-Id: I66c1b06ec3c9e8ab90a30f3a15c03f8d560ed3c6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This implements HTTP/1.1 per RFC 7230, partially.
Unit-tests are provided with documentation on usage.
This is desgined to serve as the http implementation
throughout loolwsd, for both synchronous and
asynchronous requests.
Change-Id: Iaf1b8c5fcb8cec032445e27c9f70d2fb807aa4dc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Move the connect function into the NetUtil
translation unit to aid using it for the
upcoming async socket logic.
The NetUtil should also come in handy for
the miscellaneous network helpers we have.
Change-Id: I2ee0c6e3e1769fd87572d7407d3b4979b59ffe6a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Add support for configuring the SSL certificates
when running the test binary as well as setting
up the SSL context.
Also adds the SSL socket headers with proper
compile-time guards for when SSL is disabled.
Change-Id: I99992639a66a64871f8ff8a2b2105279ead63ca1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This introduces a new macro, WSD_CMD,
used in tests only, to send a command
while logging it and its file/line of
origin.
Makes the tests more readable and the
logs more informative.
Only a handful of tests updated.
Change-Id: I55a38b35d7140a1f31f20c3c904d7eff6b19346f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This makes the test more deterministic and simpler.
We should only modify the document after it's fully
loaded. After that, we can immediately restore the
version. So we really only need three phases and
the onDocumentLoaded callback.
Change-Id: Ic59c9d4c8e03edb8e80853daf482a6c065e7c015
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
We only modify the document after it has fully loaded.
Otherwise, we risk intermittent failures due to timing
issues with when the modify commands are processed.
It's also more readable this way.
Notice that we do close the document right after
sending the modify commands. This is to test that
the modification is actually registered and is
visible when the close command is processed.
This is the whole point of this test in the first place.
Change-Id: Id3bd598b9416be901a73d6cf804563d81a245ebb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
We avoid relying on poll timing for the different
phases, instead we use the document events callbacks
to trigger the different phases of the test.
This improves the reliability of the test and makes
it more readable.
Change-Id: Ief3374acf823a89dca1412ff808cc09095f8e2e5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This makes the test less reliable on the timing of the
poll that pumps the phases by using the proper callbacks
for the different document events.
We need to wait until the document is fully loaded before
we modify it. Here we do that in onDocumentLoaded.
Change-Id: Ibf4a5b5601449b729b1e62b621f82c1957eb8a65
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This allows the UnitBase class to handle the messages
and dispatch to convenient handlers. This simplifies
the implementation of unit-tests and makes the
parsing more centralized than it is now.
Change-Id: Ice8f169ecfd12d49ee7cbd4fb9021a163b14f4ba
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
'bytes' can be smaller than the size of the buffer, so go with that size
instead.
Change-Id: I025b56379ee449fe33710b660d845fa2dd0865ee
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
fatal error: test/lokassert.hpp: No such file or dire
ctory
17 | #include <test/lokassert.hpp>
Change-Id: I935cc4e0afd6862469d27b3d2620dfa83e38ef69
Signed-off-by: Henry Castro <hcastro@collabora.com>
The text message in the WS Close Frame is optional.
Here we actually copy the remaining data after parsing
the status code, not assuming it exists or that the
status code was exactly 2 bytes (although in a well-
behaving WS implementation it always will be 2 bytes).
Also, no good reason to wait a full second between
socket reads in getErrorCode. However a small sleep
seems sensible to avoid logging "got 0 bytes" or so.
Change-Id: I162dfb0dd3ebf615a3e8e237006883388b9ff494
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Reading the messages using a different helper means
we may miss (=consume without checking) the close frame.
Change-Id: I93a529723ba8d2b516319d54496c56c7e6d7da27
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This adds proper phases instead of arbitrary
sleeping and similar workarounds. Also,
each phase documents what it expects, so
debugging failures are now self-explanatory.
Change-Id: Id51f4c285c5cf98aceba3415f0ffe14bd7605acc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This moves the test log macros into a new home,
test/testlog.hpp, to avoid cycling dependencies.
Change-Id: Iacb80e813a64ff830fa18f63ec4de2535ee702b7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Also, makes the logging of units much less error prone.
The overloaded streaming operators are temporary as
they are provided in C++20. The ones here (though
incomplete) are fashioned after the C++20 specs.
Change-Id: Ieb499282ccb6e63fa939ba07bed3e5a4fbef1bd0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
chrono::system_clock can go back in time.
For time interval measurements, where we don't
care about the local time, a monotonic clock
should be used.
This avoids the server uptime jumping around
with daylight saving (or indeed by regular
synchronization with an atomic clock), among
other cases.
Change-Id: I09f9b24c82d19439348a2e66cad9e9de7d755208
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
We now download the convert-to files into the
child-root/tmp directory and then move it into
the jail that will convert it. This way ownership
and cleanup become contained within our child-root
and jail subsystems. This reduces the chances of
leaking convert-to files and simplifies the design.
In addition, we avoid an extra file copy and improve
the security of the convert-to API.
Change-Id: I450c24d0d0dc0da447c8072b0701c3b48d07c81b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
These helpers are for testing only. They should
ideally be moved to the test helpers, but because
of dependency on the FileDeleter in FileUtil they
remain in FileUtil.
Change-Id: I93c7e08823edec8f6a53419f0a6596f3255f23f9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
size_t in C and in C++ are not necessarily the same
type. The C++ size_t is in the std namespace. Since
we do include many C headers, and indeed some C++
runtime headers do define size_t for backwards
compatibility, it's easy to mix and match the two
types.
Also, 'using std::size_t;' isn't a great practice,
so removed.
This is not exhaustive, just some low-hanging cases.
Change-Id: I85a36b6fd1acd204274b1869de9bcb94c8b3cf13
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
We now log the test assertion failure and exception (if any) details
with file and line number to assist in faster troubleshooting.
Change-Id: I3217458f30383cd24f3cbbe15431f2b9151744d4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This is non-functional change to have all HttpHelper
members in a single place (HttpHelper.cpp).
Clang-format is applied and FileUtil::Stat is used
instead of a naked stat(2).
Change-Id: I663e2eb3070e873bd1f4477b60e45b0086d29f4e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
We have a way of running the tests against
the actualy php-proxy script:
CYPRESS_INTEGRATION="php-proxy" make check
So let's remove the C++ implementation, so we don't
need to maintain a duplicated code.
Change-Id: Ie095a70a8175cc8cb4894905826d13762127b148
Signed-off-by: Tamás Zolnai <tamas.zolnai@collabora.com>
URIs may or may not have authorization data specified
via access_header or access_token query parameters.
In the event that the host doesn't have such needs
(for example authrorization could be performed by
some other means), we should accept the request
and still go ahead and make the WOPI request
all the same.
This patch effectively reverts the changes from
a019c93d90 which threw
an exception when the authorization method was
undefined. Since there was an assertion to warn
programmers that something is amis, now we simply
log the fact in trace mode and move on.
A new unit-test is added and another one that
expected the now-removed exception has been modified.
Change-Id: I26cc2514d7465b344037a6e32b777c0fe0ba9a2c