From 1d51c1ccbdc95cc38e9e7a835fe407da791d5170 Mon Sep 17 00:00:00 2001 From: Swikriti Tripathi <41103328+SwikritiT@users.noreply.github.com> Date: Wed, 4 Jan 2023 17:00:59 +0545 Subject: [PATCH] [tests-only][full-ci] Forward port send invalid UUID master (#5321) * add test * fix after review * fix Co-authored-by: Viktor Scharf --- .../features/apiSpaces/changeSpaces.feature | 11 ++++++- .../features/bootstrap/SpacesContext.php | 33 ++++++++++++++----- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/tests/acceptance/features/apiSpaces/changeSpaces.feature b/tests/acceptance/features/apiSpaces/changeSpaces.feature index 54768b04b..833e86643 100644 --- a/tests/acceptance/features/apiSpaces/changeSpaces.feature +++ b/tests/acceptance/features/apiSpaces/changeSpaces.feature @@ -227,4 +227,13 @@ Feature: Change data of space | 15 | "507" | 15 | 0 | | 10000 | between "201" and "204" | 10000 | 26 | | 0 | between "201" and "204" | 0 | 26 | - | -1 | between "201" and "204" | 0 | 26 | \ No newline at end of file + | -1 | between "201" and "204" | 0 | 26 | + + + Scenario: user sends invalid space uuid via the Graph API + When user "Admin" tries to change the name of the "non-existing" space to "new name" + Then the HTTP status code should be "404" + When user "Admin" tries to change the quota of the "non-existing" space to "10" + Then the HTTP status code should be "404" + When user "Alice" tries to change the description of the "non-existing" space to "new description" + Then the HTTP status code should be "404" diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 4d8ecd17e..1ae8c983a 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -1258,7 +1258,7 @@ class SpacesContext implements Context { } /** - * @When /^user "([^"]*)" changes the name of the "([^"]*)" space to "([^"]*)"$/ + * @When /^user "([^"]*)" (?:changes|tries to change) the name of the "([^"]*)" space to "([^"]*)"$/ * * @param string $user * @param string $spaceName @@ -1273,8 +1273,13 @@ class SpacesContext implements Context { string $spaceName, string $newName ): void { - $space = $this->getSpaceByName($user, $spaceName); - $spaceId = $space["id"]; + if ($spaceName === "non-existing") { + // check sending invalid data + $spaceId = "39c49dd3-1f24-4687-97d1-42df43f71713"; + } else { + $space = $this->getSpaceByName($user, $spaceName); + $spaceId = $space["id"]; + } $bodyData = ["Name" => $newName]; $body = json_encode($bodyData, JSON_THROW_ON_ERROR); @@ -1291,7 +1296,7 @@ class SpacesContext implements Context { } /** - * @When /^user "([^"]*)" changes the description of the "([^"]*)" space to "([^"]*)"$/ + * @When /^user "([^"]*)" (?:changes|tries to change) the description of the "([^"]*)" space to "([^"]*)"$/ * * @param string $user * @param string $spaceName @@ -1306,8 +1311,13 @@ class SpacesContext implements Context { string $spaceName, string $newDescription ): void { - $space = $this->getSpaceByName($user, $spaceName); - $spaceId = $space["id"]; + if ($spaceName === "non-existing") { + // check sending invalid data + $spaceId = "39c49dd3-1f24-4687-97d1-42df43f71713"; + } else { + $space = $this->getSpaceByName($user, $spaceName); + $spaceId = $space["id"]; + } $bodyData = ["description" => $newDescription]; $body = json_encode($bodyData, JSON_THROW_ON_ERROR); @@ -1324,7 +1334,7 @@ class SpacesContext implements Context { } /** - * @When /^user "([^"]*)" changes the quota of the "([^"]*)" space to "([^"]*)"$/ + * @When /^user "([^"]*)" (?:changes|tries to change) the quota of the "([^"]*)" space to "([^"]*)"$/ * * @param string $user * @param string $spaceName @@ -1339,8 +1349,13 @@ class SpacesContext implements Context { string $spaceName, int $newQuota ): void { - $space = $this->getSpaceByName($user, $spaceName); - $spaceId = $space["id"]; + if ($spaceName === "non-existing") { + // check sending invalid data + $spaceId = "39c49dd3-1f24-4687-97d1-42df43f71713"; + } else { + $space = $this->getSpaceByName($user, $spaceName); + $spaceId = $space["id"]; + } $bodyData = ["quota" => ["total" => $newQuota]]; $body = json_encode($bodyData, JSON_THROW_ON_ERROR);