diff --git a/apps/provisioning_api/lib/Users.php b/apps/provisioning_api/lib/Users.php index 1d15bcb16896..786a13096a68 100644 --- a/apps/provisioning_api/lib/Users.php +++ b/apps/provisioning_api/lib/Users.php @@ -218,7 +218,7 @@ public function getUser($parameters) { } // Find the data - $data['quota'] = $this->fillStorageInfo($userId); + $data['quota'] = $this->fillStorageInfo($targetUserObject->getUID()); $data['quota']['definition'] = $targetUserObject->getQuota(); $data['email'] = $targetUserObject->getEMailAddress(); $data['displayname'] = $targetUserObject->getDisplayName(); diff --git a/apps/provisioning_api/tests/UsersTest.php b/apps/provisioning_api/tests/UsersTest.php index 6f4dbebdc616..96e706f7daa2 100644 --- a/apps/provisioning_api/tests/UsersTest.php +++ b/apps/provisioning_api/tests/UsersTest.php @@ -721,6 +721,10 @@ public function testGetUserAsAdmin() { ->method('fillStorageInfo') ->with('UserToGet') ->will($this->returnValue(['DummyValue'])); + $targetUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('UserToGet')); $targetUser ->expects($this->once()) ->method('getDisplayName') @@ -797,6 +801,10 @@ public function testGetUserAsSubAdminAndUserIsAccessible() { ->expects($this->once()) ->method('getDisplayName') ->will($this->returnValue('Demo User')); + $targetUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('UserToGet')); $targetUser ->expects($this->once()) ->method('isEnabled') @@ -903,6 +911,10 @@ public function testGetUserAsSubAdminSelfLookup() { ->expects($this->once()) ->method('getDisplayName') ->will($this->returnValue('Subadmin User')); + $targetUser + ->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('subadmin')); $targetUser ->expects($this->once()) ->method('getEMailAddress') diff --git a/changelog/10.9.0_2021-12-09/39577 b/changelog/10.9.0_2021-12-09/39577 new file mode 100644 index 000000000000..17b15451bf14 --- /dev/null +++ b/changelog/10.9.0_2021-12-09/39577 @@ -0,0 +1,7 @@ +Bugfix: Provisioning API quota is incomplete when username casing is not exact + +The Provisioning API now returns all the quota information for a user even when +the username casing is different in the API request. + +https://github.com/owncloud/core/pull/39586 +https://github.com/owncloud/core/issues/39577 diff --git a/tests/acceptance/features/apiProvisioning-v1/getUser.feature b/tests/acceptance/features/apiProvisioning-v1/getUser.feature index a6824ab22fc5..972158ec5ef0 100644 --- a/tests/acceptance/features/apiProvisioning-v1/getUser.feature +++ b/tests/acceptance/features/apiProvisioning-v1/getUser.feature @@ -17,6 +17,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "Brand New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @skipOnOcV10.6 @skipOnOcV10.7 @skipOnOcV10.8.0 @@ -30,6 +31,7 @@ Feature: get user And the display name returned by the API should be "" And the email address returned by the API should be "" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp Examples: | username | displayname | email | @@ -46,6 +48,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "Brand New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @@ -69,6 +72,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @notToImplementOnOCIS @@ -105,6 +109,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @skipOnOcV10.6 @skipOnOcV10.7 @skipOnOcV10.8.0 @@ -117,6 +122,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @skipOnOcV10.6 @skipOnOcV10.7 @skipOnOcV10.8.0 @@ -129,6 +135,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @skipOnOcV10.6 @skipOnOcV10.7 @skipOnOcV10.8.0 @@ -141,6 +148,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @skipOnOcV10.6 @skipOnOcV10.7 @skipOnOcV10.8.0 @@ -153,6 +161,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @skipOnOcV10.6 @skipOnOcV10.7 @skipOnOcV10.8.0 @@ -166,6 +175,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "Admin Alice" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @notToImplementOnOCIS @skipOnOcV10.6 @skipOnOcV10.7 @skipOnOcV10.8.0 @@ -183,6 +193,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "Regular User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @notToImplementOnOCIS diff --git a/tests/acceptance/features/apiProvisioning-v2/getUser.feature b/tests/acceptance/features/apiProvisioning-v2/getUser.feature index f0f7221bf5a5..302eea885f52 100644 --- a/tests/acceptance/features/apiProvisioning-v2/getUser.feature +++ b/tests/acceptance/features/apiProvisioning-v2/getUser.feature @@ -17,6 +17,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "Brand New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @skipOnOcV10.6 @skipOnOcV10.7 @skipOnOcV10.8.0 @@ -30,6 +31,7 @@ Feature: get user And the display name returned by the API should be "" And the email address returned by the API should be "" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp Examples: | username | displayname | email | @@ -46,6 +48,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "Brand New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @@ -69,6 +72,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @notToImplementOnOCIS @@ -105,6 +109,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @skipOnOcV10.6 @skipOnOcV10.7 @skipOnOcV10.8.0 @@ -117,6 +122,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @skipOnOcV10.6 @skipOnOcV10.7 @skipOnOcV10.8.0 @@ -129,6 +135,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @skipOnOcV10.6 @skipOnOcV10.7 @skipOnOcV10.8.0 @@ -141,6 +148,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @skipOnOcV10.6 @skipOnOcV10.7 @skipOnOcV10.8.0 @@ -153,6 +161,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "New User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @notToImplementOnOCIS @skipOnOcV10.6 @skipOnOcV10.7 @skipOnOcV10.8.0 @@ -166,6 +175,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "Admin Alice" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @notToImplementOnOCIS @skipOnOcV10.6 @skipOnOcV10.7 @skipOnOcV10.8.0 @@ -183,6 +193,7 @@ Feature: get user And the HTTP status code should be "200" And the display name returned by the API should be "Regular User" And the quota definition returned by the API should be "default" + And the free, used, total and relative quota returned by the API should exist and be valid numbers And the last login returned by the API should be a current Unix timestamp @notToImplementOnOCIS diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index fd65118c79c0..e66c3359b5b9 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -4882,6 +4882,47 @@ public function theEmailAddressOfUserShouldNotHaveChanged(string $user):void { $this->theEmailAddressReturnedByTheApiShouldBe($expectedEmailAddress); } + /** + * @Then /^the free, used, total and relative quota returned by the API should exist and be valid numbers$/ + * + * @return void + * @throws Exception + */ + public function theQuotaFieldsReturnedByTheApiShouldBValid():void { + $quotaData = $this->getResponseXml(null, __METHOD__)->data[0]->quota; + $missingQuotaDataString = ""; + if (!isset($quotaData->free)) { + $missingQuotaDataString .= "free "; + } + if (!isset($quotaData->used)) { + $missingQuotaDataString .= "used "; + } + if (!isset($quotaData->total)) { + $missingQuotaDataString .= "total "; + } + if (!isset($quotaData->relative)) { + $missingQuotaDataString .= "relative "; + } + Assert::assertSame( + "", + $missingQuotaDataString, + "These quota data items are missing: $missingQuotaDataString" + ); + $freeQuota = (string) $quotaData->free; + Assert::assertIsNumeric($freeQuota, "free quota '$freeQuota' is not numeric"); + $usedQuota = (string) $quotaData->used; + Assert::assertIsNumeric($usedQuota, "used quota '$usedQuota' is not numeric"); + $totalQuota = (string) $quotaData->total; + Assert::assertIsNumeric($totalQuota, "total quota '$totalQuota' is not numeric"); + $relativeQuota = (string) $quotaData->relative; + Assert::assertIsNumeric($relativeQuota, "free quota '$relativeQuota' is not numeric"); + Assert::assertSame( + (int) $freeQuota + (int) $usedQuota, + (int) $totalQuota, + "free $freeQuota plus used $usedQuota quota is not equal to total quota $totalQuota" + ); + } + /** * @Then /^the quota definition returned by the API should be "([^"]*)"$/ *