Commit graph

604 commits

Author SHA1 Message Date
Ashod Nakashian
d15528ea91 wsd: http: improved whitebox http tests
Change-Id: I42cd2f6f8ea08923c9f0facab7a51f84bff7f524
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-22 10:09:22 -04:00
Ashod Nakashian
da07625352 wsd: http: parse the http header only
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>
2021-03-22 10:09:22 -04:00
Ashod Nakashian
f7d5428f3c wsd: test: better http tests
Change-Id: I9cb6b91790951dcb20ccd6f3f4746d66aed5b72b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-22 10:09:22 -04:00
Ashod Nakashian
56539c60ab test: don't use colored logging when output is redirected
Change-Id: I048dfb02fc37ae7be137ae7285758a89615b2dff
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-16 08:27:46 -04:00
Ashod Nakashian
c1cc2eacc8 wsd: test: LOK_ASSERT messages support ostream
Change-Id: I123348d51cb6a35080f323fb37119cfa382e0a52
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-16 08:27:46 -04:00
Ashod Nakashian
72e2b1ac9a wsd: http: better test assertions
Change-Id: Ifccbc6f7a85515ca1d372755df28409fa5d7a26b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-16 08:27:46 -04:00
Ashod Nakashian
ea9c483a28 wsd: http: StatusLine tests
Change-Id: Iac39191b407463d2691ec3c58af2a4b4abfc6645
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-16 08:27:46 -04:00
Ashod Nakashian
78fe04a58d wsd: better http poll thread name
Change-Id: I60a4ee09fcfb1bd34b44a21253ecac78f3d6830f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-16 08:27:46 -04:00
Ashod Nakashian
e7d336afbd wsd: test: HttpRequestTests improved
Change-Id: I143f2e172c6134a793839154e898ab3f63cf3390
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-16 08:27:46 -04:00
Ashod Nakashian
1517355747 wsd: test: WhiteBoxTests include cleanup
Change-Id: Ibddf5e0d6008c8d8684b3c7a329dc85d82efd22a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-16 08:27:46 -04:00
Ashod Nakashian
774afe1393 wsd: http::Request parser
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>
2021-03-16 08:27:46 -04:00
Ashod Nakashian
65f71a2efb wsd: better logging of hex data dumps
And guard http data dumping with debug directives.

