Skip to content

Commit 8106fe0

Browse files
add tests for share expiry notification
1 parent ac1689b commit 8106fe0

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

tests/acceptance/bootstrap/SharingNgContext.php

Lines changed: 42 additions & 0 deletions
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
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
@issue-10966
14+
Scenario: check share expired in-app and mail notification for Project space resource
15+
Given using spaces DAV path
16+
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
17+
And user "Alice" has created a space "NewSpace" with the default quota using the Graph API
18+
And user "Alice" has uploaded a file inside space "NewSpace" with content "share space items" to "testfile.txt"
19+
And user "Alice" has sent the following resource share invitation:
20+
| resource | testfile.txt |
21+
| space | NewSpace |
22+
| sharee | Brian |
23+
| shareType | user |
24+
| permissionsRole | Viewer |
25+
| expirationDateTime | 2025-07-15T14:00:00Z |
26+
When user "Alice" expires the last created share:
27+
| space | NewSpace |
28+
| resource | testfile.txt |
29+
Then the HTTP status code should be "200"
30+
And user "Brian" should get a notification with subject "Membership expired" and message:
31+
| message |
32+
| Access to Space NewSpace lost |
33+
And user "Brian" should have "2" emails

0 commit comments

Comments
 (0)