Commit graph

4039 commits

Author SHA1 Message Date
Ashod Nakashian
6486977ca7 loolwsd: cleanup testEachView
Change-Id: I5f2b6bf0f437b27c536fee9d1020b616a4ea215f
Reviewed-on: https://gerrit.libreoffice.org/30195
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-23 21:00:59 +00:00
Ashod Nakashian
58bf5bbf37 loolwsd: throw on unexpected errors in getResponseMessage
Tests should read errors and parse them if they are
expected. Otherwise, we should not ignore them and move
on, because they are (by the above definition) unexpected.

Change-Id: I9d7a9fb23879044ac4f11461e92c5f6fd6b03fa1
Reviewed-on: https://gerrit.libreoffice.org/30194
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-23 21:00:22 +00:00
Ashod Nakashian
85c1a0d868 loolwsd: no warning for a fairly common case
Change-Id: Ic461de074295eda4f15b6b7a8f787fc2624908ce
Reviewed-on: https://gerrit.libreoffice.org/30193
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-23 20:59:43 +00:00
Ashod Nakashian
77dde6ea71 loolwsd: ltrim returns the output to pass result as argument
Change-Id: Idc49996f5e24d634fefdc20a15d69c550c9df6ac
Reviewed-on: https://gerrit.libreoffice.org/30192
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-23 20:59:19 +00:00
Ashod Nakashian
027da26b5b loolwsd: kill redundant function
Change-Id: I8ef30205794c13e5b89e9f32ba0ec17df4441ef4
Reviewed-on: https://gerrit.libreoffice.org/30191
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-23 20:59:00 +00:00
Ashod Nakashian
452888060d loolwsd: cleanup and improve getResponseMessage
Proper parsing of incoming messages and better
prefix matching is done, as well as slightly
better logging when we timeout or hit exceptions.

Change-Id: I11adbf24a5505f6cda4a18ba855898dc5f82e238
Reviewed-on: https://gerrit.libreoffice.org/30190
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-23 20:58:45 +00:00
Ashod Nakashian
e5c9f61dd4 loolwsd: log possible document modifying calls in LOKit wrapper
Change-Id: I439460347c598a54af74d264dbde2670cf3542ac
Reviewed-on: https://gerrit.libreoffice.org/30189
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-23 20:57:35 +00:00
Ashod Nakashian
1a0ba1e41b loolwsd: remove redundant log entry for each recieved message
Change-Id: Ia072388cdc52271d3c3578a39614a9e390380c6f
Reviewed-on: https://gerrit.libreoffice.org/30188
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-23 20:57:14 +00:00
Ashod Nakashian
5c7905d4cc loolwsd: when parsing messages don't parse binary data
The last key=value entry of a message with binary payload
will not be parsed with space alone, since it is followed
immediately by a new line.

To parse these cases correctly we need to break at newline
as well.

Change-Id: I43fff48362a69dc91f36860014d49d128c0edb68
Reviewed-on: https://gerrit.libreoffice.org/30187
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-23 20:57:03 +00:00
Ashod Nakashian
167f0bf70c loolwsd: throw an exception rather than rethrow nothing
Change-Id: I1b85978d3049b39a15fded31582c2d6a62d90689
Reviewed-on: https://gerrit.libreoffice.org/30186
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-23 20:56:22 +00:00
Andras Timar
660eeab9da Pootle server times out with IPv6 address... 2016-10-23 16:44:56 +02:00
Andras Timar
a502371c27 loleaflet: updated uno command translations 2016-10-23 16:01:52 +02:00
Henry Castro
ea45bdb1f9 loleaflet: add hide/show row/column to header context menu 2016-10-23 08:44:04 -04:00
Michael Meeks
fe3e726211 Work around race in admin unit test. 2016-10-22 17:09:39 +01:00
Michael Meeks
b6291f9cb5 Unit tests new-style now search for a free port pair. 2016-10-22 16:43:42 +01:00
Michael Meeks
f8746373a7 Handle exceptions during websocket shutdown. 2016-10-22 16:43:42 +01:00
Michael Meeks
0b93441eff Improving the built-in unit tests.
Connect sockets to the local process using the details we can introspect.
Implement unit test for storage / load failure.
Cleanup tile-cache test a little.
2016-10-22 16:43:41 +01:00
Michael Meeks
dcd68c1850 tests: re-direct output to the console for unit tests, to make logs useful. 2016-10-22 13:09:28 +01:00
Pranav Kant
ba23ab2927 loleaflet: Expose some context menu item for comments
Change-Id: I242755c67f904ffbaaac63db24d735a9bfaa6bca
2016-10-21 23:34:49 +05:30
Michael Meeks
715b5c0101 Visible user error on unit test timeout. 2016-10-21 17:30:01 +01:00
Michael Meeks
ae04deada8 Restore ability to inject prisoner requests. 2016-10-21 17:30:01 +01:00
Michael Meeks
15d090a0b0 Define TDOC globally. 2016-10-21 17:30:00 +01:00
Michael Meeks
c015fecb2c Improve logging of WOPI protocol errors. 2016-10-21 10:17:40 +01:00
Andras Timar
2e12fade82 Updated Slovenian translation 2016-10-20 22:39:22 +02:00
Ashod Nakashian
693d6ccdbf bccu#2104 - writer: undo/redo doesn't invalidate properly
Change-Id: I9b3ee76cfde2c15ae59bb393070224c9f14ab586
Reviewed-on: https://gerrit.libreoffice.org/30109
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-20 15:14:21 +00:00
László Németh
7f72553236 loleaflet: traffic log and automatic typing in tile debug mode
- show outgoing and incoming network messages with some
  highlighting in Javascript console (default in tile
  debug mode)

