From b23bc2bed02bbeb0ca8828e0c2a5856272b1d4e1 Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Wed, 21 Dec 2022 16:19:16 +0100 Subject: [PATCH 1/3] add test --- .../features/apiSpaces/changeSpaces.feature | 9 +++++++ .../features/bootstrap/SpacesContext.php | 27 ++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/tests/acceptance/features/apiSpaces/changeSpaces.feature b/tests/acceptance/features/apiSpaces/changeSpaces.feature index 629ce61601c..878531aad49 100644 --- a/tests/acceptance/features/apiSpaces/changeSpaces.feature +++ b/tests/acceptance/features/apiSpaces/changeSpaces.feature @@ -223,3 +223,12 @@ Feature: Change data of space | 10000 | between "201" and "204" | | 0 | between "201" and "204" | | -1 | between "201" and "204" | + + + Scenario: user sends invalid uuid space via the Graph API + When user "Admin" changes the name of the "unknown" space to "new name" + Then the HTTP status code should be "404" + When user "Admin" changes the quota of the "unknown" space to "10" + Then the HTTP status code should be "404" + When user "Alice" changes the description of the "unknown" 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 65e9100eba7..6ae0107c3c1 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -1286,8 +1286,13 @@ class SpacesContext implements Context { string $spaceName, string $newName ): void { - $space = $this->getSpaceByName($user, $spaceName); - $spaceId = $space["id"]; + if ($spaceName === "unknown") { + // 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); @@ -1319,8 +1324,13 @@ class SpacesContext implements Context { string $spaceName, string $newDescription ): void { - $space = $this->getSpaceByName($user, $spaceName); - $spaceId = $space["id"]; + if ($spaceName === "unknown") { + // 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); @@ -1352,8 +1362,13 @@ class SpacesContext implements Context { string $spaceName, int $newQuota ): void { - $space = $this->getSpaceByName($user, $spaceName); - $spaceId = $space["id"]; + if ($spaceName === "unknown") { + // 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); From 056bb25b57ca2b4b66412608163440e51c474afa Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Thu, 22 Dec 2022 08:20:02 +0100 Subject: [PATCH 2/3] fix after review --- .../features/apiSpaces/changeSpaces.feature | 8 ++++---- .../features/bootstrap/SpacesContext.php | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/acceptance/features/apiSpaces/changeSpaces.feature b/tests/acceptance/features/apiSpaces/changeSpaces.feature index 878531aad49..34d2fbebeae 100644 --- a/tests/acceptance/features/apiSpaces/changeSpaces.feature +++ b/tests/acceptance/features/apiSpaces/changeSpaces.feature @@ -225,10 +225,10 @@ Feature: Change data of space | -1 | between "201" and "204" | - Scenario: user sends invalid uuid space via the Graph API - When user "Admin" changes the name of the "unknown" space to "new name" + Scenario: user sends invalid space uuid via the Graph API + When user "Admin" ties to change the name of the "non-existing" space to "new name" Then the HTTP status code should be "404" - When user "Admin" changes the quota of the "unknown" space to "10" + When user "Admin" ties to change the quota of the "non-existing" space to "10" Then the HTTP status code should be "404" - When user "Alice" changes the description of the "unknown" space to "new description" + When user "Alice" ties 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 6ae0107c3c1..237698c8e7a 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -1271,7 +1271,7 @@ class SpacesContext implements Context { } /** - * @When /^user "([^"]*)" changes the name of the "([^"]*)" space to "([^"]*)"$/ + * @When /^user "([^"]*)" (?:changes|ties to change) the name of the "([^"]*)" space to "([^"]*)"$/ * * @param string $user * @param string $spaceName @@ -1286,9 +1286,9 @@ class SpacesContext implements Context { string $spaceName, string $newName ): void { - if ($spaceName === "unknown") { + if ($spaceName === "non-existing") { // check sending invalid data - $spaceId = "39c49dd3-1f24-4687-97d1-42df43f71713"; + $spaceId = WebDavHelper::generateUUIDv4(); } else { $space = $this->getSpaceByName($user, $spaceName); $spaceId = $space["id"]; @@ -1309,7 +1309,7 @@ class SpacesContext implements Context { } /** - * @When /^user "([^"]*)" changes the description of the "([^"]*)" space to "([^"]*)"$/ + * @When /^user "([^"]*)" (?:changes|ties to change) the description of the "([^"]*)" space to "([^"]*)"$/ * * @param string $user * @param string $spaceName @@ -1324,9 +1324,9 @@ class SpacesContext implements Context { string $spaceName, string $newDescription ): void { - if ($spaceName === "unknown") { + if ($spaceName === "non-existing") { // check sending invalid data - $spaceId = "39c49dd3-1f24-4687-97d1-42df43f71713"; + $spaceId = WebDavHelper::generateUUIDv4(); } else { $space = $this->getSpaceByName($user, $spaceName); $spaceId = $space["id"]; @@ -1347,7 +1347,7 @@ class SpacesContext implements Context { } /** - * @When /^user "([^"]*)" changes the quota of the "([^"]*)" space to "([^"]*)"$/ + * @When /^user "([^"]*)" (?:changes|ties to change) the quota of the "([^"]*)" space to "([^"]*)"$/ * * @param string $user * @param string $spaceName @@ -1362,9 +1362,9 @@ class SpacesContext implements Context { string $spaceName, int $newQuota ): void { - if ($spaceName === "unknown") { + if ($spaceName === "non-existing") { // check sending invalid data - $spaceId = "39c49dd3-1f24-4687-97d1-42df43f71713"; + $spaceId = WebDavHelper::generateUUIDv4(); } else { $space = $this->getSpaceByName($user, $spaceName); $spaceId = $space["id"]; From 489b3f8dcad02d8299a77fc774781c30e9e61393 Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Thu, 22 Dec 2022 10:33:30 +0100 Subject: [PATCH 3/3] fix --- .../features/apiSpaces/changeSpaces.feature | 6 +++--- .../acceptance/features/bootstrap/SpacesContext.php | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/acceptance/features/apiSpaces/changeSpaces.feature b/tests/acceptance/features/apiSpaces/changeSpaces.feature index 34d2fbebeae..b57192c6860 100644 --- a/tests/acceptance/features/apiSpaces/changeSpaces.feature +++ b/tests/acceptance/features/apiSpaces/changeSpaces.feature @@ -226,9 +226,9 @@ Feature: Change data of space Scenario: user sends invalid space uuid via the Graph API - When user "Admin" ties to change the name of the "non-existing" space to "new name" + 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" ties to change the quota of the "non-existing" space to "10" + 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" ties to change the description of the "non-existing" space to "new description" + 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 237698c8e7a..8a140d7fca7 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -1271,7 +1271,7 @@ class SpacesContext implements Context { } /** - * @When /^user "([^"]*)" (?:changes|ties to change) the name of the "([^"]*)" space to "([^"]*)"$/ + * @When /^user "([^"]*)" (?:changes|tries to change) the name of the "([^"]*)" space to "([^"]*)"$/ * * @param string $user * @param string $spaceName @@ -1288,7 +1288,7 @@ class SpacesContext implements Context { ): void { if ($spaceName === "non-existing") { // check sending invalid data - $spaceId = WebDavHelper::generateUUIDv4(); + $spaceId = "39c49dd3-1f24-4687-97d1-42df43f71713"; } else { $space = $this->getSpaceByName($user, $spaceName); $spaceId = $space["id"]; @@ -1309,7 +1309,7 @@ class SpacesContext implements Context { } /** - * @When /^user "([^"]*)" (?:changes|ties to change) the description of the "([^"]*)" space to "([^"]*)"$/ + * @When /^user "([^"]*)" (?:changes|tries to change) the description of the "([^"]*)" space to "([^"]*)"$/ * * @param string $user * @param string $spaceName @@ -1326,7 +1326,7 @@ class SpacesContext implements Context { ): void { if ($spaceName === "non-existing") { // check sending invalid data - $spaceId = WebDavHelper::generateUUIDv4(); + $spaceId = "39c49dd3-1f24-4687-97d1-42df43f71713"; } else { $space = $this->getSpaceByName($user, $spaceName); $spaceId = $space["id"]; @@ -1347,7 +1347,7 @@ class SpacesContext implements Context { } /** - * @When /^user "([^"]*)" (?:changes|ties to change) the quota of the "([^"]*)" space to "([^"]*)"$/ + * @When /^user "([^"]*)" (?:changes|tries to change) the quota of the "([^"]*)" space to "([^"]*)"$/ * * @param string $user * @param string $spaceName @@ -1364,7 +1364,7 @@ class SpacesContext implements Context { ): void { if ($spaceName === "non-existing") { // check sending invalid data - $spaceId = WebDavHelper::generateUUIDv4(); + $spaceId = "39c49dd3-1f24-4687-97d1-42df43f71713"; } else { $space = $this->getSpaceByName($user, $spaceName); $spaceId = $space["id"];