Commit graph

877 commits

Author SHA1 Message Date
Ashod Nakashian
acdce2e72f wsd: check if SysTemplate is writable once per update
Change-Id: I3bc77eaf42cc84e7e5b6365f7fc446ea38df5dc0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-10 07:45:12 -05:00
Ashod Nakashian
d0ed6cd3d2 wsd: test: do not start the next test if test is not finished
Change-Id: Ibdcf66f9a037f6b4e2e575cb61fe1459c912e44f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-10 07:45:12 -05:00
Noel Grandin
6cb5570b87 no need for shared_ptr here
avoid an allocation and some pointer chasing

Signed-off-by: Noel Grandin <noel.grandin@collabora.co.uk>
Change-Id: I29711075d4bf840c2ef992341a6dadeeb87c6edd
2023-03-07 14:46:59 +01:00
Ashod Nakashian
990f8f2375 wsd: support logging without a prefix from static members
Change-Id: Id9105f1a066e290ae20f8409c8fe6bd003678192
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-06 08:43:37 -05:00
Patrick Luby
8418a033fe Fix issue #5840 by not using base64 encoding for PNG data
The new delta messsage feature expects PNG data to be unencoded or zstd
compressed only.

Signed-off-by: Patrick Luby <patrick.luby@collabora.com>
Change-Id: I776fb8e79fc9617edc5178ec66d6f0bac0706c71
2023-02-20 21:33:46 +01:00
Tor Lillqvist
31135177e4 Fix compiler warnings when building for WASM.
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I0fd4fe36cece9caaeb076a0e91894890186706d0
2023-02-12 15:55:24 +01:00
Tor Lillqvist
70baa3a467 Avoid CodeQL warning
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I17bb678d0bc977b4355745142f4ccc882652a677
2023-02-10 16:28:21 +01:00
Ashod Nakashian
318f3f6eb8 wsd: more accurate possible-modification flagging
This improves the flagging of possible-modification
in cases where there might be a race between the
arrival of the ModifiedStatus flag from Core
and the closing of the document. This can happen,
for example, when the user makes an edit and
immediately closes the document. In these cases
we want to be able to assume modification based
on the last activity from the user that may have
modified the document.

The issue this patch fixes is that we were too
aggressive in our assumption of modification,
because it was better to be wrong and try to
save rather than not. However, this also set
the IsModifiedByUser header to the PutFile
request when uploading the document to storage,
which was not accurate or acceptable.

Change-Id: I84228bfbb92f688d303568027171df3686d2cd2b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-02-07 14:36:51 +01:00
Ashod Nakashian
0f9dc9460b wsd: support per-user timezone
Change-Id: I5e2318a34cb39d8d56ec3cf4977ebd75588a7627
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-31 15:38:08 +01:00
Ashod Nakashian
92c36dadd9 wsd: test: start next test only after destroying the current
Change-Id: I6924ff288fddd1ad5315b2bf19345d541682bc92
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-30 07:52:08 -05:00
Ashod Nakashian
7569f2bcd2 wsd: test: wrap DocBroker destroy callback
This prepares to start the next test
when the DocBroker of the current one
is destroyed.

Change-Id: I3a9672d8d03ad497f15a9bca262dfe1d4f197e41
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-30 07:52:08 -05:00
Szymon Kłos
b0dd943089 Add export as pdf
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I61853fb2213e57acd02d7a3eee53e86f43cb36b5
2023-01-26 13:06:57 +00:00
Tor Lillqvist
b1d43c395a Leave ThreadPool max concurrency at 2 for Emscripten
The default would be std:🧵:hardware_concurrency() which can be
ridiculously high for the WASM case.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I77902a58b96248d7afe638a039886712516fe905
2023-01-26 00:13:07 +02:00
Ashod Nakashian
87d33d123b wsd: test: new onDocumentUploaded event
Change-Id: Ia12446f1958b6df41231f5fcca4fb3e50ab07aaf
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-23 11:07:55 -04:00
Ashod Nakashian
8003833a84 wsd: test: better UnitWOPIAsyncUpload_Modify
We now upload 3 times to succeed.

This simulates a user modifying and saving
twice before giving up and closing the
document, which succeeds in uploading.

Change-Id: Ida40f79a76fc94436c0d4b4fc1ad3e7b7acc997b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-23 11:07:55 -04:00
Ashod Nakashian
db50626aff wsd: test: refactor BaseUnit self-test
The BaseUnit test didn't belong to UnitTimeout
and, more important, it needed access to
private members to both validate their state
and to reset them (since the test is artificially
initializing both WSD and Kit tests and cannot
uninitialize them, lest we unload ourselves).

