aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHamza <40746210+hamza221@users.noreply.github.com>2024-10-30 10:07:51 +0100
committerGitHub <noreply@github.com>2024-10-30 10:07:51 +0100
commitd99c24bdcad7467a2a74e58298b05882a53a08d0 (patch)
tree7a58db3d110af189a235c61abf7ce569d06d67bb
parent42c7aab402c17051c251af38dadd8e00cad8f801 (diff)
parent061b4e99fb834efaf4a085e8944e99c16da1ac61 (diff)
downloadnextcloud-server-d99c24bdcad7467a2a74e58298b05882a53a08d0.tar.gz
nextcloud-server-d99c24bdcad7467a2a74e58298b05882a53a08d0.zip
Merge pull request #48472 from nextcloud/backport/47846/stable28
[stable28] fix: provision api's status codes
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php20
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php8
-rw-r--r--build/integration/features/provisioning-v1.feature12
3 files changed, 20 insertions, 20 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index dd5114a106e..e1c60f3eb67 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -981,7 +981,7 @@ class UsersController extends AUserData {
}
// Check if permitted to edit this field
if (!in_array($key, $permittedFields)) {
- throw new OCSException('', 103);
+ throw new OCSException('', 113);
}
// Process the edit
switch ($key) {
@@ -1036,7 +1036,7 @@ class UsersController extends AUserData {
}
$targetUser->setPassword($value);
} catch (HintException $e) { // password policy error
- throw new OCSException($e->getMessage(), 103);
+ throw new OCSException($e->getMessage(), 107);
}
break;
case self::USER_FIELD_LANGUAGE:
@@ -1069,14 +1069,14 @@ class UsersController extends AUserData {
}
}
if (!$success) {
- throw new OCSException('', 102);
+ throw new OCSException('', 101);
}
break;
case IAccountManager::PROPERTY_EMAIL:
if (filter_var($value, FILTER_VALIDATE_EMAIL) || $value === '') {
$targetUser->setEMailAddress($value);
} else {
- throw new OCSException('', 102);
+ throw new OCSException('', 101);
}
break;
case IAccountManager::COLLECTION_EMAIL:
@@ -1085,13 +1085,13 @@ class UsersController extends AUserData {
$mailCollection = $userAccount->getPropertyCollection(IAccountManager::COLLECTION_EMAIL);
if ($mailCollection->getPropertyByValue($value)) {
- throw new OCSException('', 102);
+ throw new OCSException('', 101);
}
$mailCollection->addPropertyWithDefaults($value);
$this->accountManager->updateAccount($userAccount);
} else {
- throw new OCSException('', 102);
+ throw new OCSException('', 101);
}
break;
case IAccountManager::PROPERTY_PHONE:
@@ -1113,7 +1113,7 @@ class UsersController extends AUserData {
$this->knownUserService->deleteByContactUserId($targetUser->getUID());
}
} catch (InvalidArgumentException $e) {
- throw new OCSException('Invalid ' . $e->getMessage(), 102);
+ throw new OCSException('Invalid ' . $e->getMessage(), 101);
}
}
} catch (PropertyDoesNotExistException $e) {
@@ -1122,7 +1122,7 @@ class UsersController extends AUserData {
try {
$this->accountManager->updateAccount($userAccount);
} catch (InvalidArgumentException $e) {
- throw new OCSException('Invalid ' . $e->getMessage(), 102);
+ throw new OCSException('Invalid ' . $e->getMessage(), 101);
}
break;
case IAccountManager::PROPERTY_PROFILE_ENABLED:
@@ -1158,12 +1158,12 @@ class UsersController extends AUserData {
$userProperty->setScope($value);
$this->accountManager->updateAccount($userAccount);
} catch (InvalidArgumentException $e) {
- throw new OCSException('Invalid ' . $e->getMessage(), 102);
+ throw new OCSException('Invalid ' . $e->getMessage(), 101);
}
}
break;
default:
- throw new OCSException('', 103);
+ throw new OCSException('', 113);
}
return new DataResponse();
}
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index a48461c0a27..66e54efb650 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -1650,7 +1650,7 @@ class UsersControllerTest extends TestCase {
->with($userAccount);
$this->expectException(OCSException::class);
- $this->expectExceptionCode(102);
+ $this->expectExceptionCode(101);
$this->api->editUser('UserToEdit', 'additional_mail', 'demo@nextcloud.com')->getData();
}
@@ -1709,13 +1709,13 @@ class UsersControllerTest extends TestCase {
->with($userAccount);
$this->expectException(OCSException::class);
- $this->expectExceptionCode(102);
+ $this->expectExceptionCode(101);
$this->api->editUser('UserToEdit', 'additional_mail', 'demo1@nextcloud.com')->getData();
}
public function testEditUserRegularUserSelfEditChangeEmailInvalid() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class);
- $this->expectExceptionCode(102);
+ $this->expectExceptionCode(101);
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
@@ -1947,7 +1947,7 @@ class UsersControllerTest extends TestCase {
public function testEditUserRegularUserSelfEditChangeQuota() {
$this->expectException(\OCP\AppFramework\OCS\OCSException::class);
- $this->expectExceptionCode(103);
+ $this->expectExceptionCode(113);
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
diff --git a/build/integration/features/provisioning-v1.feature b/build/integration/features/provisioning-v1.feature
index 0d1d5b1a345..be5473ea1e7 100644
--- a/build/integration/features/provisioning-v1.feature
+++ b/build/integration/features/provisioning-v1.feature
@@ -208,7 +208,7 @@ Feature: provisioning
And sending "PUT" to "/cloud/users/brand-new-user" with
| key | additional_mail |
| value | no-reply@nextcloud.com |
- And the OCS status code should be "102"
+ And the OCS status code should be "101"
And the HTTP status code should be "200"
And sending "PUT" to "/cloud/users/brand-new-user" with
| key | additional_mail |
@@ -219,7 +219,7 @@ Feature: provisioning
And sending "PUT" to "/cloud/users/brand-new-user" with
| key | additional_mail |
| value | no.reply2@nextcloud.com |
- And the OCS status code should be "102"
+ And the OCS status code should be "101"
And the HTTP status code should be "200"
Then user "brand-new-user" has
| id | brand-new-user |
@@ -264,17 +264,17 @@ Feature: provisioning
When sending "PUT" to "/cloud/users/brand-new-user" with
| key | phoneScope |
| value | invalid |
- Then the OCS status code should be "102"
+ Then the OCS status code should be "101"
And the HTTP status code should be "200"
When sending "PUT" to "/cloud/users/brand-new-user" with
| key | displaynameScope |
| value | v2-private |
- Then the OCS status code should be "102"
+ Then the OCS status code should be "101"
And the HTTP status code should be "200"
When sending "PUT" to "/cloud/users/brand-new-user" with
| key | emailScope |
| value | v2-private |
- Then the OCS status code should be "102"
+ Then the OCS status code should be "101"
And the HTTP status code should be "200"
Scenario: Edit a user account multi-value property scopes with invalid or unsupported value
@@ -320,7 +320,7 @@ Feature: provisioning
When sending "PUT" to "/cloud/users/brand-new-user" with
| key | phoneScope |
| value | v2-private |
- Then the OCS status code should be "103"
+ Then the OCS status code should be "113"
And the HTTP status code should be "200"
Scenario: Search by phone number