From 0457f4af8720fbd3ce2ad588f483442ffe99b1f8 Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Mon, 29 May 2023 16:34:23 +0545 Subject: [PATCH 1/6] Add step to set ocis max spaces quota with env --- tests/acceptance/config/behat.yml | 1 + .../features/apiSpaces/quota.feature | 13 ++++++++++- .../features/bootstrap/OcisConfigContext.php | 23 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 3149eefad4d..2b63ad7e5c7 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -54,6 +54,7 @@ default: - TUSContext: - SpacesTUSContext: - GraphContext: + - OcisConfigContext: apiSpacesShares: paths: diff --git a/tests/acceptance/features/apiSpaces/quota.feature b/tests/acceptance/features/apiSpaces/quota.feature index 006b3327b9c..7dbb2a32387 100644 --- a/tests/acceptance/features/apiSpaces/quota.feature +++ b/tests/acceptance/features/apiSpaces/quota.feature @@ -1,4 +1,4 @@ -@api +@api Feature: State of the quota As a user I want to be able to see the state of the quota @@ -122,3 +122,14 @@ Feature: State of the quota | /filesForUpload/lorem-big.txt | /ocs/v1.php/cloud/users/%username% | 100 | 91.17 | | /filesForUpload/lorem.txt | /ocs/v2.php/cloud/users/%username% | 200 | 6.99 | | /filesForUpload/lorem-big.txt | /ocs/v2.php/cloud/users/%username% | 200 | 91.17 | + + + Scenario Outline: upload a file by setting OCIS spaces max quota + Given spaces max quota has been set to "10" bytes with "OCIS_SPACES_MAX_QUOTA" + When user "Alice" uploads file with content "" to "lorem.txt" using the WebDAV API + Then the HTTP status code should be "" + Examples: + | file_content | http_status_code | + | 7 bytes | 201 | + | 10 bytes | 201 | + | more than 10 bytes content | 507 | diff --git a/tests/acceptance/features/bootstrap/OcisConfigContext.php b/tests/acceptance/features/bootstrap/OcisConfigContext.php index ad48236bc0d..edb493ab76b 100644 --- a/tests/acceptance/features/bootstrap/OcisConfigContext.php +++ b/tests/acceptance/features/bootstrap/OcisConfigContext.php @@ -21,6 +21,7 @@ */ use Behat\Behat\Context\Context; +use GuzzleHttp\Exception\GuzzleException; use TestHelpers\OcisConfigHelper; use PHPUnit\Framework\Assert; @@ -51,6 +52,28 @@ class OcisConfigContext implements Context { ); } + /** + * @Given spaces max quota has been set to :spacesQuotaSize bytes with :envToSetMaxSpacesQuotaSize + * + * @param string $spacesQuotaSize + * @param string $envToSetMaxSpacesQuotaSize + * + * @return void + * @throws GuzzleException + */ + public function spacesMaxQuotaSizeHasBeenSetToWithEnv(string $spacesQuotaSize, string $envToSetMaxSpacesQuotaSize): void { + $envs = [ + $envToSetMaxSpacesQuotaSize => $spacesQuotaSize, + ]; + + $response = OcisConfigHelper::reConfigureOcis($envs); + Assert::assertEquals( + 200, + $response->getStatusCode(), + "Failed to set async upload with delayed post processing" + ); + } + /** * @Given cors allowed origins has been set to :allowedOrigins * From 394c9bb9a21e5d97b072e83d4670408889979932 Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Tue, 30 May 2023 09:55:00 +0545 Subject: [PATCH 2/6] Add env-config tag to scenario for ocis roll back --- tests/acceptance/features/apiSpaces/quota.feature | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/acceptance/features/apiSpaces/quota.feature b/tests/acceptance/features/apiSpaces/quota.feature index 7dbb2a32387..072ef45d35f 100644 --- a/tests/acceptance/features/apiSpaces/quota.feature +++ b/tests/acceptance/features/apiSpaces/quota.feature @@ -124,6 +124,7 @@ Feature: State of the quota | /filesForUpload/lorem-big.txt | /ocs/v2.php/cloud/users/%username% | 200 | 91.17 | + @env-config Scenario Outline: upload a file by setting OCIS spaces max quota Given spaces max quota has been set to "10" bytes with "OCIS_SPACES_MAX_QUOTA" When user "Alice" uploads file with content "" to "lorem.txt" using the WebDAV API From b8c8419393f943c2dad2ad9ca897be1d64e7d3de Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Tue, 30 May 2023 14:30:54 +0545 Subject: [PATCH 3/6] Fix red CI and and test for spaces --- .../features/apiSpaces/quota.feature | 25 +++++++++++-------- .../features/bootstrap/OcisConfigContext.php | 12 ++++----- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/tests/acceptance/features/apiSpaces/quota.feature b/tests/acceptance/features/apiSpaces/quota.feature index 072ef45d35f..2cce5031d60 100644 --- a/tests/acceptance/features/apiSpaces/quota.feature +++ b/tests/acceptance/features/apiSpaces/quota.feature @@ -124,13 +124,18 @@ Feature: State of the quota | /filesForUpload/lorem-big.txt | /ocs/v2.php/cloud/users/%username% | 200 | 91.17 | - @env-config - Scenario Outline: upload a file by setting OCIS spaces max quota - Given spaces max quota has been set to "10" bytes with "OCIS_SPACES_MAX_QUOTA" - When user "Alice" uploads file with content "" to "lorem.txt" using the WebDAV API - Then the HTTP status code should be "" - Examples: - | file_content | http_status_code | - | 7 bytes | 201 | - | 10 bytes | 201 | - | more than 10 bytes content | 507 | + @env-config + Scenario: upload a file by setting OCIS spaces max quota + Given "OCIS_SPACES_MAX_QUOTA" has been enabled and set to "10" + And user "Brian" has been created with default attributes and without skeleton files + When user "Brian" uploads file with content "more than 10 bytes content" to "lorem.txt" using the WebDAV API + Then the HTTP status code should be "507" + + + @env-config + Scenario: create a space by setting OCIS spaces max quota + Given "OCIS_SPACES_MAX_QUOTA" has been enabled and set to "50" + And user "Brian" has been created with default attributes and without skeleton files + And the administrator has given "Brian" the role "Space Admin" using the settings api + When user "Brian" creates a space "new space" of type "project" with quota "51" using the Graph API + Then the HTTP status code should be "500" diff --git a/tests/acceptance/features/bootstrap/OcisConfigContext.php b/tests/acceptance/features/bootstrap/OcisConfigContext.php index edb493ab76b..5b924548d2f 100644 --- a/tests/acceptance/features/bootstrap/OcisConfigContext.php +++ b/tests/acceptance/features/bootstrap/OcisConfigContext.php @@ -53,24 +53,24 @@ class OcisConfigContext implements Context { } /** - * @Given spaces max quota has been set to :spacesQuotaSize bytes with :envToSetMaxSpacesQuotaSize + * @Given :env has been enabled and set to :envValue * - * @param string $spacesQuotaSize - * @param string $envToSetMaxSpacesQuotaSize + * @param string $env + * @param string $envValue * * @return void * @throws GuzzleException */ - public function spacesMaxQuotaSizeHasBeenSetToWithEnv(string $spacesQuotaSize, string $envToSetMaxSpacesQuotaSize): void { + public function envHasBeenEnabledAndSetTo(string $env, string $envValue): void { $envs = [ - $envToSetMaxSpacesQuotaSize => $spacesQuotaSize, + $env => $envValue, ]; $response = OcisConfigHelper::reConfigureOcis($envs); Assert::assertEquals( 200, $response->getStatusCode(), - "Failed to set async upload with delayed post processing" + "Failed to set OCIS_CORS_ALLOW_ORIGINS=" . $envValue ); } From 191808777436851c1153111386aadc04bb00f307 Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Wed, 31 May 2023 09:33:23 +0545 Subject: [PATCH 4/6] Review address --- tests/acceptance/features/apiSpaces/quota.feature | 4 ++-- .../features/bootstrap/OcisConfigContext.php | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/acceptance/features/apiSpaces/quota.feature b/tests/acceptance/features/apiSpaces/quota.feature index 2cce5031d60..f42e14d7b41 100644 --- a/tests/acceptance/features/apiSpaces/quota.feature +++ b/tests/acceptance/features/apiSpaces/quota.feature @@ -126,7 +126,7 @@ Feature: State of the quota @env-config Scenario: upload a file by setting OCIS spaces max quota - Given "OCIS_SPACES_MAX_QUOTA" has been enabled and set to "10" + Given the config "OCIS_SPACES_MAX_QUOTA" has been set to "10" And user "Brian" has been created with default attributes and without skeleton files When user "Brian" uploads file with content "more than 10 bytes content" to "lorem.txt" using the WebDAV API Then the HTTP status code should be "507" @@ -134,7 +134,7 @@ Feature: State of the quota @env-config Scenario: create a space by setting OCIS spaces max quota - Given "OCIS_SPACES_MAX_QUOTA" has been enabled and set to "50" + Given the config "OCIS_SPACES_MAX_QUOTA" has been set to "50" And user "Brian" has been created with default attributes and without skeleton files And the administrator has given "Brian" the role "Space Admin" using the settings api When user "Brian" creates a space "new space" of type "project" with quota "51" using the Graph API diff --git a/tests/acceptance/features/bootstrap/OcisConfigContext.php b/tests/acceptance/features/bootstrap/OcisConfigContext.php index 5b924548d2f..84f4ee5bc43 100644 --- a/tests/acceptance/features/bootstrap/OcisConfigContext.php +++ b/tests/acceptance/features/bootstrap/OcisConfigContext.php @@ -53,24 +53,24 @@ class OcisConfigContext implements Context { } /** - * @Given :env has been enabled and set to :envValue + * @Given the config :configVariable has been set to :configValue * - * @param string $env - * @param string $envValue + * @param string $configVariable + * @param string $configValue * * @return void * @throws GuzzleException */ - public function envHasBeenEnabledAndSetTo(string $env, string $envValue): void { + public function theConfigHasBeenSetTo(string $configVariable, string $configValue): void { $envs = [ - $env => $envValue, + $configVariable => $configValue, ]; $response = OcisConfigHelper::reConfigureOcis($envs); Assert::assertEquals( 200, $response->getStatusCode(), - "Failed to set OCIS_CORS_ALLOW_ORIGINS=" . $envValue + "Failed to set config $configVariable=$configValue" ); } From 606ef4f7e156df5e93a17008568c3b00868b21e3 Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Fri, 2 Jun 2023 14:25:08 +0545 Subject: [PATCH 5/6] Reuse step for single env --- .../acceptance/features/apiCors/cors.feature | 2 +- .../features/bootstrap/OcisConfigContext.php | 23 +------------------ 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/tests/acceptance/features/apiCors/cors.feature b/tests/acceptance/features/apiCors/cors.feature index 726f83498da..1c74fd10b12 100644 --- a/tests/acceptance/features/apiCors/cors.feature +++ b/tests/acceptance/features/apiCors/cors.feature @@ -7,7 +7,7 @@ Feature: CORS headers Background: Given user "Alice" has been created with default attributes and without skeleton files - And cors allowed origins has been set to "https://aphno.badal" + And the config "OCIS_CORS_ALLOW_ORIGINS" has been set to "https://aphno.badal" @issue-5195 Scenario Outline: CORS headers should be returned when setting CORS domain sending origin header diff --git a/tests/acceptance/features/bootstrap/OcisConfigContext.php b/tests/acceptance/features/bootstrap/OcisConfigContext.php index 84f4ee5bc43..b1ebcc5f227 100644 --- a/tests/acceptance/features/bootstrap/OcisConfigContext.php +++ b/tests/acceptance/features/bootstrap/OcisConfigContext.php @@ -63,7 +63,7 @@ class OcisConfigContext implements Context { */ public function theConfigHasBeenSetTo(string $configVariable, string $configValue): void { $envs = [ - $configVariable => $configValue, + $configVariable => $configValue, ]; $response = OcisConfigHelper::reConfigureOcis($envs); @@ -74,27 +74,6 @@ class OcisConfigContext implements Context { ); } - /** - * @Given cors allowed origins has been set to :allowedOrigins - * - * @param string $allowedOrigins - * - * @return void - * @throws GuzzleException - */ - public function corsAllowedOriginsHasBeenSet(string $allowedOrigins): void { - $envs = [ - "OCIS_CORS_ALLOW_ORIGINS" => $allowedOrigins, - ]; - - $response = OcisConfigHelper::reConfigureOcis($envs); - Assert::assertEquals( - 200, - $response->getStatusCode(), - "Failed to set OCIS_CORS_ALLOW_ORIGINS=" . $allowedOrigins - ); - } - /** * @AfterScenario @env-config * From 30b3f00b782df229ecea7b87847cac1cb40aff36 Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Tue, 6 Jun 2023 11:11:11 +0545 Subject: [PATCH 6/6] Remove doubtful scenario --- tests/acceptance/features/apiSpaces/quota.feature | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/acceptance/features/apiSpaces/quota.feature b/tests/acceptance/features/apiSpaces/quota.feature index f42e14d7b41..13588116860 100644 --- a/tests/acceptance/features/apiSpaces/quota.feature +++ b/tests/acceptance/features/apiSpaces/quota.feature @@ -130,12 +130,3 @@ Feature: State of the quota And user "Brian" has been created with default attributes and without skeleton files When user "Brian" uploads file with content "more than 10 bytes content" to "lorem.txt" using the WebDAV API Then the HTTP status code should be "507" - - - @env-config - Scenario: create a space by setting OCIS spaces max quota - Given the config "OCIS_SPACES_MAX_QUOTA" has been set to "50" - And user "Brian" has been created with default attributes and without skeleton files - And the administrator has given "Brian" the role "Space Admin" using the settings api - When user "Brian" creates a space "new space" of type "project" with quota "51" using the Graph API - Then the HTTP status code should be "500"