add Api test for adding space managers (#3166)
* add Api test for adding space managers * add cheking permissions in response * fix after rebase * only personal space dispayes owner Co-authored-by: Viktor Scharf <scharf.vi@gmail.com>
This commit is contained in:
co-authored by
Viktor Scharf
parent
602458a09d
commit
94f3d7562a
@@ -78,11 +78,12 @@ Feature: List and create spaces
|
||||
|
||||
Scenario: A user can list his personal space via multiple endpoints
|
||||
When user "Alice" lists all available spaces via the GraphApi with query "$filter=driveType eq 'personal'"
|
||||
Then the json responded should contain a space "Alice Hansen" with these key and value pairs:
|
||||
Then the json responded should contain a space "Alice Hansen" owned by "Alice" with these key and value pairs:
|
||||
| key | value |
|
||||
| driveType | personal |
|
||||
| name | Alice Hansen |
|
||||
| root@@@webDavUrl | %base_url%/dav/spaces/%space_id% |
|
||||
| owner@@@user@@@id | %user_id% |
|
||||
When user "Alice" looks up the single space "Alice Hansen" via the GraphApi by using its id
|
||||
Then the json responded should contain a space "Alice Hansen" with these key and value pairs:
|
||||
| key | value |
|
||||
|
||||
@@ -33,13 +33,11 @@ Feature: Share spaces
|
||||
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" 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" owned by "Alice" with these key and value pairs:
|
||||
| key | value |
|
||||
| driveType | project |
|
||||
| id | %space_id% |
|
||||
| name | Share space to Brian |
|
||||
| root@@@permissions@@@0@@@grantedTo@@@0@@@user@@@id | %user_id% |
|
||||
| root@@@permissions@@@0@@@roles@@@0 | manager |
|
||||
Then the json responded should contain a space "Share space to Brian" with these key and value pairs:
|
||||
| key | value |
|
||||
| driveType | project |
|
||||
| id | %space_id% |
|
||||
| name | Share space to Brian |
|
||||
|
||||
|
||||
Scenario: A user can see who has been granted access
|
||||
@@ -47,9 +45,9 @@ Feature: Share spaces
|
||||
And user "Alice" has shared a space "Share space to Brian" to user "Brian" with role "viewer"
|
||||
When user "Alice" lists all available spaces via the GraphApi
|
||||
Then the json responded should contain a space "Share space to Brian" granted to "Brian" with these key and value pairs:
|
||||
| key | value |
|
||||
| root@@@permissions@@@1@@@grantedTo@@@0@@@user@@@id | %user_id% |
|
||||
| root@@@permissions@@@1@@@roles@@@0 | viewer |
|
||||
| key | value |
|
||||
| root@@@permissions@@@1@@@grantedTo@@@0@@@user@@@id | %user_id% |
|
||||
| root@@@permissions@@@1@@@roles@@@0 | viewer |
|
||||
|
||||
|
||||
Scenario: A user can see a file in a received shared space
|
||||
@@ -81,3 +79,16 @@ Feature: Share spaces
|
||||
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 with name "Unshare space"
|
||||
|
||||
|
||||
Scenario: A user can add another user to the space managers to enable him
|
||||
Given user "Alice" has created a space "Multiple Managers" of type "project" with quota "10"
|
||||
And user "Alice" has uploaded a file inside space "Multiple Managers" with content "Test" to "test.txt"
|
||||
When user "Alice" has shared a space "Multiple Managers" to user "Brian" with role "manager"
|
||||
And user "Brian" lists all available spaces via the GraphApi
|
||||
Then the json responded should contain a space "Multiple Managers" granted to "Brian" with role "manager"
|
||||
When user "Brian" has shared a space "Multiple Managers" to user "Bob" with role "viewer"
|
||||
And user "Bob" lists all available spaces via the GraphApi
|
||||
Then the json responded should contain a space "Multiple Managers" granted to "Bob" with role "viewer"
|
||||
And for user "Bob" the space "Multiple Managers" should contain these entries:
|
||||
| test.txt |
|
||||
|
||||
@@ -809,6 +809,35 @@ class SpacesContext implements Context {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the json responded should contain a space "([^"]*)" granted to "([^"]*)" with role "([^"]*)"$/
|
||||
*
|
||||
* @param string $spaceName
|
||||
* @param string $userName
|
||||
* @param string $role
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function checkPermissionsInResponse(
|
||||
string $spaceName,
|
||||
string $userName,
|
||||
string $role
|
||||
): void {
|
||||
Assert::assertIsArray($spaceAsArray = $this->getSpaceByNameFromResponse($spaceName), "No space with name $spaceName found");
|
||||
$permissions = $spaceAsArray["root"]["permissions"];
|
||||
$userId = $this->getUserIdByUserName($userName);
|
||||
|
||||
$userRole = "";
|
||||
foreach ($permissions as $permission) {
|
||||
foreach ($permission["grantedTo"] as $grantedTo)
|
||||
if ($grantedTo["user"]["id"] === $userId) {
|
||||
$userRole = $permission["roles"][0];
|
||||
}
|
||||
}
|
||||
Assert::assertEquals($userRole, $role, "the user $userName with the role $role could not be found");
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the json responded should not contain a space with name "([^"]*)"$/
|
||||
*
|
||||
@@ -1371,22 +1400,12 @@ class SpacesContext implements Context {
|
||||
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,
|
||||
"permissions" => $role
|
||||
"role" => $role // role overrides the permissions parameter
|
||||
];
|
||||
|
||||
$fullUrl = $this->baseUrl . "/ocs/v2.php/apps/files_sharing/api/v1/shares";
|
||||
|
||||
Reference in New Issue
Block a user