From 3e6b8da6a1737338001780bffe644db96305ee7d Mon Sep 17 00:00:00 2001 From: nirajacharya2 <122071597+nirajacharya2@users.noreply.github.com> Date: Tue, 22 Aug 2023 13:16:08 +0545 Subject: [PATCH] added skip on stable 3.0 tag (#7073) --- .../deprovisioningNotification.feature | 18 ++++++------- .../bootstrap/NotificationContext.php | 27 +++++++++++++++---- .../features/bootstrap/SettingsContext.php | 3 ++- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/tests/acceptance/features/apiNotification/deprovisioningNotification.feature b/tests/acceptance/features/apiNotification/deprovisioningNotification.feature index ef19a4e639..8dd20c6bc7 100644 --- a/tests/acceptance/features/apiNotification/deprovisioningNotification.feature +++ b/tests/acceptance/features/apiNotification/deprovisioningNotification.feature @@ -1,3 +1,4 @@ +@skipOnStable3.0 Feature: Deprovisioning notification As a user admin I want to inform users about shutting down and deprovisioning the instance @@ -11,9 +12,8 @@ Feature: Deprovisioning notification Scenario: administrator creates a deprovisioning notification about shutting down the instance When the administrator creates a deprovisioning notification - Then the HTTP status code should be "200" - When user "Alice" lists all notifications - Then the HTTP status code should be "200" + And user "Alice" lists all notifications + Then the HTTP status code of responses on each endpoint should be "200, 200" respectively And the JSON response should contain a notification message with the subject "Instance will be shut down and deprovisioned" and the message-details should match """ { @@ -152,7 +152,7 @@ Feature: Deprovisioning notification """ - Scenario: administrator tries to delete the deprovisioning notification + Scenario: administrator deletes the deprovisioning notification Given the administrator has created a deprovisioning notification When the administrator deletes the deprovisioning notification Then the HTTP status code should be "200" @@ -173,9 +173,8 @@ Feature: Deprovisioning notification Scenario Outline: administrator creates a deprovisioning notification with different date formats When the administrator creates a deprovisioning notification for date "" of format "" - Then the HTTP status code should be "200" - When user "Alice" lists all notifications - Then the HTTP status code should be "200" + And user "Alice" lists all notifications + Then the HTTP status code of responses on each endpoint should be "200, 200" respectively And the JSON response should contain a notification message with the subject "Instance will be shut down and deprovisioned" and the message-details should match """ { @@ -208,9 +207,8 @@ Feature: Deprovisioning notification Scenario Outline: administrator change a deprovisioning notification with different date formats Given the administrator has created a deprovisioning notification When the administrator creates a deprovisioning notification for date "" of format "" - Then the HTTP status code should be "200" - When user "Alice" lists all notifications - Then the HTTP status code should be "200" + And user "Alice" lists all notifications + Then the HTTP status code of responses on each endpoint should be "200, 200" respectively And the JSON response should contain a notification message with the subject "Instance will be shut down and deprovisioned" and the message-details should match """ { diff --git a/tests/acceptance/features/bootstrap/NotificationContext.php b/tests/acceptance/features/bootstrap/NotificationContext.php index 8ecf67cd81..f4db55fe6c 100644 --- a/tests/acceptance/features/bootstrap/NotificationContext.php +++ b/tests/acceptance/features/bootstrap/NotificationContext.php @@ -114,6 +114,7 @@ class NotificationContext implements Context { $headers ); $this->featureContext->setResponse($response); + $this->featureContext->pushToLastHttpStatusCodesArray(); } /** @@ -516,8 +517,6 @@ class NotificationContext implements Context { } /** - * @When the administrator creates a deprovisioning notification - * @When user :user tries to create a deprovisioning notification * * @param string|null $user * @param string|null $deprovision_date @@ -533,10 +532,10 @@ class NotificationContext implements Context { ?string $user = null, ?string $deprovision_date = "2043-07-04T11:23:12Z", ?string $deprovision_date_format= "2006-01-02T15:04:05Z07:00" - ):void { + ):ResponseInterface { $payload["type"] = "deprovision"; $payload["data"] = ["deprovision_date" => $deprovision_date, "deprovision_date_format" => $deprovision_date_format]; - $response = OcsApiHelper::sendRequest( + return OcsApiHelper::sendRequest( $this->featureContext->getBaseUrl(), $user ? $this->featureContext->getActualUsername($user) : $this->featureContext->getAdminUsername(), $user ? $this->featureContext->getPasswordForUser($user) : $this->featureContext->getAdminPassword(), @@ -546,7 +545,23 @@ class NotificationContext implements Context { json_encode($payload), 2 ); + } + + /** + * @When the administrator creates a deprovisioning notification + * @When user :user tries to create a deprovisioning notification + * + * @param string|null $user + * + * @return void + * + * @throws GuzzleException + * @throws JsonException + */ + public function theAdministratorCreatesADeprovisioningNotification(?string $user = null) { + $response = $this->userCreatesDeprovisioningNotification($user); $this->featureContext->setResponse($response); + $this->featureContext->pushToLastHttpStatusCodesArray(); } /** @@ -561,7 +576,9 @@ class NotificationContext implements Context { * @throws JsonException */ public function theAdministratorCreatesADeprovisioningNotificationUsingDateFormat($deprovision_date, $deprovision_date_format) { - $this->userCreatesDeprovisioningNotification(null, $deprovision_date, $deprovision_date_format); + $response = $this->userCreatesDeprovisioningNotification(null, $deprovision_date, $deprovision_date_format); + $this->featureContext->setResponse($response); + $this->featureContext->pushToLastHttpStatusCodesArray(); } /** diff --git a/tests/acceptance/features/bootstrap/SettingsContext.php b/tests/acceptance/features/bootstrap/SettingsContext.php index 61081029ea..540f2a5254 100644 --- a/tests/acceptance/features/bootstrap/SettingsContext.php +++ b/tests/acceptance/features/bootstrap/SettingsContext.php @@ -315,7 +315,8 @@ class SettingsContext implements Context { $this->spacesContext->sendPostRequestToUrl($fullUrl, $user, $this->featureContext->getPasswordForUser($user), $body) ); - $this->featureContext->theHTTPStatusCodeShouldBe( + Assert::assertEquals( + $this->featureContext->getResponse()->getStatusCode(), 201, "Expected response status code should be 201" );