Previously, we were parsing the Status Line
and the header, both together. This of course
doesn't work when we had removed the Status
Line already. This wasn't an issue in parsing
responses from servers, but doesn't work when
parsing requests from clients (i.e. in a server).
Also, it's simpler.
Tests extended accordingly.
Change-Id: Id1c9a6385080c86b6072130fa8a169a699c42462
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This adds support to parse client request
on the server side.
Unit-tests included.
Change-Id: I90e9ad3007a3215682991fd2383362e1c48589a8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
And guard http data dumping with debug directives.
Change-Id: I22a725ba49bfb0399a27889ce9732dfe061e2563
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
When we fail to read any data from the WS,
'bytes' is -1 and is unsuitable for creating
a std::string instance from, as it throws.
Make failure in this case more informative
with proper assertion.
Change-Id: I8966b922aa0053502c58b528005602193b0593c1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
invokeWSDTest is called in an exception-safe scope
and logs errors before failing tests. No need to
have the same logic here.
Also improve the exception handling and reporting
in the fetchClipboardAssert helper.
Change-Id: I306aedc3f50f93bf8a5448f1d098e5ce884ceb37
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
The assertion will include much more info than
simply flagging for failure, which helps in
troubleshooting failures.
Change-Id: I6bd649e5334a90e9feaf0d72347790088f70c1b3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Templates were downloaded by Core
upon loading. This works fine, as
long as there is no special network
setup in loolwsd. However, when
loolwsd has a complex network setup,
such as when using reverse proxies,
Core wouldn't know about the details
and would likely fail to download
the template.
Luckily, there is no reason to rely
on Core for downloading templates.
Instead, we download it in loolwsd,
just like any other document, and
load it in Core as normal. The
remaining post-load saving of
templates remain unchanged.
Change-Id: Ib22ada4ae469863d5e5c8baeee27f667f7cd40ff
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
These are not needed to be executed on an ongoing
basis, only when modifying the http code.
As the external service is only used to verify
the initial implementation, it will also get
replaced with an internal (loopback) one.
Disabling for now to avoid noise when randomly
failing, due to network or other reasons.
Change-Id: I54f5203c39e48ba442313698d519b035200b41e5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
The last enumerator in Poco::Net::HTTPResponse::HTTPStatus is 511.
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Id183916729c8d13f63fe0d6e0d7ca7e84c8afaeb
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>