Change-Id: I22a725ba49bfb0399a27889ce9732dfe061e2563
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-13 19:34:02 -05:00
Ashod Nakashian
5467a7f7ef wsd: simplify and document dumpHex
Change-Id: I636dd6548b0712a72dfc162eb7381e3e7ac18b5a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-13 19:34:02 -05:00
Ashod Nakashian
494161940b wsd: test: minor fix to Makefile
Change-Id: Iecfe38b598adf4f9ddea97a02fd2a7d64d23cbde
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-11 09:15:40 -05:00
Ashod Nakashian
96f542a3be wsd: resuable http test helpers
Change-Id: Ib3419ad221bf957fb04d1a8112a2b1dc2ea549bd
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-11 09:15:40 -05:00
Ashod Nakashian
c215f203dd wsd: test: use unique_ptr
Change-Id: Ia00d90d83ad35de56b2563e80b20b575325b5745
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-11 09:15:40 -05:00
Ashod Nakashian
b46ff5f985 wsd: test: improve unit-integration
Change-Id: I9b5f13012278c8f3e0f4e79a46d462faa76ba78c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-11 09:15:40 -05:00
Ashod Nakashian
b8c08b3e00 wsd: test: more informative test failure
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>
2021-03-11 09:15:40 -05:00
Ashod Nakashian
95bb52d945 wsd: test: better logging
Change-Id: I3d17afb2e76f1d4b2b27182a6419482801342e8c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-08 22:49:53 -05:00
Ashod Nakashian
a533627b5a wsd: test: improved logging
Change-Id: Iac80450cd88997572727ffe30e0b26737df96f46
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-08 22:49:53 -05:00
Ashod Nakashian
43eaf4d8df wsd: test: better exception handling in UnitCopyPaste
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>
2021-03-08 22:49:53 -05:00
Ashod Nakashian
6e88701702 wsd: test: assert when failing copy-paste test
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>
2021-03-01 21:50:18 -05:00
Ashod Nakashian
ff68273549 wsd: test: logging in copy-paste test instead of cerr
Change-Id: Ia80721179c37ef159cb0c8206ba13f650ad03244
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-01 21:50:18 -05:00
Ashod Nakashian
355850e7e7 wsd: test: improve Template test
Change-Id: I4b19580e9753133ba83ee64ce287ead3fe021ccb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-01 21:50:18 -05:00
Henry Castro
177fdf0330 test: run unit test with disabled capabilities
Change-Id: I78dbdcb1ec3d960b283016d86e95614a8cb0255c
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-02-26 11:13:47 -04:00
Ashod Nakashian
88cc2d58b6 wsd: test: http::Request with invalid host
Change-Id: I88196c38a49d7e70479ea4b1a077447560c001bd
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-22 14:24:36 -05:00
Ashod Nakashian
81da7c7bff wsd: download templates by wsd
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>
2021-02-15 09:41:17 -05:00
Ashod Nakashian
d83a203ebe wsd: simplify UnitWOPITemplate
Change-Id: I934223150a391c8fed3f87c8eb6ee2a196ae8932
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-15 09:41:17 -05:00
Ashod Nakashian
e6ece7dff6 wsd: add FileUrl tests
Change-Id: I7f9ba86ceb5a31f0133c0d36dee090348386ea95
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-02-09 10:45:37 -05:00
Ashod Nakashian
190141e942 wsd: test: disable external http regression tests
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>
2021-01-29 09:09:58 -05:00
Miklos Vajna
b04f498ff4 test: avoid http status 512 and higher when interacting with poco
The last enumerator in Poco::Net::HTTPResponse::HTTPStatus is 511.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Id183916729c8d13f63fe0d6e0d7ca7e84c8afaeb
2021-01-28 16:40:00 +01:00
Ashod Nakashian
24edfa2b62 wsd: test: move HttpRequestTests to 'make check'
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>
2021-01-26 20:02:04 -05:00
Tamás Zolnai
227b5f64fa Fix ENABLE_SSL condition.
Signed-off-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Change-Id: I0f6a4dac4aff05be65b5a0735b5ff0c67fc4f7a0
2021-01-26 14:40:46 +01:00
Ashod Nakashian
42f5ceae42 wsd: test: improvements
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>
2021-01-23 23:55:43 +00:00
Ashod Nakashian
72e9f3d2d6 wsd: asynchronous HTTP/1.1 implementation
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>
2021-01-21 12:36:41 +01:00
Tomaž Vajngerl
d92252522c Add hello-world for Draw
Change-Id: I4300c96d16c1e4911aabb5aeb1ec7181dfeeae1d
Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
2021-01-21 10:22:58 +01:00
Ashod Nakashian
ce3dd02ef3 wsd: new NetUtil file for network utilities
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>
2021-01-13 22:05:18 -05:00
Shubham Goyal
3a3867e1c6 Resolve #805 : Remove Mutex lock
Signed-off-by: Shubham Goyal <22shubh22@gmail.com>
Change-Id: I80da9d085590e67c0998ce971225a8c9903c0bb7
2021-01-13 16:55:35 +00:00
Ashod Nakashian
06c5c90dd5 wsd: test: support SSL in classic tests
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>
2021-01-13 08:07:06 -05:00
Ashod Nakashian
95a9c5aaee wsd: test: simplify sending commands
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>
2021-01-13 08:07:06 -05:00
Ashod Nakashian
3b8058d7ac wsd: test: make Version Restore test robust and simpler
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>
2021-01-13 08:07:06 -05:00
Ashod Nakashian
6db0d213bc wsd: test: make owner-termination test robust and simpler
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>
2021-01-13 08:07:06 -05:00
Ashod Nakashian
24f443ccf4 wsd: test: make UnitWOPI test robust and simpler
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>
2021-01-13 08:07:06 -05:00
Ashod Nakashian
ae9cc18212 wsd: test: make DocumentConflict test robus and simpler
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>
2021-01-13 08:07:06 -05:00
Ashod Nakashian
15b6ddccd0 wsd: test: move inherited filterSendMessage to onFilterSendMessage
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>
2021-01-13 08:07:06 -05:00
Miklos Vajna
ee37bd9c05 test: avoid garbage at the end of the message in getErrorCode()
'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>
2021-01-04 15:46:39 +01:00
Henry Castro
8a768e6554 test: makefile: fix build builddir!=srcdir
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>
2020-12-28 15:07:35 -04:00
Ashod Nakashian
2edbf1c5e1 wsd: test: check if a WS Close Frame message exists
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>
2020-12-28 12:04:53 -04:00
Ashod Nakashian
d2e29d592a wsd: test: httpcrashtest drain using the getErrorCode helper
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>
2020-12-28 12:04:53 -04:00
Ashod Nakashian
96c9e03b88 wsd: test: catch and fail WSD tests when exceptions are thrown
Change-Id: Ifaabb6387d86c5a80e00cd5de34093520a1e9d66
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-28 12:04:53 -04:00