[tests-only][full-ci] Add tests for checking the end of expiration date (#5819)

* Add tests to check the end of an expiration date

* fix style

* fix style

* enable group share test

* skip group share test on ocis
This commit is contained in:
Swikriti Tripathi
2023-03-15 09:27:45 +05:45
committed by GitHub
parent 872f72b3c7
commit 173850a35c
3 changed files with 135 additions and 21 deletions

View File

@@ -427,4 +427,37 @@ Feature: Share spaces
| role |
| manager |
| editor |
| viewer |
| viewer |
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 |
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 |

View File

@@ -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 | |
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 @skip
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

View File

@@ -1907,9 +1907,22 @@ class SpacesContext implements Context {
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");
}
@@ -1926,16 +1939,34 @@ class SpacesContext implements Context {
];
$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:$/
*
@@ -2009,26 +2040,49 @@ class SpacesContext implements Context {
* @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:$/
*