As such, the self-test is now internal to
BaseUnit, with the added bonus that it
is called on all tests and not just UnitTimeout.

Also, more assertions have been added.

Change-Id: Ieaf60594f39e978a7250407262bd8bbc9b642c43
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-23 11:07:55 -04:00
Michael Stahl
9b40d40713 WASM fix includes in C++ code
Emscripten is very opinionated about sys/poll.h so use poll.h instead.

Signed-off-by: Michael Stahl <michael.stahl@allotropia.de>
Change-Id: I9691519e27a080f03a19f0cc0dd8f796fe323062
2023-01-09 22:01:47 +02:00
Szymon Kłos
85ada3b6f8 Add UserPrivateInfo
it will be used to store user data which shouldn't
be shared between views

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I58b7f22e4364ce9e07bb6cc74e8431363912a872
2023-01-06 10:36:43 +01:00
Ashod Nakashian
1b059bca0f wsd: better log levels
We no longer emit a fatal (FTL) log when
forced-exiting successfully.

Also, improved are some other logs to
better reflect the severity of the issue.

Change-Id: I22e79f685825f7ecd47cec76c9be9683deff2d55
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-21 19:41:38 -05:00
Ashod Nakashian
115b9cf2ab wsd: support isWritable flag in Session
We need to differentiate between a document
that cannot be edited (due to permissions)
and Storage being read-only.

The distinction isn't always important,
except when readonly is set either by
the client side permissions, or is due
to opening a view-only document (such as
a PDF). Since for a view-only document,
adding and editing comments might be
allowed, while the document is read-only
and cannot be otherwise edited, we
still need to upload it to storage.
This is to preserve the changes done
to comments.

Since we need to differentiate between
read-only Storage vs the above cases,
we use a new flag in Session: isWritable.

Change-Id: I028e7908db7f0f10e5407a45c71d89aaab858390
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-14 20:30:11 -05:00
Ashod Nakashian
2b7e2bda96 wsd: move isWritable to Session and rename
This helper is only true if editing of the document
is enabled and not whether or not the document is
writable in storage. Since it unifies isReadOnly
and isAllowChangeComments, which are in Session,
there is no advantage in having it in ClientSession.

It is now renamed to isEditable in Session.

Change-Id: Ib923b6162a8075be145049bc1442c42479c8ce4b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-14 20:30:11 -05:00
Ashod Nakashian
6b29335ccf wsd: support short-form names in STATE_ENUM
In some cases we don't really need the full
name of an enum, with the enum as namespace.
For those cases, we now support nameShort
and toStringShort.

Change-Id: Iddd383e15d900bb2d2f3d77e3de6a09470d51b62
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-14 04:38:26 -05:00
Ashod Nakashian
13b1534f16 wsd: test: cleanup exitTest logs
There is no reason to print the test name
explicitly when each log entry is already
prefixed by the test name.

Change-Id: I72c0a0f2989a65f477902b97e6be816446fba5c3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-12 08:00:05 -05:00
Ashod Nakashian
0a90349f33 wsd: test: correctly calculate test timeout
Now that we may have multiple tests in a
given Test Suite (i.e. a since unit-test
.so module), it is important to calculate
the timeout not from the total elapsed
time, but form the start of the *current*
test.

To that end, we capture the start time
on the first checkTimeout call, which
gives us the elapsed time from the very
start of the Test Suite. Using this, we
offset the elapsed time to arrive at
the time the current test consumed.

Change-Id: I01ebc3572bc147a3dabac7e1fb3237ea6d479116
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-12 08:00:05 -05:00
Ashod Nakashian
798712301f wsd: test: support keepgoing option
Change-Id: I397e9225972e5b50b5b9c91b44ba75bc829bfb04
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-12 08:00:05 -05:00
Ashod Nakashian
8051543a51 wsd: test: proper test options
Change-Id: Icfe5125b8fcf1ec902fff19c594cd1ffa598de71
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-12 08:00:05 -05:00
Ashod Nakashian
0146f65c7c wsd: test: minor cleanup in UnitBase
Change-Id: I2e857456895e8070ec9d2479e526186d411191b2
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
Andras Timar
a077c4288b Put all Zotero logic to browser
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Ib1b071b96322511b7f319ff6b851e902b3556fbb
2022-12-12 13:35:29 +01:00
Ashod Nakashian
d01b73456c wsd: catch mounting exceptions to fallback
In some cases mounting fails on /tmp, which
should be writable. This results in Poco
exception when trying to write to it during
mounting.

