From da17489fc260753b9e54418b41086367f0f0dea5 Mon Sep 17 00:00:00 2001 From: Sabin Date: Mon, 1 Jan 2024 17:17:58 +0545 Subject: [PATCH] updated feature file for user quota --- .../features/bootstrap/Provisioning.php | 43 +++++++++++-------- .../coreApiWebdavProperties1/getQuota.feature | 29 ++++++------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index 04bbad86c4f..0085973706b 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -4550,7 +4550,7 @@ public function theFollowingUsersShouldBeEnabled(TableNode $table):void { } /** - * @When the administrator sets the quota of user :user to :quota using the provisioning API + * @When the administrator sets the quota of user :user to :quota bytes using the provisioning API * * @param string $user * @param string $quota @@ -4559,21 +4559,30 @@ public function theFollowingUsersShouldBeEnabled(TableNode $table):void { */ public function adminSetsUserQuotaToUsingTheProvisioningApi(string $user, string $quota):void { $user = $this->getActualUsername($user); - $body - = [ - 'key' => 'quota', - 'value' => $quota, - ]; + $adminUser = $this->getAdminUsername(); + $bodyData = ["quota" => ["total" => (int)$quota]]; + $spaceId = $this->spacesContext->getSpaceIdByName($user, "Personal"); + $body = json_encode($bodyData, JSON_THROW_ON_ERROR); - $this->response = OcsApiHelper::sendRequest( - $this->getBaseUrl(), - $this->getAdminUsername(), - $this->getAdminPassword(), - "PUT", - "/cloud/users/$user", - $this->getStepLineRef(), - $body - ); + if (OcisHelper::isTestingWithGraphApi()) { + $this->response = GraphHelper::updateSpace( + $this->getBaseUrl(), + $adminUser, + $this->getAdminPassword(), + $body, + $spaceId + ); + } else { + $this->response = OcsApiHelper::sendRequest( + $this->getBaseUrl(), + $this->getAdminUsername(), + $this->getAdminPassword(), + "PUT", + "/cloud/users/$user", + $this->getStepLineRef(), + $body + ); + } } /** @@ -4597,7 +4606,7 @@ public function theQuotaOfUserHasBeenSetTo(string $user, string $quota):void { * @return void */ public function adminGivesUnlimitedQuotaToUserUsingTheProvisioningApi(string $user):void { - $this->adminSetsUserQuotaToUsingTheProvisioningApi($user, 'none'); + $this->adminSetsUserQuotaToUsingTheProvisioningApi($user, "0"); } /** @@ -4608,7 +4617,7 @@ public function adminGivesUnlimitedQuotaToUserUsingTheProvisioningApi(string $us * @return void */ public function userHasBeenGivenUnlimitedQuota(string $user):void { - $this->theQuotaOfUserHasBeenSetTo($user, 'none'); + $this->theQuotaOfUserHasBeenSetTo($user, "0"); } /** diff --git a/tests/acceptance/features/coreApiWebdavProperties1/getQuota.feature b/tests/acceptance/features/coreApiWebdavProperties1/getQuota.feature index 631b7d9d275..f8b971b94e4 100644 --- a/tests/acceptance/features/coreApiWebdavProperties1/getQuota.feature +++ b/tests/acceptance/features/coreApiWebdavProperties1/getQuota.feature @@ -1,4 +1,4 @@ -@issue-1313 @skipOnGraph +@issue-1313 Feature: get quota As a user I want to be able to find out my available storage quota @@ -13,7 +13,7 @@ Feature: get quota Given using DAV path When the administrator gives unlimited quota to user "Alice" using the provisioning API Then the HTTP status code should be "200" - And as user "Alice" folder "/" should contain a property "d:quota-available-bytes" with value "-3" + And as user "Alice" folder "/" should contain a property "d:quota-available-bytes" with value "0" Examples: | dav-path-version | | old | @@ -23,9 +23,9 @@ Feature: get quota @smokeTest Scenario Outline: retrieving folder quota when quota is set Given using DAV path - When the administrator sets the quota of user "Alice" to "10 MB" using the provisioning API + When the administrator sets the quota of user "Alice" to "10000" bytes using the provisioning API Then the HTTP status code should be "200" - And as user "Alice" folder "/" should contain a property "d:quota-available-bytes" with value "10485406" + And as user "Alice" folder "/" should contain a property "d:quota-available-bytes" with value "10000" Examples: | dav-path-version | | old | @@ -37,34 +37,33 @@ Feature: get quota Given using DAV path And user "Brian" has been created with default attributes and without skeleton files And user "Alice" has been given unlimited quota - And the quota of user "Brian" has been set to "10 MB" + And the quota of user "Brian" has been set to "10000" And user "Brian" has created folder "/testquota" And user "Brian" has created a share with settings | path | testquota | | shareType | user | | permissions | all | | shareWith | Alice | - When user "Alice" gets the following properties of folder "/testquota" using the WebDAV API + When user "Alice" gets the following properties of folder "/Shares/testquota" using the WebDAV API | propertyName | | d:quota-available-bytes | - Then the HTTP status code should be "200" - And the single response should contain a property "d:quota-available-bytes" with value "10485406" + Then the HTTP status code should be "207" + And the single response should contain a property "d:quota-available-bytes" with value "10000" Examples: | dav-path-version | | old | | new | - | spaces | Scenario Outline: retrieving folder quota when quota is set and a file was uploaded Given using DAV path - And the quota of user "Alice" has been set to "1 KB" + And the quota of user "Alice" has been set to "1000" And user "Alice" has uploaded file "/prueba.txt" of size 93 bytes When user "Alice" gets the following properties of folder "/" using the WebDAV API | propertyName | | d:quota-available-bytes | - Then the HTTP status code should be "201" - And the single response should contain a property "d:quota-available-bytes" with value "577" + Then the HTTP status code should be "207" + And the single response should contain a property "d:quota-available-bytes" with value "1000" Examples: | dav-path-version | | old | @@ -75,14 +74,14 @@ Feature: get quota Scenario Outline: retrieving folder quota when quota is set and a file was received Given using DAV path And user "Brian" has been created with default attributes and without skeleton files - And the quota of user "Brian" has been set to "1 KB" + And the quota of user "Brian" has been set to "1000" And user "Alice" has uploaded file "/Alice.txt" of size 93 bytes And user "Alice" has shared file "Alice.txt" with user "Brian" When user "Brian" gets the following properties of folder "/" using the WebDAV API | propertyName | | d:quota-available-bytes | - Then the HTTP status code should be "200" - And the single response should contain a property "d:quota-available-bytes" with value "670" + Then the HTTP status code should be "207" + And the single response should contain a property "d:quota-available-bytes" with value "1000" Examples: | dav-path-version | | old |