- add optional automatic typing

- add layer controls for overlays and automatic typing

- differentiate rectangle borders (newer is more opaque)

- fixes:

  - fix function call at cancelled tiles

  - hide all attribution control when disabling debug mode
2016-10-20 16:25:05 +02:00
Henry Castro
e189f60ad4 loleaflet: refocus map due drop down insert table 2016-10-20 09:31:27 -04:00
Pranav Kant
49f4e696e5 loleaflet: Click user item to go to its cursor
Change-Id: Iac87da20cfe422000eb9a32ccad50e8483637616
2016-10-20 17:22:36 +05:30
Andras Timar
0cdc9d70b5 loolwsd: fix error: declaration of ‘isLoaded’ shadows a member of 'this' [-Werror=shadow] 2016-10-20 11:03:24 +02:00
Pranav Kant
9f69359b33 loleaflet: Disable these toolbar buttons too, in readonly mode
Change-Id: I8bc661dd3cfd689c7c7ded367deacdba853153e4
2016-10-19 21:08:33 +05:30
Pranav Kant
1be2a78564 Handle WOPI's UserCanWrite to determine readonliness
permission= parameter in URL is still supported, but overridden
by UserCanWrite parameter.

Also, introduce a new protocol message, perm: which dictates
loleaflet about the permission rather than the other way around
(only in case of WOPI)

It is to be noted that by default loolwsd assumes very
restrictive permissions, so not providing UserCanWrite in WOPI
implementation by a WOPI host would lead to opening of only
readonly session.

Change-Id: I2013c1661fd491c79bb367a41e1a7036fa03f984
2016-10-19 20:47:20 +05:30
Pranav Kant
ef32f30017 loolwsd: Fix a crash due to invalid fileinfo
Throw if document load fails. Ignoring such a scenario would lead
to crash later in the document load process.

Change-Id: Ie80fc4f26e08e4920d4c04726f947edd2837a0cf
2016-10-19 15:51:29 +05:30
Andras Timar
1f2be91009 loleaflet: updated port files 2016-10-19 11:53:18 +02:00
Michael Meeks
8d4c5d4e68 Avoid deadlock when notifying users of document load failure. 2016-10-18 21:51:33 +01:00
Tor Lillqvist
ece9740926 Use LOOLProtocol::getAbbreviatedFrameDump() 2016-10-18 17:00:45 +03:00
Tor Lillqvist
24442a080c Introduce LOOLProtocol::getAbbreviatedFrameDump()
Produces a human-readable logging string describing a LOOL protocol
frame. To be used for re-factoring snippets of similar code that
sometimes print also the flags, sometimes pointlessly print the
(binary) contents of a CLOSE frame (as if it was text), etc.
2016-10-18 16:57:14 +03:00
Tor Lillqvist
53b718844f Add a FIXME for some sillyness
One thing works mainly by accident, another is inefficient.
2016-10-18 16:32:04 +03:00
Tor Lillqvist
b0c870cbeb Expand documentation for getAbbreviatedMessage()
It has always been the intent that getAbbreviatedMessage() is for
producing human-readbale nice output for logging purposes only. But
this has not been mentioned, so (naturally) the function has been
misused. Sigh.
2016-10-18 16:26:30 +03:00
Tor Lillqvist
e87cf1e5d8 Adapt to new URI format in the GET request 2016-10-18 12:29:05 +03:00
Tor Lillqvist
38ccbd0196 We can use LoolException::toString() in one more place 2016-10-18 09:45:02 +03:00
Tor Lillqvist
620c08a32d Bin pointless copy-pasted (?) code snippet
We did not use the 'request' variable for anyhthing.
2016-10-18 09:09:13 +03:00
Tor Lillqvist
b02a917f0a Introduce LoolException::toString() to avoid a few std::string casts
Also consistently cast the call of std::exception::what() and not a
string literal being conatenated with that.
2016-10-18 08:40:04 +03:00
Tor Lillqvist
72133868b5 Use correct function name in some log messages
These Log::foo() calls are in ClientRequestHandler::handleClientRequest(),
not in ClientRequestHandler::handleRequest().