This catches exceptions and fails gracefully
to enable falling back to copying.

Change-Id: I38c8db4f452767ee43bb20a98d13bd5cc36fdba2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-07 17:33:11 +03:00
Ashod Nakashian
54eedce089 wsd: support invalidating Authorization objects
Change-Id: Ia2327157cdbc27ac545f8137a41dbf75897b22a1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-07 15:42:04 +03:00
Pranam Lashkari
2cfae369af initial zotero skeleton
add zotero UI only if user is logged in
when zotero citation edit button is clicked,
fetch the library with zotero API.
Let user select what to insert

at this stage its not a complete solution but just first stage

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: Id67d8409bcd6416994713acd9ace495b24823fb0
2022-11-30 20:37:48 +01:00
Ashod Nakashian
49aec68f11 wsd: test: logging
Change-Id: I820e3ddbdb38cdde2ee34c144c08866ab6720495
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:55 -05:00
Ashod Nakashian
42ce410ff2 wsd: test: fix rare deadlock on stopping
Since UnitBase (and children) are invoked from
different threads, UnitBase::exitTest could
have a race. This ultimately results in
invoking std:🧵:join() concurrently,
which is unsafe. This can result in the
following deadlock.

In this case websrv_poll had invoked
UnitBase::exitTest concurrently and
evidently finished, leaving the main
coolwsd thread deadlocked.

	(gdb) info thread
	  Id   Target Id                                     Frame
	* 1    Thread 0x7f67528f0840 (LWP 4058508) "coolwsd" __futex_abstimed_wait_common64 (private=128, cancel=true, abstime=0x0, op=265, expected=4058510, futex_word=0x7f675285c910)
		at ./nptl/futex-internal.c:57
	(gdb) t a a bt

	Thread 1 (Thread 0x7f67528f0840 (LWP 4058508) "coolwsd"):
	#0  __futex_abstimed_wait_common64 (private=128, cancel=true, abstime=0x0, op=265, expected=4058510, futex_word=0x7f675285c910) at ./nptl/futex-internal.c:57
	#1  __futex_abstimed_wait_common (cancel=true, private=128, abstime=0x0, clockid=0, expected=4058510, futex_word=0x7f675285c910) at ./nptl/futex-internal.c:87
	#2  __GI___futex_abstimed_wait_cancelable64 (futex_word=futex_word@entry=0x7f675285c910, expected=4058510, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=128) at ./nptl/futex-internal.c:139
	#3  0x00007f67529cd6a4 in __pthread_clockjoin_ex (threadid=140081742857792, thread_return=0x0, clockid=0, abstime=0x0, block=<optimized out>) at ./nptl/pthread_join_common.c:105
	#4  0x00007f6752d42337 in std:🧵:join() () from /lib/x86_64-linux-gnu/libstdc++.so.6
	#5  0x000055775c5fa8e0 in SocketPoll::joinThread (this=0x55775cc9b090) at net/Socket.cpp:282
	#6  0x000055775c5c8121 in UnitBase::endTest (this=this@entry=0x55775cc0fe80, reason="") at common/Unit.cpp:545
	#7  0x00007f67528df61f in UnitWSDClient::endTest (this=0x55775cc0fe80, reason="") at ./UnitWSDClient.hpp:118
	#8  0x000055775c5cc4d1 in UnitBase::exitTest (this=0x55775cc0fe80, result=result@entry=UnitBase::TestResult::Ok, reason="") at common/Unit.cpp:486
	#9  0x00007f67528d1fa3 in UnitWOPIFileUrl::invokeWSDTest (this=0x55775cc0fe80) at UnitWOPIFileUrl.cpp:269
	#10 0x000055775c4accdb in UnitWSD::invokeTest (this=0x55775cc0fe80) at ./common/Unit.hpp:318
	#11 0x000055775c4a38cd in COOLWSD::innerMain (this=0x7ffd34248650) at wsd/COOLWSD.cpp:5459
	#12 0x000055775c4a59db in COOLWSD::main (this=<optimized out>) at wsd/COOLWSD.cpp:5706
	#13 0x00007f6753ab0877 in Poco::Util::Application::run() () from /lib/libPocoUtil.so.80
	#14 0x000055775c48316c in main (argc=14, argv=0x7ffd34248898) at wsd/COOLWSD.cpp:5845

