Skip to content

Commit fd8d35d

Browse files
committed
test: add flaky step for resource expiration
1 parent 027ffc8 commit fd8d35d

File tree

2 files changed

+83
-26
lines changed

2 files changed

+83
-26
lines changed

tests/acceptance/bootstrap/SpacesContext.php

+57-26
Original file line numberDiff line numberDiff line change
@@ -2695,32 +2695,8 @@ public function userExpiresTheLastShareOfResourceInsideOfTheSpace(
26952695
string $resource,
26962696
string $spaceName
26972697
): void {
2698-
$dateTime = new DateTime('yesterday');
2699-
$rows['expireDate'] = $dateTime->format('Y-m-d\\TH:i:sP');
2700-
if ($this->featureContext->isUsingSharingNG()) {
2701-
$space = $this->getSpaceByName($user, $spaceName);
2702-
$itemId = $this->getResourceId($user, $spaceName, $resource);
2703-
$body['expirationDateTime'] = $rows['expireDate'];
2704-
$permissionID = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
2705-
$response = GraphHelper::updateShare(
2706-
$this->featureContext->getBaseUrl(),
2707-
$this->featureContext->getStepLineRef(),
2708-
$user,
2709-
$this->featureContext->getPasswordForUser($user),
2710-
$space["id"],
2711-
$itemId,
2712-
\json_encode($body),
2713-
$permissionID
2714-
);
2715-
2716-
if ($response->getStatusCode() === 200) {
2717-
$this->featureContext->shareNgAddToCreatedUserGroupShares($response);
2718-
}
2719-
$this->featureContext->setResponse($response);
2720-
} else {
2721-
$rows['permissions'] = (string)$this->featureContext->getLastCreatedUserGroupShare()->permissions;
2722-
$this->featureContext->setResponse($this->updateSharedResource($user, $rows));
2723-
}
2698+
$response = $this->expireResourceShare($user, $resource, $spaceName);
2699+
$this->featureContext->setResponse($response);
27242700
}
27252701

27262702
/**
@@ -4829,4 +4805,59 @@ public function userHasExpiredTheMembershipOfUserFromSpace(
48294805
$rows['shareWith'] = $memberUser;
48304806
$this->featureContext->setResponse($this->shareSpace($user, $spaceName, $rows));
48314807
}
4808+
4809+
/**
4810+
* @param string $user
4811+
* @param string $resource
4812+
* @param string $spaceName
4813+
*
4814+
* @return ResponseInterface
4815+
* @throws GuzzleException|JsonException
4816+
*/
4817+
public function expireResourceShare(string $user, string $resource, string $spaceName): ResponseInterface {
4818+
$rows['expireDate'] = $this->featureContext->formatExpiryDateTime('Y-m-d\\TH:i:sP');
4819+
if ($this->featureContext->isUsingSharingNG()) {
4820+
$space = $this->getSpaceByName($user, $spaceName);
4821+
$itemId = $this->getResourceId($user, $spaceName, $resource);
4822+
$body['expirationDateTime'] = $rows['expireDate'];
4823+
$permissionID = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
4824+
$response = GraphHelper::updateShare(
4825+
$this->featureContext->getBaseUrl(),
4826+
$this->featureContext->getStepLineRef(),
4827+
$user,
4828+
$this->featureContext->getPasswordForUser($user),
4829+
$space["id"],
4830+
$itemId,
4831+
\json_encode($body),
4832+
$permissionID
4833+
);
4834+
4835+
if ($response->getStatusCode() === 200) {
4836+
$this->featureContext->shareNgAddToCreatedUserGroupShares($response);
4837+
}
4838+
return $response;
4839+
} else {
4840+
$rows['permissions'] = (string)$this->featureContext->getLastCreatedUserGroupShare()->permissions;
4841+
return $this->updateSharedResource($user, $rows);
4842+
}
4843+
}
4844+
4845+
/**
4846+
* @Given user :user has expired the last share of resource :resource inside of the space :spaceName
4847+
*
4848+
* @param string $user
4849+
* @param string $resource
4850+
* @param string $spaceName
4851+
*
4852+
* @return void
4853+
* @throws GuzzleException|JsonException
4854+
*/
4855+
public function userHasExpiredTheLastShareOfResourceInsideOfTheSpace(
4856+
string $user,
4857+
string $resource,
4858+
string $spaceName
4859+
): void {
4860+
$response = $this->expireResourceShare($user, $resource, $spaceName);
4861+
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
4862+
}
48324863
}

tests/acceptance/features/cliCommands/emailNotification.feature

+26
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ Feature: get grouped email notification
2626
| shareType | user |
2727
| permissionsRole | Viewer |
2828
And user "Alice" has removed the access of user "Brian" from resource "lorem.txt" of space "Personal"
29+
And user "Alice" has sent the following resource share invitation:
30+
| resource | lorem.txt |
31+
| space | Personal |
32+
| sharee | Brian |
33+
| shareType | user |
34+
| permissionsRole | Viewer |
35+
| expirationDateTime | 2042-01-01T23:59:59.000Z |
36+
And user "Alice" has expired the last share of resource "lorem.txt" inside of the space "Personal"
2937
And user "Alice" has sent the following space share invitation:
3038
| space | New-Space |
3139
| sharee | Brian |
@@ -54,6 +62,11 @@ Feature: get grouped email notification
5462
Even though this share has been revoked you still might have access through other shares and/or space memberships.
5563
5664
65+
Your membership of space Alice Hansen has expired at %expiry_date_in_mail%
66+
67+
Even though this membership has expired you still might have access through other shares and/or space memberships
68+
69+
5770
Alice Hansen has invited you to join "New-Space".
5871
5972
@@ -80,6 +93,14 @@ Feature: get grouped email notification
8093
| shareType | user |
8194
| permissionsRole | Viewer |
8295
And user "Alice" has removed the access of user "Brian" from resource "lorem.txt" of space "Personal"
96+
And user "Alice" has sent the following resource share invitation:
97+
| resource | lorem.txt |
98+
| space | Personal |
99+
| sharee | Brian |
100+
| shareType | user |
101+
| permissionsRole | Viewer |
102+
| expirationDateTime | 2042-01-01T23:59:59.000Z |
103+
And user "Alice" has expired the last share of resource "lorem.txt" inside of the space "Personal"
83104
And user "Alice" has sent the following space share invitation:
84105
| space | New-Space |
85106
| sharee | Brian |
@@ -108,6 +129,11 @@ Feature: get grouped email notification
108129
Even though this share has been revoked you still might have access through other shares and/or space memberships.
109130
110131
132+
Your membership of space Alice Hansen has expired at %expiry_date_in_mail%
133+
134+
Even though this membership has expired you still might have access through other shares and/or space memberships
135+
136+
111137
Alice Hansen has invited you to join "New-Space".
112138
113139

0 commit comments

Comments
 (0)