Skip to content

Commit

Permalink
Merge pull request #39586 from owncloud/issue-39577
Browse files Browse the repository at this point in the history
[10.9.0] Return all quota fields in Provisioning API get-user requests
  • Loading branch information
Jan authored Dec 14, 2021
2 parents 1fb8915 + a436877 commit 32339b3
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/provisioning_api/lib/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 12 additions & 0 deletions apps/provisioning_api/tests/UsersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down
7 changes: 7 additions & 0 deletions changelog/10.9.0_2021-12-09/39577
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions tests/acceptance/features/apiProvisioning-v1/getUser.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,6 +31,7 @@ Feature: get user
And the display name returned by the API should be "<displayname>"
And the email address returned by the API should be "<email>"
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 |
Expand All @@ -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


Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions tests/acceptance/features/apiProvisioning-v2/getUser.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,6 +31,7 @@ Feature: get user
And the display name returned by the API should be "<displayname>"
And the email address returned by the API should be "<email>"
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 |
Expand All @@ -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


Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
41 changes: 41 additions & 0 deletions tests/acceptance/features/bootstrap/Provisioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 "([^"]*)"$/
*
Expand Down

0 comments on commit 32339b3

Please sign in to comment.