Change-Id: If6162690462719f14a35241604f8a59b38a806c0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:55 -05:00
Ashod Nakashian
ed6254ac36 wsd: test: capture the original test result
Change-Id: I7818bdac0350a1afce81266093cce32d9796bba8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:55 -05:00
Ashod Nakashian
6c697b0cfd wsd: test: convert TestResult to STATE_ENUM
Change-Id: Ic1a7a24e35edd7a403fabe6be040b7e28b12eb79
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:55 -05:00
Ashod Nakashian
397d41a00b wsd: test: remove returnValue overrides
These only served to delete the Unit singletons,
but since we have GlobalArray, deleting them
isn't needed.

Change-Id: Ia2e53a1e3b43707196f45c06c38c6bb664c18e29
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:55 -05:00
Ashod Nakashian
f6301194ae wsd: test: add endTest to clean-up tests
Change-Id: I6d97471a5ab60682da8f01675cddbd766a2c0ba9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:55 -05:00
Ashod Nakashian
92ccdcdeb8 wsd: test: wakeup world when starting a new test
This is needed so we stop the DocBroker of
the old test, which is now finished.

Change-Id: I05df85fbbeca254928cd9a140198e7f4ae89fec8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:55 -05:00
Ashod Nakashian
0ff29b4157 wsd: clang-tidy: suppress bogus assert diagnostics
Clang-tidy thinks, incorrectly, that an
assert(false) can be replaced with static_assert.

While the assert(false) in question is a trap
for code paths that shouldn't happen,
static_assert is a compile-time check that
has nothing to do with the execution path.

Since the assert in question is used in a
macro, it shows up countless times where
said macro is used. This silences it.

Change-Id: I19b35da6332a06335cc83b0584505a42741de97f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:34 -05:00
Ashod Nakashian
432bec03e7 wsd: test: do not invoke WSD test when finished
Change-Id: I46b056c58ba6b214ab5a6099735767490b672ffc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
cccf7aa0be wsd: test: filter subsequent tests
Apply the test filter on all tests,
not just the first.

Change-Id: Ib34e90e883f5de2ddcf04c710f433cb54677575d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
5b45b2807f wsd: test: invoke configure for each test
Now that we may have multiple tests in a
single unit-test module, we should call
UnitWSD::configure for each one, not just
once at the start. Each test can modify
the configuration settings to meet its
test conditions.

Change-Id: I08de2d998edee5b4cbade08f2496196b596a8600
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
dad2b5e92a wsd: test: capture the reason in exitTest
When invoking exitTest it's useful to know
something about the reason. Whether it's
because the test passed or timed out,
it's useful to log this information.

Change-Id: I8e8ae525b7c2ef1de2e394d08107341cdc87c008
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
672c958b89 wsd: test: log all test names before running
Now that multiple tests and filtering are
supported, it's useful to know what tests
exist in each unit-test module.

Change-Id: Ifaa7eccabab6b23a57edf2786c0cd726ab0265db
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
57456f7ff6 wsd: test: filter tests using COOL_TEST_OPTIONS
Using the envar COOL_TEST_OPTIONS, which is
provisioned to support other options than
just filtering, it is now possible to
only run the tests with names partially
matching the filter's case-insensitive
string.

Change-Id: I6168887677fd0fddd72bac2538837615b10b9fae
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
a124356031 wsd: test: fail -> onDataLoss
The event we trigger when we detect data-loss
is best named to reflect that fact.
And since we can override the behavior,
for example if the test expected to trigger
the data-loss detection, then we can signal
the non-failure by the return value.

Change-Id: I67ca69ae783c956cfdd14d54dab5efb7cc3d258c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
e969859ef3 wsd: test: log test start and finish visibly
Change-Id: Ie374f5d617db188faa24066d494c91f4f5d49c60
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
c652757724 wsd: test: return the correct type from hooks multi
Change-Id: I057c90e9b4d5f749ff0dda74a5aa20f3afc3b24f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
3f926b488b wsd: detect json arrays in messages
So far, we assumed only json objects are
used, but that's only because we didn't
have arrays. This adds support for detecting
both json arrays and objects alike.

Change-Id: If91bf092ab95869298e90e4f071505471ab1db19
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-20 07:50:12 -05:00