Skip to content

Commit 8537813

Browse files
add tests for share exipry
1 parent bf6221a commit 8537813

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

tests/acceptance/bootstrap/SharingNgContext.php

+42
Original file line numberDiff line numberDiff line change
@@ -2160,4 +2160,46 @@ public function userListsPermissionsWithFollowingFiltersForFileOrFolderOfTheSpac
21602160
$this->getPermissionsList($user, $fileOrFolder, $space, $resource, $query)
21612161
);
21622162
}
2163+
2164+
/**
2165+
* @When user :user expires 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+
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+
$this->featureContext->setResponse(
2193+
GraphHelper::updateShare(
2194+
$this->featureContext->getBaseUrl(),
2195+
$this->featureContext->getStepLineRef(),
2196+
$user,
2197+
$this->featureContext->getPasswordForUser($user),
2198+
$spaceId,
2199+
$itemId,
2200+
\json_encode($body),
2201+
$permissionID
2202+
)
2203+
);
2204+
}
21632205
}

tests/acceptance/features/apiSettings/notificationSetting.feature

+21
Original file line numberDiff line numberDiff line change
@@ -607,3 +607,24 @@ 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+
When user "Alice" expires the last created share:
622+
| space | Personal |
623+
| resource | testfile.txt |
624+
Then the HTTP status code should be "200"
625+
And for user "Brian" the space "Shares" should not contain these entries:
626+
| testfile.txt |
627+
And user "Brian" should get a notification with subject "Membership expired" and message:
628+
| message |
629+
| Access to Space Alice Hansen lost |
630+
And user "Brian" should have "2" emails

0 commit comments

Comments
 (0)