From 92749265e3aac691e9c65f4f1dafdaaeb81f316a Mon Sep 17 00:00:00 2001 From: amrita-shrestha Date: Tue, 11 Feb 2025 10:09:25 +0545 Subject: [PATCH] remove flaky scenario --- tests/acceptance/bootstrap/FeatureContext.php | 26 ++++++++---- .../acceptance/bootstrap/SharingNgContext.php | 42 ------------------- tests/acceptance/bootstrap/SpacesContext.php | 34 ++++++++++----- ...ected-failures-localAPI-on-OCIS-storage.md | 3 -- .../shareExpireNotification.feature | 37 +++++----------- 5 files changed, 52 insertions(+), 90 deletions(-) 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/SharingNgContext.php b/tests/acceptance/bootstrap/SharingNgContext.php index f8940674823..8515d71e8a5 100644 --- a/tests/acceptance/bootstrap/SharingNgContext.php +++ b/tests/acceptance/bootstrap/SharingNgContext.php @@ -2135,46 +2135,4 @@ public function userListsPermissionsWithFollowingFiltersForFileOrFolderOfTheSpac $this->getPermissionsList($user, $fileOrFolder, $space, $resource, $query) ); } - - /** - * @When user :user expires the last created share: - * - * @param string $user - * @param TableNode $table - * - * @return void - */ - public function userExpiresTheLastCreatedShare(string $user, TableNode $table): void { - $permissionID = $this->featureContext->shareNgGetLastCreatedUserGroupShareID(); - $bodyRows = $table->getRowsHash(); - if ($bodyRows['space'] === 'Personal' || $bodyRows['space'] === 'Shares') { - $space = $this->spacesContext->getSpaceByName($user, $bodyRows['space']); - } else { - $space = $this->spacesContext->getCreatedSpace($bodyRows['space']); - } - $spaceId = $space["id"]; - - $resource = $bodyRows['resource'] ?? ''; - if ($resource === '' && !\in_array($bodyRows['space'], ['Personal', 'Shares'])) { - $itemId = $space['fileId']; - } else { - $itemId = $this->spacesContext->getResourceId($user, $bodyRows['space'], $resource); - } - $body = []; - $dateTime = new DateTime("now", new DateTimeZone("UTC")); - $body['expirationDateTime'] = $dateTime->modify('-5 minutes')->format('Y-m-d\TH:i:s\Z'); - - $this->featureContext->setResponse( - GraphHelper::updateShare( - $this->featureContext->getBaseUrl(), - $this->featureContext->getStepLineRef(), - $user, - $this->featureContext->getPasswordForUser($user), - $spaceId, - $itemId, - \json_encode($body), - $permissionID - ) - ); - } } diff --git a/tests/acceptance/bootstrap/SpacesContext.php b/tests/acceptance/bootstrap/SpacesContext.php index fb8979b2f70..d2c44b61b14 100644 --- a/tests/acceptance/bootstrap/SpacesContext.php +++ b/tests/acceptance/bootstrap/SpacesContext.php @@ -74,6 +74,12 @@ class SpacesContext implements Context { */ private array $storedEtags = []; + private string $lastShareExpirationDateTime = ''; + + public function getLastShareExpirationDateTime(): string { + return $this->lastShareExpirationDateTime; + } + /** * @param string $spaceName * @@ -2666,18 +2672,24 @@ 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) { + $res = json_decode($response->getBody()->getContents(), true); + $date = new DateTimeImmutable($res['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/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index 73c2628f18d..b39621ca7bf 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -324,8 +324,5 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiServiceAvailability/serviceAvailabilityCheck.feature:116](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiServiceAvailability/serviceAvailabilityCheck.feature#L116) - [apiServiceAvailability/serviceAvailabilityCheck.feature:125](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiServiceAvailability/serviceAvailabilityCheck.feature#L125) -### [Multiple in-app and mail notification generated for Share Expired event of resource inside Project drive ](https://github.com/owncloud/ocis/issues/10936) --[apiNotification/shareExpireNotification.feature:33](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiNotification/shareExpireNotification.feature#L33) - Note: always have an empty line at the end of this file. The bash script that processes this file requires that the last line has a newline on the end. diff --git a/tests/acceptance/features/apiNotification/shareExpireNotification.feature b/tests/acceptance/features/apiNotification/shareExpireNotification.feature index 14e62353bf7..acb482d759d 100644 --- a/tests/acceptance/features/apiNotification/shareExpireNotification.feature +++ b/tests/acceptance/features/apiNotification/shareExpireNotification.feature @@ -11,8 +11,9 @@ Feature: Share Expiry Notification | Brian | - Scenario: check share expired in-app and mail notification for Personal space resource - Given user "Alice" has uploaded file with content "hello world" to "testfile.txt" + 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 | @@ -20,33 +21,17 @@ Feature: Share Expiry Notification | shareType | user | | permissionsRole | Viewer | | expirationDateTime | 2025-07-15T14:00:00Z | - When user "Alice" expires the last created share: - | space | Personal | - | resource | testfile.txt | + 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, - @issue-10966 - Scenario: check share expired in-app and mail notification for Project space resource - Given using spaces DAV path - And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API - And user "Alice" has created a space "NewSpace" with the default quota using the Graph API - And user "Alice" has uploaded a file inside space "NewSpace" with content "share space items" to "testfile.txt" - And user "Alice" has sent the following resource share invitation: - | resource | testfile.txt | - | space | NewSpace | - | sharee | Brian | - | shareType | user | - | permissionsRole | Viewer | - | expirationDateTime | 2025-07-15T14:00:00Z | - When user "Alice" expires the last created share: - | space | NewSpace | - | resource | testfile.txt | - 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 NewSpace lost | - And user "Brian" should have "2" emails + 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 + """