diff --git a/core/modules/rest/src/Tests/CreateTest.php b/core/modules/rest/src/Tests/CreateTest.php index ae61ee7..5e3a08e 100644 --- a/core/modules/rest/src/Tests/CreateTest.php +++ b/core/modules/rest/src/Tests/CreateTest.php @@ -171,19 +171,17 @@ public function testCreateUser() { $entity_values = $this->entityValues($entity_type); $entity = entity_create($entity_type, $entity_values); - // Verify that user cannot create content when trying to write to fields where it is not possible. + // Verify that only administrative users can create users. if (!$account->hasPermission('administer users')) { $serialized = $this->serializer->serialize($entity, $this->defaultFormat, ['account' => $account]); $this->httpRequest('entity/' . $entity_type, 'POST', $serialized, $this->defaultMimeType); $this->assertResponse(403); - // Remove fields where non-admin users cannot write. - $entity = $this->removeUserFieldsForNonAdminUsers($entity); - } - else { - // Changed field can never be added. - unset($entity->changed); + continue; } + // Changed field can never be added. + unset($entity->changed); + $serialized = $this->serializer->serialize($entity, $this->defaultFormat, ['account' => $account]); $this->createEntityOverRestApi($entity_type, $serialized); @@ -195,9 +193,6 @@ public function testCreateUser() { $this->createEntityNoData($entity_type); $this->createEntityInvalidSerialized($entity, $entity_type); - - $this->createEntityWithoutProperPermissions($entity_type, $serialized); - } } diff --git a/core/modules/rest/src/Tests/RESTTestBase.php b/core/modules/rest/src/Tests/RESTTestBase.php index 1150bfd..750334e 100644 --- a/core/modules/rest/src/Tests/RESTTestBase.php +++ b/core/modules/rest/src/Tests/RESTTestBase.php @@ -371,18 +371,4 @@ protected function removeNodeFieldsForNonAdminUsers(NodeInterface $node) { return $node; } - /** - * Remove user fields where a non-admin user cannot write to. - * - * @param UserInterface $user - * @return UserInterface - */ - protected function removeUserFieldsForNonAdminUsers(UserInterface $user) { - unset($user->status); - unset($user->created); - unset($user->changed); - - return $user; - } - } diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php index 81386d7..ab96e9a 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -40,7 +40,7 @@ * }, * "translation" = "Drupal\user\ProfileTranslationHandler" * }, - * admin_permission = "administer user", + * admin_permission = "administer users", * base_table = "users", * data_table = "users_field_data", * label_callback = "user_format_name",