Skip to content

Commit

Permalink
added test to send share invitation to unknown group
Browse files Browse the repository at this point in the history
  • Loading branch information
PrajwolAmatya committed Jan 19, 2024
1 parent e1c74f3 commit c4b9850
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
56 changes: 56 additions & 0 deletions tests/acceptance/features/apiSharingNg/shareInvitations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1111,3 +1111,59 @@ Feature: Send a sharing invitations
| Co Owner | folder | FolderToShare |
| Uploader | folder | FolderToShare |
| Manager | folder | FolderToShare |


Scenario Outline: send sharing invitation to non-existing group
Given user "Alice" has uploaded file with content "to share" to "/textfile1.txt"
And user "Alice" has created folder "FolderToShare"
When user "Alice" sends the following share invitation using the Graph API:
| resourceType | <resource-type> |
| resource | <path> |
| space | Personal |
| sharee | nonExistentGroup |
| shareType | group |
| 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",
"enum": [
"generalException"
]
},
"message": {
"type": "string",
"enum": [
"itemNotFound: not found"
]
}
}
}
}
}
"""
Examples:
| permissions-role | resource-type | path |
| Viewer | file | /textfile1.txt |
| File Editor | file | /textfile1.txt |
| Co Owner | file | /textfile1.txt |
| Manager | file | /textfile1.txt |
| Viewer | folder | FolderToShare |
| Editor | folder | FolderToShare |
| Co Owner | folder | FolderToShare |
| Uploader | folder | FolderToShare |
| Manager | folder | FolderToShare |
6 changes: 4 additions & 2 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Psr\Http\Message\ResponseInterface;
use TestHelpers\GraphHelper;
use TestHelpers\WebDavHelper;
use Behat\Gherkin\Node\TableNode;

require_once 'bootstrap.php';
Expand Down Expand Up @@ -149,9 +150,10 @@ public function sendShareInvitation(string $user, TableNode $table): ResponseInt
$shareeIds = [];
foreach ($sharees as $index => $sharee) {
$shareType = $shareTypes[$index];
$shareeIds[] = ($shareType === 'user')
// for non-exiting group or user, generate random id
$shareeIds[] = (($shareType === 'user')
? $this->featureContext->getAttributeOfCreatedUser($sharee, 'id')
: $this->featureContext->getAttributeOfCreatedGroup($sharee, 'id');
: $this->featureContext->getAttributeOfCreatedGroup($sharee, 'id')) ?: WebDavHelper::generateUUIDv4();
}

$permissionsRole = $rows['permissionsRole'] ?? null;
Expand Down

0 comments on commit c4b9850

Please sign in to comment.