diff options
Diffstat (limited to 'tests/features')
-rw-r--r-- | tests/features/bootstrap/DirectContext.php | 60 | ||||
-rw-r--r-- | tests/features/bootstrap/RichDocumentsContext.php | 10 | ||||
-rw-r--r-- | tests/features/bootstrap/WopiContext.php | 4 | ||||
-rw-r--r-- | tests/features/direct.feature | 87 |
4 files changed, 154 insertions, 7 deletions
diff --git a/tests/features/bootstrap/DirectContext.php b/tests/features/bootstrap/DirectContext.php index 4c17a0f4..4662d35d 100644 --- a/tests/features/bootstrap/DirectContext.php +++ b/tests/features/bootstrap/DirectContext.php @@ -83,6 +83,46 @@ class DirectContext implements Context { $this->handleDirectEditingLink(); } + /** + * @When /^User "([^"]*)" opens the file "([^"]*)" in the last share link through direct editing from server "([^"]*)"$/ + */ + public function userOpensTheFileInTheLastShareLinkThroughDirectEditingFromServer($user, $path, $host) { + $shareToken = $this->sharingContext->getLastShareData()['token']; + $this->serverContext->usingWebAsUser($user); + $this->requestPublicDirectEditingLink($user, $shareToken, $path, null, $this->serverContext->getServer($host)); + $this->handleDirectEditingLink(); + } + + /** + * @When /^User "([^"]*)" opens the file "([^"]*)" in the last share link through direct editing from server "([^"]*)" with password "([^"]*)"$/ + */ + public function userOpensTheFileInTheLastShareLinkThroughDirectEditingFromServerWithPassword($user, $path, $host, $password) { + $shareToken = $this->sharingContext->getLastShareData()['token']; + $this->serverContext->usingWebAsUser($user); + $this->requestPublicDirectEditingLink($user, $shareToken, $path, $password, $this->serverContext->getServer($host)); + $this->handleDirectEditingLink(); + } + + /** + * @When /^User "([^"]*)" cannot open the file "([^"]*)" in the last share link through direct editing from server "([^"]*)" with password "([^"]*)"$/ + */ + public function userCannotOpenTheFileInTheLastShareLinkThroughDirectEditingFromServerWithPassword($user, $path, $host, $password) { + $shareToken = $this->sharingContext->getLastShareData()['token']; + $this->serverContext->usingWebAsUser($user); + $this->requestPublicDirectEditingLink($user, $shareToken, $path, $password, $this->serverContext->getServer($host)); + $this->serverContext->assertHttpStatusCode(403); + } + + /** + * @When /^A guest opens the file "([^"]*)" in the last share link through direct editing$/ + */ + public function aGuestOpensTheFileInTheLastShareLinkThroughDirectEditing($path) { + $shareToken = $this->sharingContext->getLastShareData()['token']; + $this->serverContext->usingWebasGuest(); + $this->requestPublicDirectEditingLink(null, $shareToken, $path); + $this->handleDirectEditingLink(); + } + private function handleDirectEditingLink() { $this->serverContext->assertHttpStatusCode(200); $data = $this->serverContext->getOCSResponseData(); @@ -152,13 +192,25 @@ class DirectContext implements Context { $this->serverContext->sendOCSRequest('POST', 'apps/richdocuments/api/v1/document', [ 'fileId' => $fileId ]); } - private function requestPublicDirectEditingLink($user, $token, $filePath = null, $password = null) { - $this->serverContext->sendOCSRequest('POST', 'apps/richdocuments/api/v1/share', [ - 'host' => $this->serverContext->getBaseUrl(), + /** + * @param $user + * @param $token + * @param null $filePath + * @param null $password + * @param null $host + */ + private function requestPublicDirectEditingLink($user, $token, $filePath = null, $password = null, $host = null) { + // ServerContext currently does not support sending anonymous ocs requests + $options = $user ? [] : [ 'auth' => null ]; + $data = [ 'shareToken' => $token, 'path' => $filePath, 'password' => $password - ]); + ]; + if ($host) { + $data['host'] = $host; + } + $this->serverContext->sendOCSRequest('POST', 'apps/richdocuments/api/v1/share', $data, $options); } } diff --git a/tests/features/bootstrap/RichDocumentsContext.php b/tests/features/bootstrap/RichDocumentsContext.php index cea95325..20cf8bf4 100644 --- a/tests/features/bootstrap/RichDocumentsContext.php +++ b/tests/features/bootstrap/RichDocumentsContext.php @@ -215,4 +215,14 @@ class RichDocumentsContext implements Context $this->wopiToken = $result['token']; $this->wopiContext->setWopiParameters($this->currentServer, $this->fileId, $this->wopiToken); } + + /** + * @When /^the guest updates the display name to "([^"]*)"$/ + */ + public function updateTheGuestDisplayName($displayName) { + $this->serverContext->sendOCSRequest('POST', 'apps/richdocuments/api/v1/wopi/guestname', [ + 'access_token' => $this->wopiContext->getWopiToken(), + 'guestName' => $displayName, + ], [ 'auth' => null ]); + } } diff --git a/tests/features/bootstrap/WopiContext.php b/tests/features/bootstrap/WopiContext.php index 03ddda51..d115b884 100644 --- a/tests/features/bootstrap/WopiContext.php +++ b/tests/features/bootstrap/WopiContext.php @@ -66,6 +66,10 @@ class WopiContext implements Context { return $this->serverContext->getBaseUrl(); } + public function getWopiToken() { + return $this->wopiToken; + } + public function setWopiParameters($server, $fileId, $accessToken) { $this->currentServer = $server; $this->fileId = $fileId; diff --git a/tests/features/direct.feature b/tests/features/direct.feature index 8359b020..b09103d1 100644 --- a/tests/features/direct.feature +++ b/tests/features/direct.feature @@ -129,7 +129,8 @@ Feature: Direct editing And Collabora fetches and receives the following in the checkFileInfo response | BaseFileName | document-share-link.odt | | OwnerId | user1 | - | UserFriendlyName | user2-displayname (Guest) | + | UserId | user2 | + | UserFriendlyName | user2-displayname | And checkFileInfo "UserCanWrite" is true And both Collabora files used the same file id And Collabora can save the file with the content of "./../assets/template.ods" @@ -151,8 +152,8 @@ Feature: Direct editing And Collabora fetches and receives the following in the checkFileInfo response | BaseFileName | document-share-link.odt | | OwnerId | user1 | - | UserFriendlyName | user2-displayname (Guest) | - And checkFileInfo "UserId" matches "/Guest-/" + | UserId | user2 | + | UserFriendlyName | user2-displayname | And both Collabora files used the same file id And Collabora can not save the file with the content of "./../assets/template.ods" Then Collabora downoads the file and it is equal to "./../assets/template.odt" @@ -174,6 +175,57 @@ Feature: Direct editing And Collabora fetches and receives the following in the checkFileInfo response | BaseFileName | document-share-link.odt | | OwnerId | user1 | + | UserId | user2 | + | UserFriendlyName | user2-displayname | + And checkFileInfo "UserCanWrite" is true + And both Collabora files used the same file id + And Collabora can save the file with the content of "./../assets/template.ods" + Then Collabora downoads the file and it is equal to "./../assets/template.ods" + + Scenario: Open a file in a shared folder of a share link with direct editing as writable as a guest + Given on instance "serverA" + And as user "user1" + And User "user1" creates a folder "Folder" + And User "user1" uploads file "./../assets/template.odt" to "/Folder/document-share-link.odt" + When User "user1" opens "/Folder/document-share-link.odt" through direct editing + And Collabora fetches checkFileInfo + And as "user1" create a share with + | path | /Folder/ | + | shareType | 3 | + And Updating last share with + | permissions | 3 | + When A guest opens the file "/document-share-link.odt" in the last share link through direct editing + And Collabora fetches and receives the following in the checkFileInfo response + | BaseFileName | document-share-link.odt | + | OwnerId | user1 | + | UserFriendlyName | Anonymous guest | + When the guest updates the display name to "Random name" + And Collabora fetches checkFileInfo + And checkFileInfo "UserFriendlyName" is "Random name (Guest)" + And checkFileInfo "UserId" matches "/Guest-/" + And checkFileInfo "UserCanWrite" is true + And both Collabora files used the same file id + And Collabora can save the file with the content of "./../assets/template.ods" + Then Collabora downoads the file and it is equal to "./../assets/template.ods" + + Scenario: Open a file in a shared folder of a share link with direct editing as writable as a remote user + Given on instance "serverA" + And as user "user1" + And User "user1" creates a folder "Folder" + And User "user1" uploads file "./../assets/template.odt" to "/Folder/document-share-link.odt" + When User "user1" opens "/Folder/document-share-link.odt" through direct editing + And Collabora fetches checkFileInfo + And as "user1" create a share with + | path | /Folder/ | + | shareType | 3 | + And Updating last share with + | permissions | 3 | + Given on instance "serverB" + And as user "user2" + When User "user2" opens the file "/document-share-link.odt" in the last share link through direct editing from server "serverA" + And Collabora fetches and receives the following in the checkFileInfo response + | BaseFileName | document-share-link.odt | + | OwnerId | user1 | | UserFriendlyName | user2-displayname (Guest) | And checkFileInfo "UserId" matches "/Guest-/" And checkFileInfo "UserCanWrite" is true @@ -181,6 +233,35 @@ Feature: Direct editing And Collabora can save the file with the content of "./../assets/template.ods" Then Collabora downoads the file and it is equal to "./../assets/template.ods" + Scenario: Open a file in a shared folder of a share link with direct editing as writable as a remote user with password + Given on instance "serverA" + And as user "user1" + And User "user1" creates a folder "Folder" + And User "user1" uploads file "./../assets/template.odt" to "/Folder/document-share-link.odt" + When User "user1" opens "/Folder/document-share-link.odt" through direct editing + And Collabora fetches checkFileInfo + And as "user1" create a share with + | path | /Folder/ | + | shareType | 3 | + | password | mysecret | + And Updating last share with + | permissions | 3 | + Given on instance "serverB" + And as user "user2" + When User "user2" opens the file "/document-share-link.odt" in the last share link through direct editing from server "serverA" with password "mysecret" + And Collabora fetches and receives the following in the checkFileInfo response + | BaseFileName | document-share-link.odt | + | OwnerId | user1 | + | UserFriendlyName | user2-displayname (Guest) | + And checkFileInfo "UserId" matches "/Guest-/" + And checkFileInfo "UserCanWrite" is true + And both Collabora files used the same file id + And Collabora can save the file with the content of "./../assets/template.ods" + Then Collabora downoads the file and it is equal to "./../assets/template.ods" + + And as user "user2" + When User "user2" cannot open the file "/document-share-link.odt" in the last share link through direct editing from server "serverA" with password "wrongpassword" + @federation @known-failure-ci Scenario: Open a link that originates on a federated share through direct editing Given user "user3" exists |