Merge pull request #3004 from owncloud/share-space-apiTest

Share space api test
This commit is contained in:
Viktor Scharf
2022-01-21 10:05:00 +01:00
committed by GitHub
4 changed files with 92 additions and 13 deletions

View File

@@ -21,3 +21,6 @@
#### [Overwriting a file in the space within the allowed quota does not work](https://github.com/owncloud/ocis/issues/2829)
- [apiSpaces/quota.feature:56](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/quota.feature#L56)
#### [Uploading a file to a shared space does not work](https://github.com/owncloud/ocis/issues/3002)
- [apiSpaces/uploadSpaces.feature:90](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/uploadSpaces.feature#L90)
- [apiSpaces/uploadSpaces.feature:106](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/uploadSpaces.feature#L106)

View File

@@ -12,9 +12,17 @@ Feature: Share spaces
And the administrator has given "Alice" the role "Admin" using the settings api
Scenario: A user can share a space to another user
Scenario: A user can share a space to another user with role viewer
Given user "Alice" has created a space "Space to share" of type "project" with quota "10"
When user "Alice" shares a space "Space to share" to user "Brian"
When user "Alice" shares a space "Space to share" to user "Brian" with role "viewer"
Then the HTTP status code should be "200"
And the OCS status code should be "200"
And the OCS status message should be "OK"
Scenario: A user can share a space to another user with role editor
Given user "Alice" has created a space "Space to share with role editor" of type "project" with quota "10"
When user "Alice" shares a space "Space to share with role editor" to user "Brian" with role "editor"
Then the HTTP status code should be "200"
And the OCS status code should be "200"
And the OCS status message should be "OK"
@@ -22,7 +30,7 @@ Feature: Share spaces
Scenario: A user can see that a received shared space is available
Given user "Alice" has created a space "Share space to Brian" of type "project" with quota "10"
And user "Alice" has shared a space "Share space to Brian" to user "Brian"
And user "Alice" has shared a space "Share space to Brian" to user "Brian" with role "viewer"
When user "Brian" lists all available spaces via the GraphApi
Then the json responded should contain a space "Share space to Brian" with these key and value pairs:
| key | value |
@@ -36,7 +44,7 @@ Feature: Share spaces
Scenario: A user can see a file in a received shared space
Given user "Alice" has created a space "Share space with file" of type "project" with quota "10"
And user "Alice" has uploaded a file inside space "Share space with file" with content "Test" to "test.txt"
When user "Alice" has shared a space "Share space with file" to user "Brian"
When user "Alice" has shared a space "Share space with file" to user "Brian" with role "viewer"
Then for user "Brian" the space "Share space with file" should contain these entries:
| test.txt |
@@ -44,14 +52,14 @@ Feature: Share spaces
Scenario: A user can see a folder in received shared space
Given user "Alice" has created a space "Share space with folder" of type "project" with quota "10"
And user "Alice" has created a folder "Folder Main" in space "Share space with folder"
When user "Alice" has shared a space "Share space with folder" to user "Brian"
When user "Alice" has shared a space "Share space with folder" to user "Brian" with role "viewer"
Then for user "Brian" the space "Share space with folder" should contain these entries:
| Folder Main |
Scenario: When a user unshares a space, the space becomes unavailable to the receiver
Given user "Alice" has created a space "Unshare space" of type "project" with quota "10"
And user "Alice" has shared a space "Unshare space" to user "Brian"
And user "Alice" has shared a space "Unshare space" to user "Brian" with role "viewer"
When user "Brian" lists all available spaces via the GraphApi
Then the json responded should contain a space "Unshare space" with these key and value pairs:
| key | value |
@@ -61,4 +69,4 @@ Feature: Share spaces
When user "Alice" unshares a space "Unshare space" to user "Brian"
Then the HTTP status code should be "200"
And user "Brian" lists all available spaces via the GraphApi
And the json responded should not contain a space "Unshare space"
And the json responded should not contain a space with name "Unshare space"

View File

@@ -64,3 +64,52 @@ Feature: Upload files into a space
| quota@@@total | 2000 |
| quota@@@remaining| 1996 |
| quota@@@used | 4 |
Scenario: A user with role editor can create a folder in shared Space via the Graph API
Given user "Alice" has created a space "Editor can create folder" of type "project" with quota "2000"
And user "Alice" has shared a space "Editor can create folder" to user "Bob" with role "editor"
When user "Bob" creates a folder "mainFolder" in space "Editor can create folder" using the WebDav Api
Then the HTTP status code should be "201"
And for user "Bob" the space "Editor can create folder" should contain these entries:
| mainFolder |
And for user "Alice" the space "Editor can create folder" should contain these entries:
| mainFolder |
Scenario: A user with role viewer cannot create a folder in shared Space via the Graph API
Given user "Alice" has created a space "Viewer cannot create folder" of type "project" with quota "2000"
And user "Alice" has shared a space "Viewer cannot create folder" to user "Bob" with role "viewer"
When user "Bob" creates a folder "mainFolder" in space "Viewer cannot create folder" using the WebDav Api
Then the HTTP status code should be "403"
And for user "Bob" the space "Viewer cannot create folder" should not contain these entries:
| mainFolder |
And for user "Alice" the space "Viewer cannot create folder" should not contain these entries:
| mainFolder |
Scenario: A user with role editor can upload a file in shared Space via the Graph API
Given user "Alice" has created a space "Editor can upload file" of type "project" with quota "20"
And user "Alice" has shared a space "Editor can upload file" to user "Bob" with role "editor"
When user "Bob" uploads a file inside space "Editor can upload file" with content "Test" to "test.txt" using the WebDAV API
Then the HTTP status code should be "201"
And for user "Bob" the space "Editor can upload file" should contain these entries:
| test.txt |
And for user "Alice" the space "Editor can upload file" should contain these entries:
| test.txt |
When user "Bob" lists all available spaces via the GraphApi
Then the json responded should contain a space "Editor can upload file" with these key and value pairs:
| key | value |
| name | Editor can upload file |
| quota@@@used | 4 |
Scenario: A user with role viewer cannot upload a file in shared Space via the Graph API
Given user "Alice" has created a space "Viewer cannot upload file" of type "project" with quota "20"
And user "Alice" has shared a space "Viewer cannot upload file" to user "Bob" with role "viewer"
When user "Bob" uploads a file inside space "Viewer cannot upload file" with content "Test" to "test.txt" using the WebDAV API
Then the HTTP status code should be "403"
And for user "Bob" the space "Viewer cannot upload file" should not contain these entries:
| test.txt |
And for user "Alice" the space "Viewer cannot upload file" should not contain these entries:
| test.txt |

View File

@@ -1235,11 +1235,12 @@ class SpacesContext implements Context {
}
/**
* @When /^user "([^"]*)" shares a space "([^"]*)" to user "([^"]*)"$/
* @When /^user "([^"]*)" shares a space "([^"]*)" to user "([^"]*)" with role "([^"]*)"$/
*
* @param string $user
* @param string $spaceName
* @param string $userRecipient
* @param string $role
*
* @return void
* @throws GuzzleException
@@ -1247,10 +1248,26 @@ class SpacesContext implements Context {
public function sendShareSpaceRequest(
string $user,
string $spaceName,
string $userRecipient
string $userRecipient,
string $role
): void {
switch ($role) {
case "viewer":
$role = 1;
break;
case "editor":
$role = 15;
break;
default:
$role = 1;
}
$space = $this->getSpaceByName($user, $spaceName);
$body = ["space_ref" => $space['id'], "shareType" => 7, "shareWith" => $userRecipient];
$body = [
"space_ref" => $space['id'],
"shareType" => 7,
"shareWith" => $userRecipient,
"permissions" => $role
];
$fullUrl = $this->baseUrl . "/ocs/v2.php/apps/files_sharing/api/v1/shares";
@@ -1267,11 +1284,12 @@ class SpacesContext implements Context {
}
/**
* @Given /^user "([^"]*)" has shared a space "([^"]*)" to user "([^"]*)"$/
* @Given /^user "([^"]*)" has shared a space "([^"]*)" to user "([^"]*)" with role "([^"]*)"$/
*
* @param string $user
* @param string $spaceName
* @param string $userRecipient
* @param string $role
*
* @return void
* @throws GuzzleException
@@ -1279,9 +1297,10 @@ class SpacesContext implements Context {
public function userHasSharedSpace(
string $user,
string $spaceName,
string $userRecipient
string $userRecipient,
string $role
): void {
$this->sendShareSpaceRequest($user, $spaceName, $userRecipient);
$this->sendShareSpaceRequest($user, $spaceName, $userRecipient, $role);
$expectedHTTPStatus = "200";
$this->featureContext->theHTTPStatusCodeShouldBe(