Skip to content

Commit ffa135a

Browse files
add tests for share exipry
1 parent 453debe commit ffa135a

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

tests/acceptance/bootstrap/SharingNgContext.php

+46
Original file line numberDiff line numberDiff line change
@@ -2160,4 +2160,50 @@ public function userListsPermissionsWithFollowingFiltersForFileOrFolderOfTheSpac
21602160
$this->getPermissionsList($user, $fileOrFolder, $space, $resource, $query)
21612161
);
21622162
}
2163+
2164+
/**
2165+
* @When user :user has expired the last created share:
2166+
*
2167+
* @param string $user
2168+
* @param TableNode $table
2169+
*
2170+
* @return void
2171+
*/
2172+
public function userExpiresTheLastCreatedShare(string $user, TableNode $table): void {
2173+
$permissionID = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
2174+
$bodyRows = $table->getRowsHash();
2175+
if ($bodyRows['space'] === 'Personal' || $bodyRows['space'] === 'Shares') {
2176+
$space = $this->spacesContext->getSpaceByName($user, $bodyRows['space']);
2177+
} else {
2178+
$space = $this->spacesContext->getCreatedSpace($bodyRows['space']);
2179+
}
2180+
$spaceId = $space["id"];
2181+
// for updating role of project space shared, we do not need to provide resource
2182+
$resource = $bodyRows['resource'] ?? '';
2183+
if ($resource === '' && !\in_array($bodyRows['space'], ['Personal', 'Shares'])) {
2184+
$itemId = $space['fileId'];
2185+
} else {
2186+
$itemId = $this->spacesContext->getResourceId($user, $bodyRows['space'], $resource);
2187+
}
2188+
$body = [];
2189+
$dateTime = new DateTime("now", new DateTimeZone("UTC"));
2190+
$body['expirationDateTime'] = $dateTime->modify('-5 minutes')->format('Y-m-d\TH:i:s\Z');
2191+
2192+
$response = GraphHelper::updateShare(
2193+
$this->featureContext->getBaseUrl(),
2194+
$this->featureContext->getStepLineRef(),
2195+
$user,
2196+
$this->featureContext->getPasswordForUser($user),
2197+
$spaceId,
2198+
$itemId,
2199+
\json_encode($body),
2200+
$permissionID
2201+
);
2202+
2203+
$this->featureContext->theHttpStatusCodeShouldBe(
2204+
200,
2205+
"Failed to update shared permissions for user '$user'.",
2206+
$response
2207+
);
2208+
}
21632209
}

tests/acceptance/features/apiSettings/notificationSetting.feature

+41
Original file line numberDiff line numberDiff line change
@@ -607,3 +607,44 @@ Feature: Notification Settings
607607
| message |
608608
| Alice Hansen added you to Space new-space |
609609
But user "Brian" should not have a notification related to space "new-space" with subject "Space disabled"
610+
611+
612+
Scenario: check share expired in-app and mail notification for Personal space resource
613+
Given user "Alice" has uploaded file with content "hello world" to "testfile.txt"
614+
And user "Alice" has sent the following resource share invitation:
615+
| resource | testfile.txt |
616+
| space | Personal |
617+
| sharee | Brian |
618+
| shareType | user |
619+
| permissionsRole | Viewer |
620+
| expirationDateTime | 2025-07-15T14:00:00Z |
621+
And user "Alice" has expired the last created share:
622+
| space | Personal |
623+
| resource | testfile.txt |
624+
Then user "Brian" should get a notification with subject "Membership expired" and message:
625+
| message |
626+
| Access to Space Alice Hansen lost |
627+
And user "Brian" should have "2" emails
628+
629+
630+
Scenario: check share expired in-app and mail notification for Project space resource
631+
Given using spaces DAV path
632+
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
633+
And user "Alice" has created a space "NewSpace" with the default quota using the Graph API
634+
And user "Alice" has uploaded a file inside space "NewSpace" with content "share space items" to "testfile.txt"
635+
And user "Alice" has sent the following resource share invitation:
636+
| resource | testfile.txt |
637+
| space | NewSpace |
638+
| sharee | Brian |
639+
| shareType | user |
640+
| permissionsRole | Viewer |
641+
| expirationDateTime | 2025-07-15T14:00:00Z |
642+
And user "Alice" has expired the last created share:
643+
| space | NewSpace |
644+
| resource | testfile.txt |
645+
When user "Brian" lists all notifications
646+
Then the HTTP status code should be "200"
647+
Then user "Brian" should get a notification with subject "Membership expired" and message:
648+
| message |
649+
| Access to Space NewSpace lost |
650+
And user "Brian" should have "2" emails

0 commit comments

Comments
 (0)