Skip to content

Commit 9274926

Browse files
remove flaky scenario
1 parent a0612ce commit 9274926

File tree

5 files changed

+52
-90
lines changed

5 files changed

+52
-90
lines changed

tests/acceptance/bootstrap/FeatureContext.php

+18-8
Original file line numberDiff line numberDiff line change
@@ -2500,6 +2500,14 @@ public function substituteInLineCodes(
25002500
"getXRequestIdRegex"
25012501
],
25022502
"parameter" => []
2503+
],
2504+
[
2505+
"code" => "%expirationDateTime%",
2506+
"function" => [
2507+
$this->spacesContext,
2508+
"getLastShareExpirationDateTime"
2509+
],
2510+
"parameter" => []
25032511
]
25042512
];
25052513
if ($user !== null) {
@@ -2546,16 +2554,18 @@ public function substituteInLineCodes(
25462554
"parameter" => [$user, true]
25472555
],
25482556
[
2549-
"code" => "%user_id%",
2550-
"function" =>
2551-
[$this, "getUserIdByUserName"],
2552-
"parameter" => [$userName]
2557+
"code" => "%user_id%",
2558+
"function" => [
2559+
$this, "getUserIdByUserName"
2560+
],
2561+
"parameter" => [$userName]
25532562
],
25542563
[
2555-
"code" => "%group_id%",
2556-
"function" =>
2557-
[$this, "getGroupIdByGroupName"],
2558-
"parameter" => [$group]
2564+
"code" => "%group_id%",
2565+
"function" => [
2566+
$this, "getGroupIdByGroupName"
2567+
],
2568+
"parameter" => [$group]
25592569
]
25602570
);
25612571

tests/acceptance/bootstrap/SharingNgContext.php

-42
Original file line numberDiff line numberDiff line change
@@ -2135,46 +2135,4 @@ public function userListsPermissionsWithFollowingFiltersForFileOrFolderOfTheSpac
21352135
$this->getPermissionsList($user, $fileOrFolder, $space, $resource, $query)
21362136
);
21372137
}
2138-
2139-
/**
2140-
* @When user :user expires the last created share:
2141-
*
2142-
* @param string $user
2143-
* @param TableNode $table
2144-
*
2145-
* @return void
2146-
*/
2147-
public function userExpiresTheLastCreatedShare(string $user, TableNode $table): void {
2148-
$permissionID = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
2149-
$bodyRows = $table->getRowsHash();
2150-
if ($bodyRows['space'] === 'Personal' || $bodyRows['space'] === 'Shares') {
2151-
$space = $this->spacesContext->getSpaceByName($user, $bodyRows['space']);
2152-
} else {
2153-
$space = $this->spacesContext->getCreatedSpace($bodyRows['space']);
2154-
}
2155-
$spaceId = $space["id"];
2156-
2157-
$resource = $bodyRows['resource'] ?? '';
2158-
if ($resource === '' && !\in_array($bodyRows['space'], ['Personal', 'Shares'])) {
2159-
$itemId = $space['fileId'];
2160-
} else {
2161-
$itemId = $this->spacesContext->getResourceId($user, $bodyRows['space'], $resource);
2162-
}
2163-
$body = [];
2164-
$dateTime = new DateTime("now", new DateTimeZone("UTC"));
2165-
$body['expirationDateTime'] = $dateTime->modify('-5 minutes')->format('Y-m-d\TH:i:s\Z');
2166-
2167-
$this->featureContext->setResponse(
2168-
GraphHelper::updateShare(
2169-
$this->featureContext->getBaseUrl(),
2170-
$this->featureContext->getStepLineRef(),
2171-
$user,
2172-
$this->featureContext->getPasswordForUser($user),
2173-
$spaceId,
2174-
$itemId,
2175-
\json_encode($body),
2176-
$permissionID
2177-
)
2178-
);
2179-
}
21802138
}

tests/acceptance/bootstrap/SpacesContext.php

