Skip to content

Commit

Permalink
Merge pull request #8129 from owncloud/add-test-for-invite-user-with-…
Browse files Browse the repository at this point in the history
…wrong-objectId

[full-ci] [tests-only] Added test for sending share invitation to wrong objectId
  • Loading branch information
grgprarup authored Jan 25, 2024
2 parents 18a62b5 + c937838 commit 5d96e9b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 10 deletions.
47 changes: 47 additions & 0 deletions tests/acceptance/features/apiSharingNg/shareInvitations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1192,3 +1192,50 @@ Feature: Send a sharing invitations
| Viewer | folder | FolderToShare |
| Editor | folder | FolderToShare |
| Uploader | folder | FolderToShare |


Scenario Outline: send share invitation to wrong user id
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 | Viewer |
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:
| resource-type | path |
| file | /textfile1.txt |
| 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 @@ -156,16 +156,20 @@ public function sendShareInvitation(string $user, TableNode $table): ResponseInt
: $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 @@ -208,6 +212,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 5d96e9b

Please sign in to comment.