Skip to content

Commit

Permalink
Added test for sending share invitation to wrong objectId
Browse files Browse the repository at this point in the history
  • Loading branch information
grgprarup committed Jan 24, 2024
1 parent 7f5aa6b commit 988a558
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 10 deletions.
50 changes: 50 additions & 0 deletions tests/acceptance/features/apiSharingNg/shareInvitations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1208,3 +1208,53 @@ Feature: Send a sharing invitations
| Viewer | folder | FolderToShare |
| Editor | folder | FolderToShare |
| Uploader | folder | FolderToShare |


Scenario Outline: send share invitation to wrong user id with different roles
Given user "Alice" has uploaded file with content "to share" to "/textfile1.txt"
And user "Alice" has created folder "FolderToShare"
When user "Alice" tries to send the following share invitation using the Graph API:
| resourceType | <resource-type> |
| resource | <path> |
| space | Personal |
| shareeId | a4c0c83e-ae24-4870-93c3-fcaf2a2228f7 |
| shareType | user |
| permissionsRole | <permissions-role> |
Then the HTTP status code should be "400"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "string",
"pattern": "generalException"
},
"message": {
"type": "string",
"enum": [
"itemNotFound: not found"
]
}
}
}
}
}
"""
Examples:
| permissions-role | resource-type | path |
| Viewer | file | /textfile1.txt |
| File Editor | file | /textfile1.txt |
| Viewer | folder | FolderToShare |
| Editor | folder | FolderToShare |
| Uploader | folder | FolderToShare |
25 changes: 15 additions & 10 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,20 @@ public function sendShareInvitation(string $user, TableNode $table): ResponseInt
? $this->spacesContext->getResourceId($user, $rows['space'], $rows['resource'])
: $this->spacesContext->getFileId($user, $rows['space'], $rows['resource']);

$sharees = array_map('trim', explode(',', $rows['sharee']));
$shareTypes = array_map('trim', explode(',', $rows['shareType']));

$shareeIds = [];
foreach ($sharees as $index => $sharee) {
$shareType = $shareTypes[$index];
// for non-exiting group or user, generate random id
$shareeIds[] = (($shareType === 'user')
? $this->featureContext->getAttributeOfCreatedUser($sharee, 'id')
: $this->featureContext->getAttributeOfCreatedGroup($sharee, 'id')) ?: WebDavHelper::generateUUIDv4();
if (\array_key_exists('shareeId', $rows)) {
$shareeIds[] = $rows['shareeId'];
$shareTypes[] = $rows['shareType'];
} else {
$sharees = array_map('trim', explode(',', $rows['sharee']));
$shareTypes = array_map('trim', explode(',', $rows['shareType']));

foreach ($sharees as $index => $sharee) {
$shareType = $shareTypes[$index];
// for non-exiting group or user, generate random id
$shareeIds[] = (($shareType === 'user')
? $this->featureContext->getAttributeOfCreatedUser($sharee, 'id')
: $this->featureContext->getAttributeOfCreatedGroup($sharee, 'id')) ?: WebDavHelper::generateUUIDv4();
}
}

$permissionsRole = $rows['permissionsRole'] ?? null;
Expand Down Expand Up @@ -197,6 +201,7 @@ public function userHasSentTheFollowingShareInvitation(string $user, TableNode $

/**
* @When /^user "([^"]*)" sends the following share invitation using the Graph API:$/
* @When /^user "([^"]*)" tries to send the following share invitation using the Graph API:$/
*
* @param string $user
* @param TableNode $table
Expand Down

0 comments on commit 988a558

Please sign in to comment.