+23-11
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ class SpacesContext implements Context {
7474
*/
7575
private array $storedEtags = [];
7676

77+
private string $lastShareExpirationDateTime = '';
78+
79+
public function getLastShareExpirationDateTime(): string {
80+
return $this->lastShareExpirationDateTime;
81+
}
82+
7783
/**
7884
* @param string $spaceName
7985
*
@@ -2666,18 +2672,24 @@ public function userExpiresTheLastShareOfResourceInsideOfTheSpace(
26662672
$itemId = $this->getResourceId($user, $spaceName, $resource);
26672673
$body['expirationDateTime'] = $rows['expireDate'];
26682674
$permissionID = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
2669-
$this->featureContext->setResponse(
2670-
GraphHelper::updateShare(
2671-
$this->featureContext->getBaseUrl(),
2672-
$this->featureContext->getStepLineRef(),
2673-
$user,
2674-
$this->featureContext->getPasswordForUser($user),
2675-
$space["id"],
2676-
$itemId,
2677-
\json_encode($body),
2678-
$permissionID
2679-
)
2675+
$response = GraphHelper::updateShare(
2676+
$this->featureContext->getBaseUrl(),
2677+
$this->featureContext->getStepLineRef(),
2678+
$user,
2679+
$this->featureContext->getPasswordForUser($user),
2680+
$space["id"],
2681+
$itemId,
2682+
\json_encode($body),
2683+
$permissionID
26802684
);
2685+
2686+
if ($response->getStatusCode() === 200) {
2687+
$res = json_decode($response->getBody()->getContents(), true);
2688+
$date = new DateTimeImmutable($res['expirationDateTime']);
2689+
$this->lastShareExpirationDateTime = $date->format('Y-m-d H:i:s');
2690+
}
2691+
2692+
$this->featureContext->setResponse($response);
26812693
} else {
26822694
$rows['permissions'] = (string)$this->featureContext->getLastCreatedUserGroupShare()->permissions;
26832695
$this->featureContext->setResponse($this->updateSharedResource($user, $rows));

tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md

-3
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,5 @@ The expected failures in this file are from features in the owncloud/ocis repo.
324324
- [apiServiceAvailability/serviceAvailabilityCheck.feature:116](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiServiceAvailability/serviceAvailabilityCheck.feature#L116)
325325
- [apiServiceAvailability/serviceAvailabilityCheck.feature:125](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiServiceAvailability/serviceAvailabilityCheck.feature#L125)
326326

327-
### [Multiple in-app and mail notification generated for Share Expired event of resource inside Project drive ](https://github.com/owncloud/ocis/issues/10936)
328-
-[apiNotification/shareExpireNotification.feature:33](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiNotification/shareExpireNotification.feature#L33)
329-
330327
Note: always have an empty line at the end of this file.
331328
The bash script that processes this file requires that the last line has a newline on the end.

tests/acceptance/features/apiNotification/shareExpireNotification.feature

+11-26
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,27 @@ Feature: Share Expiry Notification
1111
| Brian |
1212

1313

14-
Scenario: check share expired in-app and mail notification for Personal space resource
15-
Given user "Alice" has uploaded file with content "hello world" to "testfile.txt"
14+
Scenario: check share expired in-app and mail notifications for Personal space resource
15+
Given using SharingNG
16+
And user "Alice" has uploaded file with content "hello world" to "testfile.txt"
1617
And user "Alice" has sent the following resource share invitation:
1718
| resource | testfile.txt |
1819
| space | Personal |
1920
| sharee | Brian |
2021
| shareType | user |
2122
| permissionsRole | Viewer |
2223
| expirationDateTime | 2025-07-15T14:00:00Z |
23-
When user "Alice" expires the last created share:
24-
| space | Personal |
25-
| resource | testfile.txt |
24+
When user "Alice" expires the last share of resource "testfile.txt" inside of the space "Personal"
2625
Then the HTTP status code should be "200"
2726
And user "Brian" should get a notification with subject "Membership expired" and message:
2827
| message |
2928
| Access to Space Alice Hansen lost |
3029
And user "Brian" should have "2" emails
30+
And user "Brian" should have received the following email from user "Alice"
31+
"""
32+
Hello Brian Murphy,
3133
32-
@issue-10966
33-
Scenario: check share expired in-app and mail notification for Project space resource
34-
Given using spaces DAV path
35-
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
36-
And user "Alice" has created a space "NewSpace" with the default quota using the Graph API
37-
And user "Alice" has uploaded a file inside space "NewSpace" with content "share space items" to "testfile.txt"
38-
And user "Alice" has sent the following resource share invitation:
39-
| resource | testfile.txt |
40-
| space | NewSpace |
41-
| sharee | Brian |
42-
| shareType | user |
43-
| permissionsRole | Viewer |
44-
| expirationDateTime | 2025-07-15T14:00:00Z |
45-
When user "Alice" expires the last created share:
46-
| space | NewSpace |
47-
| resource | testfile.txt |
48-
Then the HTTP status code should be "200"
49-
And user "Brian" should get a notification with subject "Membership expired" and message:
50-
| message |
51-
| Access to Space NewSpace lost |
52-
And user "Brian" should have "2" emails
34+
Your membership of space %displayname% has expired at %expirationDateTime%
35+
36+
Even though this membership has expired you still might have access through other shares and/or space memberships
37+
"""

0 commit comments

Comments
 (0)