Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #83: Refactor wopi controller #84

Merged
merged 70 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
26b6df2
Issue 83: Add some trailing commas on multi-line argument lists.
donquixote Jan 8, 2025
1df2c48
Issue 83: Return 404 instead of 403 for media not found.
donquixote Jan 8, 2025
aa7d28a
Issue 83: Fix ExceptionWopiSubscriber service by adding autoconfigure…
donquixote Jan 7, 2025
cfca92f
Issue 83: Refactor ExceptionWopiSubscriber, introducing local vars.
donquixote Jan 7, 2025
9efebde
Issue 83: Use wildcard loading for media entity in WopiController, bu…
donquixote Jan 7, 2025
3ec3c87
Issue 83: Pass the media entity directly to verifyTokenForMedia().
donquixote Jan 8, 2025
d431553
Issue 83: Always fail if token is missing.
donquixote Jan 8, 2025
0ac761b
Issue 83: Remove pointless local var $returnCode.
donquixote Jan 8, 2025
bc26320
Issue 83: Centralize the call to verifyTokenForMedia().
donquixote Jan 8, 2025
a451d9a
Issue 83: Centralize the user loading.
donquixote Jan 8, 2025
f00e9fe
Issue 83: Centralize the file loading.
donquixote Jan 8, 2025
3e07847
Issue 83: Centralize the can_write check.
donquixote Jan 8, 2025
13e7af9
Issue 83: Drop pointless local var $mimetype.
donquixote Jan 8, 2025
7516055
Issue 83: Extract buildSaveReason() from wopiPutFile().
donquixote Jan 8, 2025
2b12a09
Issue 83: Rename $payload -> $response_data.
donquixote Jan 8, 2025
ba48462
Issue 83: Rename $jsonPayload -> $response_json.
donquixote Jan 8, 2025
0e4d406
Issue 83: Use JsonResponse.
donquixote Jan 8, 2025
6b33eea
Issue 83: Return the response directly, drop the local var.
donquixote Jan 8, 2025
5063f45
Issue 83: Don't forget to switch back the account.
donquixote Jan 8, 2025
e9f85b7
Issue 83: Don't switch account in wopiGetFile().
donquixote Jan 8, 2025
b5d132d
Issue 83: Don't switch account in wopiPutFile().
donquixote Jan 8, 2025
99a6dde
Issue 83: Drop local vars in buildSaveReason().
donquixote Jan 8, 2025
6260a94
Issue 83: Enhance reporting on failing test in assertJsonResponse().
donquixote Jan 8, 2025
8bb0015
Issue 83: Rename a variable to $new_file.
donquixote Jan 8, 2025
b11fa7f
Issue 83: Properly format the log message on save timestamp conflict.
donquixote Jan 8, 2025
2752e17
Issue 83: Rename a variable to $wopi_changed_time in WopiControllerTest.
donquixote Jan 8, 2025
3abd424
Issue 83: Assert the log message in WopiControllerTest::testWopiPutFi…
donquixote Jan 8, 2025
9ca30c5
Issue 83: Extract checkSaveTimestampConflict() from wopiPutFile().
donquixote Jan 8, 2025
8bfb2fe
Issue 83: Assert that the file is replaced in wopiPutFile().
donquixote Jan 8, 2025
4197dd9
Issue 83: Assert that file uri changes on save.
donquixote Jan 8, 2025
b65b72d
Issue 83: Extract callbackTestWopiPutFile() from testWopiPutFile().
donquixote Jan 8, 2025
d76b0ef
Issue 83: Remove a pointless line in callbackTestWopiPutFile().
donquixote Jan 8, 2025
7ced738
Issue 83: Convert the closure to regular method doTestWopiPutFile().
donquixote Jan 8, 2025
a6624dc
Issue 83: Inline $expected_response_data.
donquixote Jan 8, 2025
02d7b32
Issue 83: Assert the media revision log message.
donquixote Jan 8, 2025
be8534c
Issue 83: Assert the saved file content.
donquixote Jan 8, 2025
25a33c2
Issue 83: Rename a variable to $new_file_uri.
donquixote Jan 8, 2025
5011509
Issue 83: Rename $content -> $new_file_content in wopiPutFile().
donquixote Jan 9, 2025
6542c97
Issue 83: Extract createNewFileEntity() from wopiPutFile().
donquixote Jan 8, 2025
916c4f3
Issue 83: Inline $owner_id in createNewFileEntity().
donquixote Jan 8, 2025
09c21f3
Issue 83: Always preserve the filename on save, don't check if old fi…
donquixote Jan 8, 2025
6fd08cc
Issue 83: Break a call and an array to multiple lines.
donquixote Jan 8, 2025
1580163
Issue 83: Reorder statements in wopiPutFile().
donquixote Jan 8, 2025
487524c
Issue 83: Drop the $mtime variable, introduce DateTimeHelper::format().
donquixote Jan 9, 2025
6900a3e
Issue 83: Rename variables that hold timestamps, time strings or date…
donquixote Jan 9, 2025
2d88e46
Issue 83: Assert exact file uri on save.
donquixote Jan 9, 2025
e337cb7
Issue 83: Assert that file name does not change on save.
donquixote Jan 9, 2025
942ca91
Issue 83: Assert that file owner is set correctly on save.
donquixote Jan 9, 2025
d0205ab
Issue 83: Change log level to info.
donquixote Jan 14, 2025
bdff035
Issue 83: Introduce WopiControllerTest::assertOnlyLogMessage().
donquixote Jan 14, 2025
bbf8ac9
Issue 83: Change the log message on save to provide more detail.
donquixote Jan 14, 2025
6729442
Issue 83: Fix typo 'mesage' -> 'message'.
donquixote Jan 14, 2025
a6f26f2
Issue 83: Add copyright in ExceptionWopiSubscriber.
donquixote Jan 14, 2025
682c073
Issue 83: Assert that new file is permanent.
donquixote Jan 14, 2025
b850900
Issue 83: Test missing token.
donquixote Jan 14, 2025
176f315
Issue 83: Check and test if file entity missing.
donquixote Jan 14, 2025
c217401
Issue 83: Check and test if file missing in filesystem.
donquixote Jan 14, 2025
22129d7
Issue 83: Test file size field value on save.
donquixote Jan 14, 2025
ca665e4
Issue 83: Rely on core to update the file size field value.
donquixote Jan 14, 2025
50746d0
Issue 83: Introduce CollaboraJwtKeyException, and clarify failure mes…
donquixote Jan 14, 2025
04f2583
Issue 83: Introduce KernelTestLoggerTrait.
donquixote Jan 14, 2025
de45fa1
Issue 83: Assert core log messages in assertAccessDeniedResponse() an…
donquixote Jan 15, 2025
00d1113
Issue 83: Assert no log messages left in tearDown().
donquixote Jan 15, 2025
4e20afe
Issue 83: Assert log message in testBadToken().
donquixote Jan 15, 2025
d02baee
Issue 83: Test JWT key missing or empty.
donquixote Jan 14, 2025
830d47e
Issue 83: Test the user picture in wopi file info response.
donquixote Jan 15, 2025
c713571
Issue 83: The 3 methods in WopiController don't need to be public.
donquixote Jan 15, 2025
501c5f9
Issue 83: Test wopiPutFile() without write access.
donquixote Jan 15, 2025
ddc83e3
Issue 83: Always check user write permission if token says 'wri'.
donquixote Jan 15, 2025
b6b4a36
Issue 83: Test missing write permission.
donquixote Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions collabora_online.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ collabora-online.settings:
_permission: 'administer site configuration'