Actually I wonder why we show the name of the function in this handful of
places. We don't do it in general. Consistency, bah.
2016-10-18 08:39:24 +03:00
Tor Lillqvist
32b33ee685 Add logging of NumDocBrokers and the size of the DocBrokers array
I fear they get can out of sync when HTTPCrashTest::killLoKitProcesses()
kills a loolkit process, and this then causes HTTPWSError::testMaxDocuments()
to fail. This is to help debugging that.

Haven't fully understood what is going on yet. But one thing is sure:
It is a bad idea to duplicate the same state information in two
places, we shouldn't really use that separate NumDocBrokers
variable.

Probably also NumConnections tracks state that can easily be
calculated from the data structures, but maybe NumConnections does not
that easily get out of sync.
2016-10-18 08:06:16 +03:00
Tor Lillqvist
970259d170 killLoKitProcesses() already calls countLoolKitProcesses(0)
No need to immetiately call it again in testBarren().
2016-10-17 22:11:39 +03:00
Tor Lillqvist
a3236497a8 Fix HTTPWSTest::testConnectNoLoad
The waiting for the expected number of loolkit processes after that
test never succeeded. That apparently was caused by the fact that the
loolwsd process is waiting for up to COMMAND_TIMEOUT_MS (five seconds
currently) for an auto-save of the document to succeed, and that never
happens in this case.

countLoolKitProcesses() on the other hand was waiting only a bit over
three seconds (calculated in a complicated way from POLL_TIMEOUT_MS
and a few magic numbers) for the number of loolkit processes to reach
the expected number. Or something like that.

COMMAND_TIMEOUT_MS=5000 and POLL_TIMEOUT_MS=COMMAND_TIMEOUT_MS/10 =>
500. We used to have in countLoolKitProcesses():
sleepMs=POLL_TIMEOUT_MS/3 => 166 and repeat=(3000/sleepMs)+1 =>
19. 19*166 => 3154.

Fix by calculating the max time to wait for the expected number of
loolkit processes in countLoolKitProcesses() in a different way, so
that it is always longer than COMMAND_TIMEOUT_MS.
2016-10-17 22:11:05 +03:00
Tor Lillqvist
bb36ca79d4 Attempt to handle unauthorized WOPI usage better
Use the previously unused UnauthorizedRequestException for this, and
throw a such in StorageBase::create() when the WOPI host doesn't match
any of those configured.

In a developer debug build, without access to any real WOPI
functionality, you can test by setting the FAKE_UNAUTHORIZED
environment variable and attempting to edit a plain local file:
URI. That will cause such an exception to be thrown in that function.

Catch that UnauthorizedRequestException in
ClientRequestHandler::handleGetRequest(), and send an 'error:
cmd=internal kind=unauthorized' message to the client. Handle that in
loleaflet in the same place where the 'error: cmd=internal
kild=diskfull' message is handled, and in the same fashion, giving up
on the document.

Actually, using exceptions for relatively non-exceptional situations
like this is lame and makes understanding the code harder, but that is
just my personal preference...

FIXME: By the time StorageBase::create() gets called we have already
sent three 'statusindicator:' messages ('find', 'connect', and
'ready') to the client. We should ideally do the checks we do in
StorageBase::create() much earlier.

Also consider that ClientRequestHandler::handleClientRequest() has
code that catches UnauthorizedRequestException and
BadRequestException, and tries to set the HTTP response in those
cases. I am not sure if that functionality has ever been exercised,
though. Currently, we upgrade the HTTP connection to WebSocket early,
and only after that we check whether the WOPI host is authorized
etc. By that time it is too late to return an HTTP response to the
user. If that even is what we ideally should do? If not, then we
probably should drop the code that constructs HTTP responses and
attempts to send them.

Also, if I, as a test, force an HTTPResponse::HTTP_BAD_REQUEST to be
sent before the HTTP connection is upgraded to WebSocket, loleaflet
throws up the generic "Well, this is embarrassing" dialog anyway. At
least in Firefox on Linux. (Instead of the browser showing some own
dialog, which I was half-expecting to happen.)
2016-10-17 19:34:04 +03:00
Tor Lillqvist
b29ae3c032 Sort lines for clarity 2016-10-17 19:34:04 +03:00
Pranav Kant
8ab4682a71 loolwsd: Fix handling of CPPUNIT_TEST_NAME in external test-suite
Doing a plain CPPUNIT_TEST_NAME='somettest' make check will
result in executing all the tests in external test suite. This is
a problem when one wants to execute only internal tests (unit-*
ones) as test harness first executes those followed by all of the
tests in external test-suites.

Lets execute all the tests only when no CPPUNIT_TEST_NAME is
provided, and ignore when it is provided but no match is found.

Change-Id: I7e40b6f3124e6965a86cfb6395d246df3b5c17ba
2016-10-17 21:21:54 +05:30
Pranav Kant
be1e49715c loolwsd: Bring this test back to life
There doesn't seem to be any failure on this test anymore.
Consecutive 20 runs of this test gives no failure, so lets enable
it again.

Change-Id: I77ddd1c36d18162bdc75fd24d51c1a2df22f749d
2016-10-17 18:34:22 +05:30