shareSubItemOfSpace.feature: Used sharingNG for sharing in given step

This commit is contained in:
Prarup Gurung
2024-05-13 16:28:53 +05:45
parent 8a91df10ad
commit f2f2439284
4 changed files with 114 additions and 59 deletions

View File

@@ -294,7 +294,7 @@ The expected failures in this file are from features in the owncloud/ocis repo.
### [500 when deleting share role](https://github.com/owncloud/ocis/issues/8747)
- [apiSpacesShares/shareSubItemOfSpace.feature:147](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/shareSubItemOfSpace.feature#L147)
- [apiSpacesShares/shareSubItemOfSpace.feature:159](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/shareSubItemOfSpace.feature#L159)
- 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.

View File

@@ -41,9 +41,11 @@ Feature: Share a file or folder that is inside a space
Scenario Outline: user participant of the project space with manager role can share an entity to another user
Given user "Alice" has shared a space "share sub-item" with settings:
| shareWith | Brian |
| role | manager |
Given user "Alice" has sent the following space share invitation:
| space | share sub-item |
| sharee | Brian |
| shareType | user |
| permissionsRole | Manager |
When user "Brian" creates a share inside of space "share sub-item" with settings:
| path | <resource> |
| shareWith | Bob |
@@ -64,9 +66,11 @@ Feature: Share a file or folder that is inside a space
@skipOnRevaMaster
Scenario Outline: user participant of the project space without space manager role cannot share an entity to another user
Given user "Alice" has shared a space "share sub-item" with settings:
| shareWith | Brian |
| role | <space-role> |
Given user "Alice" has sent the following space share invitation:
| space | share sub-item |
| sharee | Brian |
| shareType | user |
| permissionsRole | <space-role> |
When user "Brian" creates a share inside of space "share sub-item" with settings:
| path | <resource> |
| shareWith | Bob |
@@ -75,17 +79,19 @@ Feature: Share a file or folder that is inside a space
And the OCS status code should be "403"
And the OCS status message should be "No share permission"
Examples:
| resource | space-role |
| folder | editor |
| file.txt | editor |
| file.txt | viewer |
| folder | viewer |
| resource | space-role |
| folder | Space Editor |
| file.txt | Space Editor |
| file.txt | Space Viewer |
| folder | Space Viewer |
Scenario Outline: user participant of the project space can see the created resources share
Given user "Alice" has shared a space "share sub-item" with settings:
| shareWith | Brian |
| role | <space-role> |
Given user "Alice" has sent the following space share invitation:
| space | share sub-item |
| sharee | Brian |
| shareType | user |
| permissionsRole | <space-role> |
When user "Alice" creates a share inside of space "share sub-item" with settings:
| path | file.txt |
| shareWith | Bob |
@@ -93,10 +99,10 @@ Feature: Share a file or folder that is inside a space
Then for user "Alice" the space "share sub-item" should contain the last created share of the file "file.txt"
And for user "Brian" the space "share sub-item" should contain the last created share of the file "file.txt"
Examples:
| space-role |
| editor |
| viewer |
| manager |
| space-role |
| Space Editor |
| Space Viewer |
| Manager |
Scenario: user shares the folder to the group
@@ -117,11 +123,14 @@ Feature: Share a file or folder that is inside a space
Scenario: user changes the expiration date
Given user "Alice" has created a share inside of space "share sub-item" with settings:
| path | folder |
| shareWith | Brian |
| role | viewer |
| expireDate | 2042-01-01T23:59:59+0100 |
Given using SharingNG
And user "Alice" has sent the following resource share invitation:
| resource | folder |
| space | share sub-item |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expireDate | 2042-01-01T23:59:59.000Z |
When user "Alice" changes the last share with settings:
| expireDate | 2044-01-01T23:59:59.999+01:00 |
| role | viewer |
@@ -131,11 +140,14 @@ Feature: Share a file or folder that is inside a space
Scenario: user deletes the expiration date
Given user "Alice" has created a share inside of space "share sub-item" with settings:
| path | folder |
| shareWith | Brian |
| role | viewer |
| expireDate | 2042-01-01T23:59:59+0100 |
Given using SharingNG
And user "Alice" has sent the following resource share invitation:
| resource | folder |
| space | share sub-item |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expireDate | 2042-01-01T23:59:59.000Z |
When user "Alice" changes the last share with settings:
| expireDate | |
| role | viewer |
@@ -143,39 +155,47 @@ Feature: Share a file or folder that is inside a space
And the information about the last share for user "Brian" should include
| expiration | |
@issue-8747
Scenario: user cannot delete share role
Given using OCS API version "<ocs_api_version>"
And user "Alice" has created a share inside of space "share sub-item" with settings:
| path | folder |
| shareWith | Brian |
| role | viewer |
| expireDate | 2042-01-01T23:59:59+0100 |
And using SharingNG
And user "Alice" has sent the following resource share invitation:
| resource | folder |
| space | share sub-item |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expireDate | 2042-01-01T23:59:59.000Z |
When user "Alice" changes the last share with settings:
| role | |
Then the HTTP status code should be "400"
Scenario: check the end of expiration date in user share
Given user "Alice" has created a share inside of space "share sub-item" with settings:
| path | folder |
| shareWith | Brian |
| role | viewer |
| expireDate | 2042-01-01T23:59:59+0100 |
When user "Alice" expires the last share
Given using SharingNG
And user "Alice" has sent the following resource share invitation:
| resource | folder |
| space | share sub-item |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| expireDate | 2042-01-01T23:59:59.000Z |
When user "Alice" expires the last share of resource "folder" inside of the space "share sub-item"
Then the HTTP status code should be "200"
And as "Brian" folder "Shares/folder" should not exist
@issue-5823
Scenario: check the end of expiration date in group share
Given group "sales" has been created
And using SharingNG
And the administrator has added a user "Brian" to the group "sales" using the Graph API
And user "Alice" has created a share inside of space "share sub-item" with settings:
| path | folder |
| shareWith | sales |
| shareType | 1 |
| role | viewer |
| expireDate | 2042-01-01T23:59:59+0100 |
When user "Alice" expires the last share
And user "Alice" has sent the following resource share invitation:
| resource | folder |
| space | share sub-item |
| sharee | sales |
| shareType | group |
| permissionsRole | Viewer |
| expireDate | 2042-01-01T23:59:59.000Z |
When user "Alice" expires the last share of resource "folder" inside of the space "share sub-item"
Then the HTTP status code should be "200"
And as "Brian" folder "Shares/folder" should not exist

View File

@@ -1934,10 +1934,11 @@ trait Sharing {
* @param TableNode $table
*
* @return void
* @throws Exception
*/
public function userGetsTheLastShareSharedWithHimUsingTheSharingApi(string $user, TableNode $table):void {
$user = $this->getActualUsername($user);
$shareId = (string) $this->getLastCreatedPublicShare()->id;
$shareId = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
$response = $this->getShareData($user, $shareId);
$this->checkFields($user, $table, $response);
}

View File

@@ -2244,7 +2244,8 @@ class SpacesContext implements Context {
$this->featureContext->getStepLineRef()
);
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
$this->featureContext->addToCreatedPublicShares($responseXml->data);
$sharer = (string) $responseXml->data->uid_owner;
$this->featureContext->addToCreatedUserGroupshares($sharer, $responseXml->data);
return $response;
}
@@ -2314,7 +2315,7 @@ class SpacesContext implements Context {
* @throws JsonException
*/
public function updateSharedResource(string $user, array $rows):ResponseInterface {
$shareId = (string) $this->featureContext->getLastCreatedPublicShare()->id;
$shareId = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedUserGroupShareID() : $this->featureContext->getLastCreatedUserGroupShareId();
$fullUrl = $this->baseUrl . $this->ocsApiUrl . '/' . $shareId;
return HttpRequestHelper::sendRequest(
$fullUrl,
@@ -2328,17 +2329,44 @@ class SpacesContext implements Context {
}
/**
* @When /^user "([^"]*)" expires the last share$/
* @When user :user expires the last share of resource :resource inside of the space :spaceName
*
* @param string $user
* @param string $resource
* @param string $spaceName
*
* @return void
* @throws GuzzleException|JsonException
*/
public function userExpiresLastResourceShare(string $user): void {
public function userExpiresTheLastShareOfResourceInsideOfTheSpace(string $user, string $resource, string $spaceName): void {
$dateTime = new DateTime('yesterday');
$rows['expireDate'] = $dateTime->format('Y-m-d\\TH:i:sP');
$rows['permissions'] = (string) $this->featureContext->getLastCreatedPublicShare()->permissions;
$this->featureContext->setResponse($this->updateSharedResource($user, $rows));
if ($this->featureContext->isUsingSharingNG()) {
if (!\in_array($spaceName, ['Personal', 'Shares'])) {
$space = $this->getSpaceByName($user, $spaceName);
$itemId = $this->getResourceId($user, $spaceName, $resource);
} else {
$space = $this->getCreatedSpace($spaceName);
$itemId = $space['fileId'];
}
$body['expirationDateTime'] = $rows['expireDate'];
$permissionID = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
$this->featureContext->setResponse(
GraphHelper::updateShare(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$space["id"],
$itemId,
\json_encode($body),
$permissionID
)
);
} else {
$rows['permissions'] = (string)$this->featureContext->getLastCreatedUserGroupShare()->permissions;
$this->featureContext->setResponse($this->updateSharedResource($user, $rows));
}
}
/**
@@ -3410,12 +3438,12 @@ class SpacesContext implements Context {
/**
* @Then /^for user "([^"]*)" the space "([^"]*)" should (not|)\s?contain the last created public link$/
* @Then /^for user "([^"]*)" the space "([^"]*)" should (not|)\s?contain the last created public link of the file "([^"]*)"$/
* @Then /^for user "([^"]*)" the space "([^"]*)" should (not|)\s?contain the last created share of the file "([^"]*)"$/
* @Then /^for user "([^"]*)" the space "([^"]*)" should (not|)\s?contain the last created (public link|share) of the file "([^"]*)"$/
*
* @param string $user
* @param string $spaceName
* @param string $shouldOrNot (not|)
* @param string $shareType
* @param string $fileName
*
* @return void
@@ -3426,6 +3454,7 @@ class SpacesContext implements Context {
string $user,
string $spaceName,
string $shouldOrNot,
string $shareType = 'public link',
string $fileName = ''
): void {
if (!empty($fileName)) {
@@ -3449,8 +3478,13 @@ class SpacesContext implements Context {
if ($should) {
Assert::assertNotEmpty($responseArray, __METHOD__ . ' Response should contain a link, but it is empty');
foreach ($responseArray as $element) {
$expectedLinkId = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareID() : (string) $this->featureContext->getLastCreatedPublicShare()->id;
Assert::assertEquals($element["id"], $expectedLinkId, "link IDs are different");
if ($shareType === 'public link') {
$expectedLinkId = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareID() : (string) $this->featureContext->getLastCreatedPublicShare()->id;
Assert::assertEquals($element["id"], $expectedLinkId, "link IDs are different");
} else {
$expectedShareId = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedUserGroupShareID() : (string)$this->featureContext->getLastCreatedUserGroupShareId();
Assert::assertEquals($element["id"], $expectedShareId, "share IDs are different");
}
}
} else {
Assert::assertEmpty($responseArray, __METHOD__ . ' Response should be empty');