added test to create odt file inside folder in public space

This commit is contained in:
Prajwol Amatya
2024-09-17 17:05:53 +05:45
parent bf9c0d9d6d
commit 5cfdfec4de
2 changed files with 100 additions and 5 deletions

View File

@@ -122,18 +122,16 @@ class CollaborationContext implements Context {
}
/**
* @When the public creates a file :file inside the last shared public link folder with password :password using wopi endpoint
* @When the public tries to create a file :file inside the last shared public link folder with password :password using wopi endpoint
*
* @param string $file
* @param string $password
* @param string $folder
*
* @return void
* @throws GuzzleException
*/
public function thePublicCreatesAFileInsideTheLastSharedPublicLinkFolderWithPasswordUsingWopiEndpoint(string $file, string $password): void {
public function createFile(string $file, string $password, string $folder = ""): void {
$token = $this->featureContext->shareNgGetLastCreatedLinkShareToken();
$davPath = WebDavHelper::getDavPath($token, null, "public-files-new");
$davPath = WebDavHelper::getDavPath($token, null, "public-files-new") . "/$folder";
$response = HttpRequestHelper::sendRequest(
$this->featureContext->getBaseUrl() . "/$davPath",
$this->featureContext->getStepLineRef(),
@@ -164,6 +162,35 @@ class CollaborationContext implements Context {
);
}
/**
* @When the public creates a file :file inside the last shared public link folder with password :password using wopi endpoint
* @When the public tries to create a file :file inside the last shared public link folder with password :password using wopi endpoint
*
* @param string $file
* @param string $password
*
* @return void
* @throws GuzzleException
*/
public function thePublicCreatesAFileInsideTheLastSharedPublicLinkFolderWithPasswordUsingWopiEndpoint(string $file, string $password): void {
$this->createFile($file, $password);
}
/**
* @When the public creates a file :file inside folder :folder in the last shared public link space with password :password using wopi endpoint
* @When the public tries to create a file :file inside folder :folder in the last shared public link space with password :password using wopi endpoint
*
* @param string $file
* @param string $folder
* @param string $password
*
* @return void
* @throws GuzzleException
*/
public function thePublicCreatesAFileInsideFolderInTheLastSharedPublicLinkSpaceWithPasswordUsingWopiEndpoint(string $file, string $folder, string $password): void {
$this->createFile($file, $password, $folder);
}
/**
* @When user :user tries to check the information of file :file of space :space using office :app with invalid file-id
*

View File

@@ -1012,3 +1012,71 @@ Feature: collaboration (wopi)
}
}
"""
@issue-8691
Scenario Outline: public user with permission edit/upload/createOnly creates odt file inside folder of public space using wopi endpoint
Given using spaces DAV path
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "new-space" with the default quota using the Graph API
And user "Alice" has created a folder "testFolder" in space "new-space"
And user "Alice" has created the following space link share:
| space | new-space |
| permissionsRole | <permissions-role> |
| password | %public% |
When the public creates a file "simple.odt" inside folder "testFolder" in the last shared public link space with password "%public%" using wopi endpoint
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"file_id"
],
"properties": {
"file_id": {
"type": "string",
"pattern": "^%file_id_pattern%$"
}
}
}
"""
And for user "Alice" folder "testFolder" of the space "new-space" should contain these files:
| simple.odt |
Examples:
| permissions-role |
| edit |
| upload |
| createOnly |
@issue-8691
Scenario: public user with permission view tries to create odt file inside folder of public space using wopi endpoint
Given using spaces DAV path
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "new-space" with the default quota using the Graph API
And user "Alice" has created a folder "testFolder" in space "new-space"
And user "Alice" has created the following space link share:
| space | new-space |
| permissionsRole | view |
| password | %public% |
When the public tries to create a file "simple.odt" inside folder "testFolder" in the last shared public link space with password "%public%" using wopi endpoint
Then the HTTP status code should be "500"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"const": "SERVER_ERROR"
},
"message": {
"const": "error calling InitiateFileUpload"
}
}
}
"""
And for user "Alice" folder "testFolder" of the space "new-space" should not contain these files:
| simple.odt |