collabora-online.wopi.info:
path: '/cool/wopi/files/{id}'
path: '/cool/wopi/files/{media}'
defaults:
_controller: '\Drupal\collabora_online\Controller\WopiController::wopi'
action: 'info'
Expand All @@ -53,11 +53,11 @@ collabora-online.wopi.info:
parameters:
action:
type: string
id:
type: string
media:
type: entity:media

collabora-online.wopi.contents:
path: '/cool/wopi/files/{id}/contents'
path: '/cool/wopi/files/{media}/contents'
defaults:
_controller: '\Drupal\collabora_online\Controller\WopiController::wopi'
action: 'content'
Expand All @@ -69,11 +69,11 @@ collabora-online.wopi.contents:
parameters:
action:
type: string
id:
type: string
media:
type: entity:media

collabora-online.wopi.save:
path: '/cool/wopi/files/{id}/contents'
path: '/cool/wopi/files/{media}/contents'
defaults:
_controller: '\Drupal\collabora_online\Controller\WopiController::wopi'
action: 'save'
Expand All @@ -85,5 +85,5 @@ collabora-online.wopi.save:
parameters:
action:
type: string
id:
type: string
media:
type: entity:media
1 change: 1 addition & 0 deletions collabora_online.services.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
services:
_defaults:
autowire: true
autoconfigure: true
logger.channel.collabora_online:
parent: logger.channel_base
arguments: ['cool']
Expand Down
2 changes: 1 addition & 1 deletion src/Access/WopiProofAccessCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ protected function getSubject(Request $request): string {
pack('N', strlen($url)),
strtoupper($url),
pack('N', 8),
pack('J', $timestamp_ticks)
pack('J', $timestamp_ticks),
AaronGilMartinez marked this conversation as resolved.
Show resolved Hide resolved
);
}

Expand Down
Loading
Loading