Skip to content

Commit

Permalink
[full-ci][tests-only][backport]Add tests to check the end of an expir…
Browse files Browse the repository at this point in the history
…ation date (#5834)

* Add tests to check the end of an expiration date

fix style

fix style

enable group share test

skip group share test on ocis

* add correct skip tag
  • Loading branch information
SwikritiT authored Mar 16, 2023
1 parent 81b479a commit 47cddcd
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 20 deletions.
33 changes: 33 additions & 0 deletions tests/acceptance/features/apiSpacesShares/shareSpaces.feature
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,36 @@ Feature: Share spaces
| manager |
| editor |
| viewer |

@skipOnStable2.0
Scenario Outline: check the end of expiration of a space in user share
Given user "Alice" has shared a space "share space" with settings:
| shareWith | Brian |
| role | <role> |
| expireDate | 2042-03-25T23:59:59+0100 |
When user "Alice" expires the user share of space "share space" for user "Brian"
Then the HTTP status code should be "200"
And the user "Brian" should not have a space called "share space"
Examples:
| role |
| manager |
| editor |
| viewer |

@skipOnStable2.0
Scenario Outline: check the end of expiration of a space in group share
Given group "sales" has been created
And the administrator has added a user "Brian" to the group "sales" using GraphApi
And user "Alice" has shared a space "share space" with settings:
| shareWith | sales |
| shareType | 8 |
| role | <role> |
| expireDate | 2042-03-25T23:59:59+0100 |
When user "Alice" expires the group share of space "share space" for group "sales"
Then the HTTP status code should be "200"
And the user "Brian" should not have a space called "share space"
Examples:
| role |
| manager |
| editor |
| viewer |
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,30 @@ Feature: Share a file or folder that is inside a space
Then the HTTP status code should be "200"
And the information about the last share for user "Brian" should include
| expiration | |

@skipOnStable2.0
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 |
And user "Brian" has accepted share "/folder" offered by user "Alice"
When user "Alice" expires the last share
Then the HTTP status code should be "200"
Then as "Brian" folder "Shares/folder" should not exist

@issue-5823 @skipOnStable2.0
Scenario: check the end of expiration date in group share
Given group "sales" has been created
And the administrator has added a user "Brian" to the group "sales" using GraphApi
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 |
And user "Brian" has accepted share "/folder" offered by user "Alice"
When user "Alice" expires the last share
Then the HTTP status code should be "200"
Then as "Brian" folder "Shares/folder" should not exist
94 changes: 74 additions & 20 deletions tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1998,9 +1998,22 @@ public function sendShareSpaceRequest(
string $spaceName,
TableNode $table
): void {
$rows = $table->getRowsHash();
$this->featureContext->setResponse($this->shareSpace($user, $spaceName, $rows));
}

/**
* @param string $user
* @param string $spaceName
* @param array $rows
*
* @return ResponseInterface
*
* @throws GuzzleException
*/
public function shareSpace(string $user, string $spaceName, array $rows): ResponseInterface {
$space = $this->getSpaceByName($user, $spaceName);
$availableRoleToAssignToShareSpace = ['manager', 'editor', 'viewer'];
$rows = $table->getRowsHash();
if (isset($rows['role']) && !\in_array(\strtolower($rows['role']), $availableRoleToAssignToShareSpace)) {
throw new Error("The Selected " . $rows['role'] . " Cannot be Found");
}
Expand All @@ -2017,16 +2030,34 @@ public function sendShareSpaceRequest(
];

$fullUrl = $this->baseUrl . $this->ocsApiUrl;
$this->featureContext->setResponse(
$this->sendPostRequestToUrl(
$fullUrl,
$user,
$this->featureContext->getPasswordForUser($user),
$body
)

return $this->sendPostRequestToUrl(
$fullUrl,
$user,
$this->featureContext->getPasswordForUser($user),
$body
);
}

/**
* @When /^user "([^"]*)" expires the (user|group) share of space "([^"]*)" for (?:user|group) "([^"]*)"$/
*
* @param string $user
* @param string $shareType
* @param string $spaceName
* @param string $memberUser
*
* @return void
* @throws GuzzleException
*/
public function userExpiresTheShareOfSpaceForUser(string $user, string $shareType, string $spaceName, string $memberUser) {
$dateTime = new DateTime('yesterday');
$rows['expireDate'] = $dateTime->format('Y-m-d\\TH:i:sP');
$rows['shareWith'] = $memberUser;
$rows['shareType'] = ($shareType === 'user') ? 7 : 8;
$this->featureContext->setResponse($this->shareSpace($user, $spaceName, $rows));
}

/**
* @When /^user "([^"]*)" creates a share inside of space "([^"]*)" with settings:$/
*
Expand Down Expand Up @@ -2100,26 +2131,49 @@ public function hasSharedTheFollowingEntityInsideOfSpace(
* @return void
* @throws GuzzleException
*/
public function changeShareResource(
public function changeShareResourceWithSettings(
string $user,
TableNode $table
): void {
$shareId = $this->featureContext->getLastPublicLinkShareId();
$rows = $table->getRowsHash();
$this->featureContext->setResponse($this->updateSharedResource($user, $rows));
}

/**
* @param string $user
* @param array $rows
*
* @return ResponseInterface
*
* @throws GuzzleException
* @throws JsonException
*/
public function updateSharedResource(string $user, array $rows):ResponseInterface {
$shareId = $this->featureContext->getLastPublicLinkShareId();
$fullUrl = $this->baseUrl . $this->ocsApiUrl . '/' . $shareId;
$this->featureContext->setResponse(
HttpRequestHelper::sendRequest(
$fullUrl,
"",
"PUT",
$this->featureContext->getActualUsername($user),
$this->featureContext->getPasswordForUser($user),
null,
$rows
)
return HttpRequestHelper::sendRequest(
$fullUrl,
"",
"PUT",
$this->featureContext->getActualUsername($user),
$this->featureContext->getPasswordForUser($user),
null,
$rows
);
}

/**
* @When /^user "([^"]*)" expires the last share$/
*
* @param string $user
*
* @return void
*/
public function userExpiresLastResourceShare(string $user): void {
$dateTime = new DateTime('yesterday');
$rows['expireDate'] = $dateTime->format('Y-m-d\\TH:i:sP');
$this->featureContext->setResponse($this->updateSharedResource($user, $rows));
}
/**
* @When /^user "([^"]*)" creates a public link share inside of space "([^"]*)" with settings:$/
*
Expand Down

0 comments on commit 47cddcd

Please sign in to comment.