Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2021-05-17 12:56:11 +0300
committerJulius Härtl <jus@bitgrid.net>2021-05-17 12:56:11 +0300
commit41bfb5a7c8c14c084b420481f6e01de56d518852 (patch)
tree3706d674b8fea13bd5379e156b97b3020dda15f8 /tests
parent8029f00da08d6e8dd00e5438714d7a9ae88e6633 (diff)
Add tests for PutRelativeFile
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/features/bootstrap/WopiContext.php22
-rw-r--r--tests/features/wopi.feature49
2 files changed, 71 insertions, 0 deletions
diff --git a/tests/features/bootstrap/WopiContext.php b/tests/features/bootstrap/WopiContext.php
index fcbaaadb..03ddda51 100644
--- a/tests/features/bootstrap/WopiContext.php
+++ b/tests/features/bootstrap/WopiContext.php
@@ -267,4 +267,26 @@ class WopiContext implements Context {
Assert::assertNotEquals($current, $previous);
}
+
+ /**
+ * @Given /^Collabora saves the content of "([^"]*)" as "([^"]*)"$/
+ */
+ public function collaboraSavesTheFileAs($source, $newName) {
+ $file = \GuzzleHttp\Psr7\stream_for(fopen($source, 'r'));
+ $client = new Client();
+ $options = [
+ 'body' => $file,
+ 'headers' => [
+ 'X-LOOL-WOPI-Timestamp' => $this->checkFileInfoResult['LastModifiedTime'],
+ 'X-WOPI-SuggestedTarget' => $newName,
+ 'X-WOPI-Override' => 'PUT_RELATIVE',
+ ]
+ ];
+ try {
+ $this->response = $client->post($this->getWopiEndpointBaseUrl() . 'index.php/apps/richdocuments/wopi/files/' . $this->fileId . '?access_token=' . $this->wopiToken, $options);
+ } catch (\GuzzleHttp\Exception\ClientException $e) {
+ $this->response = $e->getResponse();
+ }
+ }
+
}
diff --git a/tests/features/wopi.feature b/tests/features/wopi.feature
index 27de7027..64ad99e2 100644
--- a/tests/features/wopi.feature
+++ b/tests/features/wopi.feature
@@ -269,3 +269,52 @@ Feature: WOPI
| UserFriendlyName | user1-displayname |
And checkFileInfo "UserCanWrite" is true
And TemplateSource is set
+
+
+ Scenario: Save as
+ Given as user "user1"
+ And User "user1" uploads file "./../assets/template.odt" to "/file-origin.odt"
+ Then User "user1" opens "/file-origin.odt"
+ And Collabora fetches and receives the following in the checkFileInfo response
+ | BaseFileName | file-origin.odt |
+ | OwnerId | user1 |
+ | UserId | user1 |
+ | UserFriendlyName | user1-displayname |
+ And checkFileInfo "UserCanWrite" is true
+ And Collabora saves the content of "./../assets/template.ods" as "saveas.odt"
+ And the WOPI HTTP status code should be "200"
+
+ Then User "user1" opens "/saveas.odt"
+ And Collabora fetches and receives the following in the checkFileInfo response
+ | BaseFileName | saveas.odt |
+ | OwnerId | user1 |
+ | UserId | user1 |
+ | UserFriendlyName | user1-displayname |
+ And Collabora downloads the file
+ And Collabora downoads the file and it is equal to "./../assets/template.ods"
+
+ Scenario: Save as different user
+ Given as user "user1"
+ And User "user1" uploads file "./../assets/template.odt" to "/file-origin.odt"
+ And as "user1" create a share with
+ | path | /file-origin.odt |
+ | shareType | 0 |
+ | shareWith | user2 |
+ | permissions | 31 |
+ Then User "user2" opens "/file-origin.odt"
+ And Collabora fetches and receives the following in the checkFileInfo response
+ | BaseFileName | file-origin.odt |
+ | OwnerId | user1 |
+ | UserId | user2 |
+ | UserFriendlyName | user2-displayname |
+ And Collabora saves the content of "./../assets/template.ods" as "/saveas.odt"
+ And the WOPI HTTP status code should be "200"
+
+ Then User "user2" opens "/saveas.odt"
+ And Collabora fetches and receives the following in the checkFileInfo response
+ | BaseFileName | saveas.odt |
+ | OwnerId | user2 |
+ | UserId | user2 |
+ | UserFriendlyName | user2-displayname |
+ And Collabora downloads the file
+ And Collabora downoads the file and it is equal to "./../assets/template.ods"