summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Browning2013-07-05 15:24:16 (GMT)
committer Kyle Browning2013-07-05 15:24:16 (GMT)
commit492920ee87e2c53adc901acbec9efd95982842a9 (patch)
tree180ccfbef1570f3894c35467a302381d87b49806
parent5d248632da907097f0e93bd589108654bf4f4bca (diff)
Issue [#2032153] by Yorirou7.x-3.5
-rw-r--r--resources/user_resource.inc4
-rw-r--r--tests/functional/ServicesResourceUserTests.test17
2 files changed, 21 insertions, 0 deletions
diff --git a/resources/user_resource.inc b/resources/user_resource.inc
index e7eead4..2d7be21 100644
--- a/resources/user_resource.inc
+++ b/resources/user_resource.inc
@@ -348,6 +348,10 @@ function _user_resource_update($uid, $account) {
* @see user_delete()
*/
function _user_resource_delete($uid) {
+ if ($uid == 1) {
+ return services_error(t('The admin user cannot be deleted.'), 403);
+ }
+
$account = user_load($uid);
if (empty($account)) {
return services_error(t('There is no user with ID @uid.', array('@uid' => $uid)), 404);
diff --git a/tests/functional/ServicesResourceUserTests.test b/tests/functional/ServicesResourceUserTests.test
index 6bae2f7..189e1d9 100644
--- a/tests/functional/ServicesResourceUserTests.test
+++ b/tests/functional/ServicesResourceUserTests.test
@@ -253,6 +253,23 @@ class ServicesResourceUsertests extends ServicesWebtestCase {
}
/**
+ * Test delete system user method.
+ */
+ function testDeleteSystemUser() {
+ // Delete user 0.
+ $response = $this->servicesDelete($this->endpoint->path . '/user/0');
+
+ $this->assertTrue(strpos($response['code'], '404') !== FALSE,
+ 'Anonymous user was not deleted.', 'UserResource: Delete');
+
+ // Delete user 1.
+ $response = $this->servicesDelete($this->endpoint->path . '/user/1');
+
+ $this->assertTrue(strpos($response['status'], 'The admin user cannot be deleted.') !== FALSE,
+ 'Admin user was not deleted.', 'UserResource: Delete');
+ }
+
+ /**
* Test index method.
*
* Create several users list them. List one user by name.