mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-30 08:50:49 -06:00
Added test for sharingNg for endpoint sharedByMe (#8311)
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 Co-authored-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com>
This commit is contained in:
@@ -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%$"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
@@ -231,6 +231,26 @@ class SharingNgContext implements Context {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When user :user updates the last share with the following using the Graph API:
|
||||
*
|
||||
* @param string $user
|
||||
* @param TableNode $table
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userUpdatesTheLastShareWithFollowingUsingGraphApi($user, TableNode $table) {
|
||||
$response = $this->featureContext->shareNgGetLastCreatedUserGroupShare();
|
||||
$permissionID = json_decode($response->getBody()->getContents())->value[0]->id;
|
||||
$this->featureContext->setResponse(
|
||||
$this->updateShare(
|
||||
$user,
|
||||
$table,
|
||||
$permissionID
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When user :user sends the following share invitation with file-id :fileId using the Graph API:
|
||||
*
|
||||
@@ -287,16 +307,28 @@ class SharingNgContext implements Context {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userUpdatesLastPublicLinkShareUsingTheGraphApiWith(string $user, TableNode $body):void {
|
||||
$this->featureContext->setResponse(
|
||||
$this->updateShare(
|
||||
$user,
|
||||
$body,
|
||||
$this->featureContext->shareNgGetLastCreatedLinkShareID()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $user
|
||||
* @param TableNode $body
|
||||
* @param string $permissionID
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function updateShare(string $user, TableNode $body, string $permissionID): ResponseInterface {
|
||||
$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 = [
|
||||
@@ -319,7 +351,7 @@ class SharingNgContext implements Context {
|
||||
throw new Error('Expiration date or role is missing to update for share link!');
|
||||
}
|
||||
|
||||
$response = GraphHelper::updateLinkShare(
|
||||
return GraphHelper::updateLinkShare(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$user,
|
||||
@@ -327,9 +359,8 @@ class SharingNgContext implements Context {
|
||||
$spaceId,
|
||||
$itemId,
|
||||
\json_encode($body),
|
||||
$this->featureContext->shareNgGetLastCreatedLinkShareID()
|
||||
$permissionID
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user