Commit graph

573 commits

Author SHA1 Message Date
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
Ashod Nakashian
39e69e8168 wsd: test: improved UnitWOPIDocumentConflict
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>
2020-12-28 12:04:53 -04:00
Ashod Nakashian
b3366cfef0 wsd: test: better logging in WopiTestServer
Change-Id: I8e33172d5c474c1d56e0af214f7a6281510d0836
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-28 12:04:53 -04:00
Ashod Nakashian
7972ded44f wsd: test: log test assertions
Change-Id: Ibf9274b1812f70f54ccd4e7be991b08a11f36c86
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-28 12:04:53 -04:00
Ashod Nakashian
64251966d5 wsd: test: use LOG_TST in new-style tests
Change-Id: I0d4558d44bc6cb92ba820ae8471d7ed2528277fc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-28 12:04:53 -04:00
Ashod Nakashian
3b4add03ef wsd: test: store the current test name in UnitBase
Change-Id: Iaf521f6a99dcd6e6465769aed7f3757332e04f7d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-28 12:04:53 -04:00
Ashod Nakashian
b4d9e1f413 wsd: test: use chrono types
Change-Id: Iec7f64a122126ae82af3bf16719081ea4ee645f3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-28 12:04:53 -04:00
Ashod Nakashian
9bbd273e91 wsd: test: leverage the log system in TST_LOG
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>
2020-12-28 12:04:53 -04:00
Ashod Nakashian
13d7d23cbe wsd: use chrono for readability and conversion safety
Change-Id: If5d478605fef0199b331d91310673a460e70d48e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-22 11:24:13 -05:00
Ashod Nakashian
693ac2fa52 wsd: logs and const
Change-Id: Id7e4f81ab9709b62eddfa747479ab593a5ad45a2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-22 11:24:13 -05:00
Ashod Nakashian
583c627a66 wsd: avoid single-character strings
Change-Id: I709e8e797bc5e68984823d8c46c590e109d23f18
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-12-09 17:19:58 +01:00
Gabriel Masei
99c9ac1723 wsd: allow different UI mode for different views
Signed-off-by: Gabriel Masei <gabriel.masei@1and1.ro>
Change-Id: Icad28de7a75a6392cafb4fd3385e564616ece499
2020-12-09 15:46:24 +01:00
Ashod Nakashian
ba4e52e7b9 wsd: log: overload chrono duration to simplify logging
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>
2020-12-08 09:26:41 +00:00
Ashod Nakashian
47630f826e wsd: use steady_clock for measuring time interval
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>
2020-12-08 09:26:41 +00:00
Michael Meeks
4082975330 Fix unit test to not rely on under-defined behavior.
Change-Id: I4ad9ce7710f7f25884ca2ab31aabd82e2dc5be8e
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2020-11-29 19:27:23 -05:00
Ashod Nakashian
b87495a791 wsd: test: add Buffer test and minor cosmetics
Change-Id: Ie4ac80984523ecd32fd81238496253b6a4015692
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-29 19:27:23 -05:00
Ashod Nakashian
fad4222a2a wsd: move convert-to docs into the jail
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>
2020-11-23 21:29:34 -05:00
Ashod Nakashian
f665816812 wsd: getTempFilePath -> getTempFileCopyPath
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>
2020-11-22 22:26:36 -05:00
Ashod Nakashian
3724ab4e35 wsd: centralize temporary directory helpers in FileUtil
Change-Id: I9b55d0b8d4c55a68af4baa7e638627de6c73b64d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-22 22:26:36 -05:00
Ashod Nakashian
cb4beaca34 wsd: avoid the using keyword and use C++ size_t
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>
2020-11-15 15:41:41 -05:00
Ashod Nakashian
634dfdb098 test: improve failure details
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>
2020-11-15 14:19:12 -05:00
Ashod Nakashian
20f95a17a9 wsd: improved Stat modified-time and unit-tests
Change-Id: Ic6e7972e3d69c78681f599b6e6797e3e4164cd34
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-15 13:50:16 -05:00
Ashod Nakashian
0d031e19ef wsd: move HttpHelper namespace from Socket to its home
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>
2020-11-02 07:56:03 -05:00
mert
ffaf53d3ef Make Themeing related CSS vars UI Configurable
Change-Id: If6e4096dc37573ff116f218ceb4ca14135820ff7
Signed-off-by: mert <mert.tumer@collabora.com>
2020-10-30 11:20:00 +01:00
Ayhan Yalçınsoy
42c56919b3 Remove Poco/TimeStamp.h left-over part-2
Change-Id: I2d5ce91cab57fb0806f4edb7045207cf32de99bb
Signed-off-by: Ayhan Yalçınsoy <ayhanyalcinsoy@pisilinux.org>
2020-10-27 11:56:51 +03:00
Tamás Zolnai
7886d63349 cypress: remove php-proxy simulation.
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>
2020-10-26 19:28:31 +01:00
Ashod Nakashian
abf017ee5e test: tabs -> spaces
Change-Id: I8a9a98b84babf1100a8526e5a08c3f22e81c8d1e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-10-25 12:20:58 +01:00
Ayhan Yalçınsoy
1ef9ad4f56 Remove Poco::LocalDateTime left-overs
Change-Id: Ia847ec0f1b5602cfa0790b8702aa70e74ecec160
2020-10-24 23:52:11 +03:00
Pranam Lashkari
a992cfcd23 wsd: correction in conversion from timestamp to ISO8601
closes #168

Change-Id: Ibdb1aa72a6961d4707c2336382cc593c984d3615
2020-10-16 04:27:53 +05:30
Gabriel Masei
21373089c0 Unit test for skipping ModifiedStatus from deduplication
Change-Id: Ie20da2f0060b86c05b1f45e930f31ca5cab6d9fa
2020-10-07 16:16:54 +02:00
Ashod Nakashian
eb122ec0a0 wsd: allow URIs without access_header or access_token
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
2020-10-07 08:13:29 -04:00
Andrea Gelmini
9d01540680 Fix typos
Change-Id: I7d487f32ca43e19023760ef3c6bb1683607f93d1
2020-10-07 12:51:08 +02:00