adding test for updating role of a share (#8329)
This commit is contained in:
@@ -1756,7 +1756,7 @@ class GraphHelper {
|
|||||||
* @return ResponseInterface
|
* @return ResponseInterface
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
*/
|
*/
|
||||||
public static function updateLinkShare(
|
public static function updateShare(
|
||||||
string $baseUrl,
|
string $baseUrl,
|
||||||
string $xRequestId,
|
string $xRequestId,
|
||||||
string $user,
|
string $user,
|
||||||
|
|||||||
@@ -1451,74 +1451,3 @@ 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%$"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
|
|||||||
@@ -0,0 +1,160 @@
|
|||||||
|
Feature: Update permission of a share
|
||||||
|
As a user
|
||||||
|
I want to update resources shared with me
|
||||||
|
So that I can have more control over my shares and manage it
|
||||||
|
https://owncloud.dev/libre-graph-api/#/drives.permissions/UpdatePermission
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given these users have been created with default attributes and without skeleton files:
|
||||||
|
| username |
|
||||||
|
| Alice |
|
||||||
|
| Brian |
|
||||||
|
|
||||||
|
|
||||||
|
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 |
|
||||||
|
| expirationDateTime | 2025-07-15T14:00:00Z |
|
||||||
|
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%$"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
Scenario Outline: user updates role of a share
|
||||||
|
Given user "Alice" has uploaded file with content "to share" to "/textfile1.txt"
|
||||||
|
And user "Alice" has created folder "FolderToShare"
|
||||||
|
And user "Alice" has sent the following share invitation:
|
||||||
|
| resource | <path> |
|
||||||
|
| space | Personal |
|
||||||
|
| sharee | Brian |
|
||||||
|
| shareType | user |
|
||||||
|
| permissionsRole | <previous-permissions-role> |
|
||||||
|
When user "Alice" updates the last share with the following using the Graph API:
|
||||||
|
| permissionsRole | <new-permissions-role> |
|
||||||
|
| space | Personal |
|
||||||
|
| resource | <path> |
|
||||||
|
Then the HTTP status code should be "200"
|
||||||
|
And the JSON data of the response should match
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"grantedToV2",
|
||||||
|
"id",
|
||||||
|
"roles"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"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%$"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
Examples:
|
||||||
|
| previous-permissions-role | path | new-permissions-role |
|
||||||
|
| Viewer | textfile1.txt | File Editor |
|
||||||
|
| File Editor | textfile1.txt | Viewer |
|
||||||
|
| Viewer | FolderToShare | Uploader |
|
||||||
|
| Viewer | FolderToShare | Editor |
|
||||||
|
| Editor | FolderToShare | Viewer |
|
||||||
|
| Editor | FolderToShare | Uploader |
|
||||||
|
| Uploader | FolderToShare | Editor |
|
||||||
|
| Uploader | FolderToShare | Viewer |
|
||||||
@@ -243,7 +243,7 @@ class SharingNgContext implements Context {
|
|||||||
$response = $this->featureContext->shareNgGetLastCreatedUserGroupShare();
|
$response = $this->featureContext->shareNgGetLastCreatedUserGroupShare();
|
||||||
$permissionID = json_decode($response->getBody()->getContents())->value[0]->id;
|
$permissionID = json_decode($response->getBody()->getContents())->value[0]->id;
|
||||||
$this->featureContext->setResponse(
|
$this->featureContext->setResponse(
|
||||||
$this->updateShare(
|
$this->updateResourceShare(
|
||||||
$user,
|
$user,
|
||||||
$table,
|
$table,
|
||||||
$permissionID
|
$permissionID
|
||||||
@@ -251,6 +251,41 @@ class SharingNgContext implements Context {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $user
|
||||||
|
* @param TableNode $body
|
||||||
|
* @param string $permissionID
|
||||||
|
*
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
public function updateResourceShare(string $user, TableNode $body, string $permissionID): ResponseInterface {
|
||||||
|
$bodyRows = $body->getRowsHash();
|
||||||
|
$space = $bodyRows['space'];
|
||||||
|
$resource = $bodyRows['resource'];
|
||||||
|
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
|
||||||
|
$itemId = $this->spacesContext->getResourceId($user, $space, $resource);
|
||||||
|
$body = [];
|
||||||
|
|
||||||
|
if (\array_key_exists('permissionsRole', $bodyRows)) {
|
||||||
|
$body["roles"] = [GraphHelper::getPermissionsRoleIdByName($bodyRows['permissionsRole'])];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (\array_key_exists('expirationDateTime', $bodyRows)) {
|
||||||
|
$body["expirationDateTime"] = $bodyRows['expirationDateTime'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return GraphHelper::updateShare(
|
||||||
|
$this->featureContext->getBaseUrl(),
|
||||||
|
$this->featureContext->getStepLineRef(),
|
||||||
|
$user,
|
||||||
|
$this->featureContext->getPasswordForUser($user),
|
||||||
|
$spaceId,
|
||||||
|
$itemId,
|
||||||
|
\json_encode($body),
|
||||||
|
$permissionID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When user :user sends the following share invitation with file-id :fileId using the Graph API:
|
* @When user :user sends the following share invitation with file-id :fileId using the Graph API:
|
||||||
*
|
*
|
||||||
@@ -308,7 +343,7 @@ class SharingNgContext implements Context {
|
|||||||
*/
|
*/
|
||||||
public function userUpdatesLastPublicLinkShareUsingTheGraphApiWith(string $user, TableNode $body):void {
|
public function userUpdatesLastPublicLinkShareUsingTheGraphApiWith(string $user, TableNode $body):void {
|
||||||
$this->featureContext->setResponse(
|
$this->featureContext->setResponse(
|
||||||
$this->updateShare(
|
$this->updateLinkShare(
|
||||||
$user,
|
$user,
|
||||||
$body,
|
$body,
|
||||||
$this->featureContext->shareNgGetLastCreatedLinkShareID()
|
$this->featureContext->shareNgGetLastCreatedLinkShareID()
|
||||||
@@ -323,35 +358,23 @@ class SharingNgContext implements Context {
|
|||||||
*
|
*
|
||||||
* @return ResponseInterface
|
* @return ResponseInterface
|
||||||
*/
|
*/
|
||||||
public function updateShare(string $user, TableNode $body, string $permissionID): ResponseInterface {
|
public function updateLinkShare(string $user, TableNode $body, string $permissionID): ResponseInterface {
|
||||||
$bodyRows = $body->getRowsHash();
|
$bodyRows = $body->getRowsHash();
|
||||||
$space = $bodyRows['space'];
|
$space = $bodyRows['space'];
|
||||||
$resource = $bodyRows['resource'];
|
$resource = $bodyRows['resource'];
|
||||||
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
|
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
|
||||||
$itemId = $this->spacesContext->getResourceId($user, $space, $resource);
|
$itemId = $this->spacesContext->getResourceId($user, $space, $resource);
|
||||||
|
$body = [];
|
||||||
|
|
||||||
if (\array_key_exists('role', $bodyRows) && \array_key_exists('expirationDateTime', $bodyRows)) {
|
if (\array_key_exists('permissionsRole', $bodyRows)) {
|
||||||
$body = [
|
$body["link"]["type"] = $bodyRows['permissionsRole'];
|
||||||
"expirationDateTime" => $bodyRows['expirationDateTime'],
|
|
||||||
"link" => [
|
|
||||||
"type" => $bodyRows['permissionsRole']
|
|
||||||
]
|
|
||||||
];
|
|
||||||
} elseif (\array_key_exists('permissionsRole', $bodyRows)) {
|
|
||||||
$body = [
|
|
||||||
"link" => [
|
|
||||||
"type" => $bodyRows['permissionsRole']
|
|
||||||
]
|
|
||||||
];
|
|
||||||
} elseif (\array_key_exists('expirationDateTime', $bodyRows)) {
|
|
||||||
$body = [
|
|
||||||
"expirationDateTime" => $bodyRows['expirationDateTime']
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
throw new Error('Expiration date or role is missing to update for share link!');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return GraphHelper::updateLinkShare(
|
if (\array_key_exists('expirationDateTime', $bodyRows)) {
|
||||||
|
$body["expirationDateTime"] = $bodyRows['expirationDateTime'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return GraphHelper::updateShare(
|
||||||
$this->featureContext->getBaseUrl(),
|
$this->featureContext->getBaseUrl(),
|
||||||
$this->featureContext->getStepLineRef(),
|
$this->featureContext->getStepLineRef(),
|
||||||
$user,
|
$user,
|
||||||
|
|||||||
Reference in New Issue
Block a user