Skip to content

Commit

Permalink
adding test for updating permission of a share
Browse files Browse the repository at this point in the history
  • Loading branch information
nirajacharya2 committed Feb 1, 2024
1 parent 80ef9b8 commit bd25fea
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 1 deletion.
72 changes: 72 additions & 0 deletions tests/acceptance/features/apiSharingNg/sharedByMe.feature
Original file line number Diff line number Diff line change
Expand Up @@ -612,3 +612,75 @@ Feature: resources shared by user
}
}
"""


Scenario: user updates experation 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 permissions of last share using the Graph API:
| resourceType | file |
| 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%$"
}
]
}
}
}
"""
27 changes: 26 additions & 1 deletion tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,20 @@ public function userSendsTheFollowingShareInvitationUsingTheGraphApi(string $use
);
}

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

/**
* @When /^user "([^"]*)" creates the following link share using the Graph API:$/
*
Expand Down Expand Up @@ -275,6 +289,17 @@ public function userHasCreatedTheFollowingLinkShare(string $user, TableNode $bo
* @throws Exception
*/
public function userUpdatesLastPublicLinkShareUsingTheGraphApiWith(string $user, TableNode $body):void {
$this->updateLinkShare($user, $body, $this->featureContext->shareNgGetLastCreatedLinkShareID());
}

/**
* @param string $user
* @param TableNode $body
* @param string $shareID
*
* @return void
*/
public function updateLinkShare(string $user, TableNode $body, string $shareID) {
$bodyRows = $body->getRowsHash();
$space = $bodyRows['space'];
$resourceType = $bodyRows['resourceType'];
Expand Down Expand Up @@ -315,7 +340,7 @@ public function userUpdatesLastPublicLinkShareUsingTheGraphApiWith(string $user,
$spaceId,
$itemId,
\json_encode($body),
$this->featureContext->shareNgGetLastCreatedLinkShareID()
$shareID
);
$this->featureContext->setResponse($response);
}
Expand Down

0 comments on commit bd25fea

Please sign in to comment.