Skip to content

Commit 590d199

Browse files
add test for notifications related to share expiry
1 parent ac1689b commit 590d199

File tree

3 files changed

+94
-1
lines changed

3 files changed

+94
-1
lines changed

tests/acceptance/bootstrap/SharingNgContext.php

+42
Original file line numberDiff line numberDiff line change
@@ -2135,4 +2135,46 @@ 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+
}
21382180
}

tests/acceptance/features/apiNotification/notification.feature

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Feature: Notification
99
| username |
1010
| Alice |
1111
| Brian |
12-
| Carol |
1312
And user "Alice" has uploaded file with content "other data" to "/textfile1.txt"
1413
And user "Alice" has created folder "my_data"
1514

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
@notification @email
2+
Feature: Share Expiry Notification
3+
As a user
4+
I want to be notified when share expires
5+
So that I can stay updated about the share
6+
7+
Background:
8+
Given these users have been created with default attributes:
9+
| username |
10+
| Alice |
11+
| Brian |
12+
13+
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"
16+
And user "Alice" has sent the following resource share invitation:
17+
| resource | testfile.txt |
18+
| space | Personal |
19+
| sharee | Brian |
20+
| shareType | user |
21+
| permissionsRole | Viewer |
22+
| expirationDateTime | 2025-07-15T14:00:00Z |
23+
When user "Alice" expires the last created share:
24+
| space | Personal |
25+
| resource | testfile.txt |
26+
Then the HTTP status code should be "200"
27+
And user "Brian" should get a notification with subject "Membership expired" and message:
28+
| message |
29+
| Access to Space Alice Hansen lost |
30+
And user "Brian" should have "2" emails
31+
32+
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

0 commit comments

Comments
 (0)