Skip to content

Commit

Permalink
adding test for listing permission of project space by a user who is …
Browse files Browse the repository at this point in the history
…not a member of the space
  • Loading branch information
nirajacharya2 committed Apr 24, 2024
1 parent 0960d7f commit 0e24595
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/acceptance/features/apiSharingNg/listPermissions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1079,3 +1079,45 @@ Feature: List a sharing permissions
| drive |
| Personal |
| Shares |


Scenario: non member tries to list the permissions of a project space using permission endpoint
Given using spaces DAV path
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Brian" has been created with default attributes and without skeleton files
And user "Alice" has created a space "new-space" with the default quota using the Graph API
When user "Brian" tries to list the permissions of space "new-space" owned by "Alice" using permissions endpoint of the Graph API
Then the HTTP status code should be "404"
And the JSON data of the response should match
"""
{
"type": "object",
"required": ["error"],
"properties": {
"error": {
"type": "object",
"required": [
"code",
"innererror",
"message"
],
"properties": {
"code": {
"const": "itemNotFound"
},
"innererror": {
"type": "object",
"required": [
"date",
"request-id"
]
},
"message": {
"type": "string",
"pattern": "stat: error: not found: %file_id_pattern%$"
}
}
}
}
}
"""
26 changes: 26 additions & 0 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,32 @@ public function userListsThePermissionsOfSpaceUsingTheGraphApi($user, $space):vo
);
}

/**
* @When /^user "([^"]*)" tries to list the permissions of space "([^"]*)" owned by "([^"]*)" using permissions endpoint of the Graph API$/
*
* @param string $user
* @param string $space
* @param string $spaceOwner
*
* @return void
* @throws Exception
*/
public function userTriesToListThePermissionsOfSpaceUsingTheGraphApi(string $user, string $space, string $spaceOwner):void {
$spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"];
$itemId = $this->spacesContext->getResourceId($spaceOwner, $space, '');

$this->featureContext->setResponse(
GraphHelper::getPermissionsList(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$spaceId,
$itemId
)
);
}

/**
* @param string $user
* @param TableNode $table
Expand Down

0 comments on commit 0e24595

Please sign in to comment.