diff --git a/tests/acceptance/bootstrap/FeatureContext.php b/tests/acceptance/bootstrap/FeatureContext.php index 505080f5f36..7ff28799056 100644 --- a/tests/acceptance/bootstrap/FeatureContext.php +++ b/tests/acceptance/bootstrap/FeatureContext.php @@ -2500,6 +2500,14 @@ public function substituteInLineCodes( "getXRequestIdRegex" ], "parameter" => [] + ], + [ + "code" => "%expirationDateTime%", + "function" => [ + $this->spacesContext, + "getLastShareExpirationDateTime" + ], + "parameter" => [] ] ]; if ($user !== null) { @@ -2546,16 +2554,18 @@ public function substituteInLineCodes( "parameter" => [$user, true] ], [ - "code" => "%user_id%", - "function" => - [$this, "getUserIdByUserName"], - "parameter" => [$userName] + "code" => "%user_id%", + "function" => [ + $this, "getUserIdByUserName" + ], + "parameter" => [$userName] ], [ - "code" => "%group_id%", - "function" => - [$this, "getGroupIdByGroupName"], - "parameter" => [$group] + "code" => "%group_id%", + "function" => [ + $this, "getGroupIdByGroupName" + ], + "parameter" => [$group] ] ); diff --git a/tests/acceptance/bootstrap/SpacesContext.php b/tests/acceptance/bootstrap/SpacesContext.php index fb8979b2f70..5e06f8423d5 100644 --- a/tests/acceptance/bootstrap/SpacesContext.php +++ b/tests/acceptance/bootstrap/SpacesContext.php @@ -74,6 +74,15 @@ class SpacesContext implements Context { */ private array $storedEtags = []; + private string $lastShareExpirationDateTime = ''; + + /** + * @return string + */ + public function getLastShareExpirationDateTime(): string { + return $this->lastShareExpirationDateTime; + } + /** * @param string $spaceName * @@ -2666,18 +2675,23 @@ public function userExpiresTheLastShareOfResourceInsideOfTheSpace( $itemId = $this->getResourceId($user, $spaceName, $resource); $body['expirationDateTime'] = $rows['expireDate']; $permissionID = $this->featureContext->shareNgGetLastCreatedUserGroupShareID(); - $this->featureContext->setResponse( - GraphHelper::updateShare( - $this->featureContext->getBaseUrl(), - $this->featureContext->getStepLineRef(), - $user, - $this->featureContext->getPasswordForUser($user), - $space["id"], - $itemId, - \json_encode($body), - $permissionID - ) + $response = GraphHelper::updateShare( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user), + $space["id"], + $itemId, + \json_encode($body), + $permissionID ); + + if ($response->getStatusCode() === 200) { + $shareExpireResponse = json_decode($response->getBody()->getContents(), true); + $date = new DateTimeImmutable($shareExpireResponse['expirationDateTime']); + $this->lastShareExpirationDateTime = $date->format('Y-m-d H:i:s'); + } + $this->featureContext->setResponse($response); } else { $rows['permissions'] = (string)$this->featureContext->getLastCreatedUserGroupShare()->permissions; $this->featureContext->setResponse($this->updateSharedResource($user, $rows)); diff --git a/tests/acceptance/features/apiNotification/notification.feature b/tests/acceptance/features/apiNotification/notification.feature index 976983631c0..8031f44c4c0 100644 --- a/tests/acceptance/features/apiNotification/notification.feature +++ b/tests/acceptance/features/apiNotification/notification.feature @@ -9,7 +9,6 @@ Feature: Notification | username | | Alice | | Brian | - | Carol | And user "Alice" has uploaded file with content "other data" to "/textfile1.txt" And user "Alice" has created folder "my_data" diff --git a/tests/acceptance/features/apiNotification/shareExpireNotification.feature b/tests/acceptance/features/apiNotification/shareExpireNotification.feature new file mode 100644 index 00000000000..acb482d759d --- /dev/null +++ b/tests/acceptance/features/apiNotification/shareExpireNotification.feature @@ -0,0 +1,37 @@ +@notification @email +Feature: Share Expiry Notification + As a user + I want to be notified when share expires + So that I can stay updated about the share + + Background: + Given these users have been created with default attributes: + | username | + | Alice | + | Brian | + + + Scenario: check share expired in-app and mail notifications for Personal space resource + Given using SharingNG + And user "Alice" has uploaded file with content "hello world" to "testfile.txt" + And user "Alice" has sent the following resource share invitation: + | resource | testfile.txt | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + | expirationDateTime | 2025-07-15T14:00:00Z | + When user "Alice" expires the last share of resource "testfile.txt" inside of the space "Personal" + Then the HTTP status code should be "200" + And user "Brian" should get a notification with subject "Membership expired" and message: + | message | + | Access to Space Alice Hansen lost | + And user "Brian" should have "2" emails + And user "Brian" should have received the following email from user "Alice" + """ + Hello Brian Murphy, + + Your membership of space %displayname% has expired at %expirationDateTime% + + Even though this membership has expired you still might have access through other shares and/or space memberships + """