Skip to content

Commit

Permalink
Added test for sharingNg for endpoint sharedByMe
Browse files Browse the repository at this point in the history
Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com>

Added tests for list shared by me

Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com>

adding test for updating permission of a share
  • Loading branch information
SagarGi authored and nirajacharya2 committed Feb 2, 2024
1 parent 10aa33c commit afd43a1
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 7 deletions.
71 changes: 71 additions & 0 deletions tests/acceptance/features/apiSharingNg/sharedByMe.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1463,3 +1463,74 @@ Feature: resources shared by user
}
}
"""


Scenario: user updates expiration date of a share
Given user "Alice" has uploaded file with content "hello world" to "testfile.txt"
And user "Alice" has sent the following share invitation:
| resource | testfile.txt |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
When user "Alice" updates the last share with the following using the Graph API:
| space | Personal |
| resource | testfile.txt |
| expirationDateTime | 2200-07-15T14:00:00Z |
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"expirationDateTime",
"grantedToV2",
"id",
"roles"
],
"properties": {
"expirationDateTime": {
"type": "string",
"enum": ["2200-07-15T14:00:00Z"]
},
"grantedToV2": {
"type": "object",
"required": [
"user"
],
"properties":{
"user": {
"type": "object",
"required": [
"displayName",
"id"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Brian Murphy"]
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
}
}
}
}
},
"id": {
"type": "string",
"pattern": "^%permissions_id_pattern%$"
},
"roles": {
"type": "array",
"items": [
{
"type": "string",
"pattern": "^%role_id_pattern%$"
}
]
}
}
}
"""
34 changes: 27 additions & 7 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,20 @@ public function userSendsTheFollowingShareInvitationUsingTheGraphApi(string $use
);
}

/**
* @When user :user updates the last share with the following using the Graph API:
*
* @param string $user
* @param TableNode $table
*
* @return void
*/
public function userUpdatesThePermissions($user, TableNode $table) {
$response = $this->featureContext->shareNgGetLastCreatedUserGroupShare();
$permissionID = json_decode($response->getBody()->getContents())->value[0]->id;
$this->updateShare($user, $table, $permissionID);
}

/**
* @When user :user sends the following share invitation with file-id :fileId using the Graph API:
*
Expand Down Expand Up @@ -287,16 +301,22 @@ public function userHasCreatedTheFollowingLinkShare(string $user, TableNode $bo
* @throws Exception
*/
public function userUpdatesLastPublicLinkShareUsingTheGraphApiWith(string $user, TableNode $body):void {
$this->updateShare($user, $body, $this->featureContext->shareNgGetLastCreatedLinkShareID());
}

/**
* @param string $user
* @param TableNode $body
* @param string $permissionID
*
* @return void
*/
public function updateShare(string $user, TableNode $body, string $permissionID) {
$bodyRows = $body->getRowsHash();
$space = $bodyRows['space'];
$resourceType = $bodyRows['resourceType'];
$resource = $bodyRows['resource'];
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
if ($resourceType === 'folder') {
$itemId = $this->spacesContext->getResourceId($user, $space, $resource);
} else {
$itemId = $this->spacesContext->getFileId($user, $space, $resource);
}
$itemId = $this->spacesContext->getResourceId($user, $space, $resource);

if (\array_key_exists('role', $bodyRows) && \array_key_exists('expirationDateTime', $bodyRows)) {
$body = [
Expand Down Expand Up @@ -327,7 +347,7 @@ public function userUpdatesLastPublicLinkShareUsingTheGraphApiWith(string $user,
$spaceId,
$itemId,
\json_encode($body),
$this->featureContext->shareNgGetLastCreatedLinkShareID()
$permissionID
);
$this->featureContext->setResponse($response);
}
Expand Down

0 comments on commit afd43a1

Please sign in to comment.