Skip to content

Commit

Permalink
[tests-only][full-ci]Added test to update role and expiration date fo…
Browse files Browse the repository at this point in the history
…r share link (v1beta1) (owncloud#8071)

* Added test to update role and expiration date for share link

Signed-off-by: [email protected] <[email protected]>

* Review address

---------

Signed-off-by: [email protected] <[email protected]>
  • Loading branch information
SagarGi authored and 2403905 committed Jan 24, 2024
1 parent 745b4a5 commit 4f55994
Show file tree
Hide file tree
Showing 5 changed files with 321 additions and 20 deletions.
35 changes: 35 additions & 0 deletions tests/TestHelpers/GraphHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1666,4 +1666,39 @@ public static function createLinkShare(
$body
);
}

/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $user
* @param string $password
* @param string $spaceId
* @param string $itemId
* @param mixed $body
* @param string $shareId
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function updateLinkShare(
string $baseUrl,
string $xRequestId,
string $user,
string $password,
string $spaceId,
string $itemId,
$body,
string $shareId
): ResponseInterface {
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/items/$itemId/permissions/$shareId");
return HttpRequestHelper::sendRequestOnce(
$url,
$xRequestId,
'PATCH',
$user,
$password,
self::getRequestHeaders(),
$body
);
}
}
15 changes: 9 additions & 6 deletions tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,14 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiLocks/lockFiles.feature:457](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L457)

### [blocksDownload link type is not implemented yet (sharing-ng)](https://github.com/owncloud/ocis/issues/7879)
- [apiSharingNg/createLink.feature:78](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/createLink.feature#L78)
- [apiSharingNg/createLink.feature:147](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/createLink.feature#L147)
- [apiSharingNg/createLink.feature:225](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/createLink.feature#L225)
- [apiSharingNg/createLink.feature:301](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/createLink.feature#L301)
- [apiSharingNg/createLink.feature:372](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/createLink.feature#L372)

- [apiSharingNg/linkShare.feature:78](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L78)
- [apiSharingNg/linkShare.feature:147](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L147)
- [apiSharingNg/linkShare.feature:225](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L225)
- [apiSharingNg/linkShare.feature:301](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L301)
- [apiSharingNg/linkShare.feature:372](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L372)
- [apiSharingNg/linkShare.feature:445](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L445)
- [apiSharingNg/linkShare.feature:447](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L447)
- [apiSharingNg/linkShare.feature:448](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L448)
- [apiSharingNg/linkShare.feature:449](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L449)
- Note: always have an empty line at the end of this file.
The bash script that processes this file requires that the last line has a newline on the end.
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ Feature: Create a share link for a resource
| edit |
| blocksDownload |

@env-config
@env-config @issue-7879
Scenario Outline: create a link share of a file without password
Given the following configs have been set:
| config | value |
Expand Down Expand Up @@ -370,3 +370,151 @@ Feature: Create a share link for a resource
| view |
| edit |
| blocksDownload |

@issue-7879
Scenario Outline: update role of a file's link share
Given user "Alice" has uploaded file with content "other data" to "textfile1.txt"
And user "Alice" has created the following link share:
| resourceType | file |
| resource | textfile1.txt |
| space | Personal |
| role | <previousRole> |
| password | %public% |
When user "Alice" updates the last public link share using the Graph API with
| resourceType | file |
| resource | textfile1.txt |
| space | Personal |
| role | <newRole> |
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"hasPassword",
"id",
"link"
],
"properties": {
"hasPassword": {
"type": "boolean",
"enum": [true]
},
"id": {
"type": "string",
"pattern": "^[a-zA-Z]{15}$"
},
"link": {
"type": "object",
"required": [
"@libre.graph.displayName",
"@libre.graph.quickLink",
"preventsDownload",
"type",
"webUrl"
],
"properties": {
"@libre.graph.displayName": {
"type": "string",
"enum": [""]
},
"@libre.graph.quickLink": {
"type": "boolean",
"enum": [false]
},
"preventsDownload": {
"type": "boolean",
"enum": [false]
},
"type": {
"type": "string",
"enum": ["<newRole>"]
},
"webUrl": {
"type": "string",
"pattern": "^%base_url%\/s\/[a-zA-Z]{15}$"
}
}
}
}
}
"""
Examples:
| previousRole | newRole |
| view | edit |
| view | blocksDownload |
| edit | view |
| edit | blocksDownload |
| blocksDownload | edit |
| blocksDownload | blocksDownload |


Scenario: update expiration date of a file's link share
Given user "Alice" has uploaded file with content "other data" to "textfile1.txt"
And user "Alice" has created the following link share:
| resourceType | file |
| resource | textfile1.txt |
| space | Personal |
| role | view |
| password | %public% |
| expirationDateTime | 2200-07-15T14:00:00.000Z |
When user "Alice" updates the last public link share using the Graph API with
| resourceType | file |
| resource | textfile1.txt |
| space | Personal |
| expirationDateTime | 2201-07-15T14:00:00.000Z |
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"hasPassword",
"id",
"link",
"expirationDateTime"
],
"properties": {
"hasPassword": {
"type": "boolean",
"enum": [true]
},
"id": {
"type": "string",
"pattern": "^[a-zA-Z]{15}$"
},
"expirationDateTime": {
"type": "string",
"enum": ["2201-07-15T23:59:59Z"]
},
"link": {
"type": "object",
"required": [
"@libre.graph.displayName",
"@libre.graph.quickLink",
"preventsDownload",
"type",
"webUrl"
],
"properties": {
"@libre.graph.quickLink": {
"type": "boolean",
"enum": [false]
},
"preventsDownload": {
"type": "boolean",
"enum": [false]
},
"type": {
"type": "string",
"enum": ["view"]
},
"webUrl": {
"type": "string",
"pattern": "^%base_url%\/s\/[a-zA-Z]{15}$"
}
}
}
}
}
"""
32 changes: 32 additions & 0 deletions tests/acceptance/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ trait Sharing {
*/
private array $createdPublicShares = [];

/**
* @var array
*/
private array $shareNgCreatedLinkShares = [];

/**
* @return string
*/
Expand All @@ -98,6 +103,22 @@ public function addToCreatedPublicShares(SimpleXMLElement $shareData): void {
$this->createdPublicShares[] = $shareData;
}

/**
* @param ResponseInterface $response
*
* @return void
*/
public function shareNgAddToCreatedLinkShares(ResponseInterface $response): void {
$this->shareNgCreatedLinkShares[] = $response;
}

/**
* @return ResponseInterface|null
*/
public function shareNgGetLastCreatedLinkShare():?ResponseInterface {
return \end($this->shareNgCreatedLinkShares);
}

/**
* @param string $sharer
* @param SimpleXMLElement $shareData
Expand Down Expand Up @@ -152,6 +173,17 @@ public function getSharesEndpointPath(?string $postfix = ''):string {
return "/apps/files_sharing/api/v$this->sharingApiVersion/shares$postfix";
}

/**
* @return string
*/
public function shareNgGetLastCreatedLinkShareID(): string {
$lastResponse = $this->shareNgGetLastCreatedLinkShare();
if (!isset($this->getJsonDecodedResponse($lastResponse)['id'])) {
throw new Error('Response did not contain share id ' . $this->getJsonDecodedResponse($lastResponse)['id'] . ' for the created public link');
}
return $this->getJsonDecodedResponse($lastResponse)['id'];
}

/**
* Split given permissions string each separated with "," into array of strings
*
Expand Down
Loading

0 comments on commit 4f55994

Please sign in to comment.