protected function LayoutRestTestBase::setUpAuthorization in Drupal 8
Same name and namespace in other branches
- 9 core/modules/layout_builder/tests/src/Functional/Rest/LayoutRestTestBase.php \Drupal\Tests\layout_builder\Functional\Rest\LayoutRestTestBase::setUpAuthorization()
- 10 core/modules/layout_builder/tests/src/Functional/Rest/LayoutRestTestBase.php \Drupal\Tests\layout_builder\Functional\Rest\LayoutRestTestBase::setUpAuthorization()
Sets up the necessary authorization.
In case of a test verifying publicly accessible REST resources: grant permissions to the anonymous user role.
In case of a test verifying behavior when using a particular authentication provider: create a user with a particular set of permissions.
Because of the $method parameter, it's possible to first set up authentication for only GET, then add POST, et cetera. This then also allows for verifying a 403 in case of missing authorization.
Parameters
string $method: The HTTP method for which to set up authentication.
Overrides ResourceTestBase::setUpAuthorization
See also
::grantPermissionsToAnonymousRole()
::grantPermissionsToAuthenticatedRole()
1 call to LayoutRestTestBase::setUpAuthorization()
- LayoutRestTestBase::setUp in core/
modules/ layout_builder/ tests/ src/ Functional/ Rest/ LayoutRestTestBase.php
File
- core/
modules/ layout_builder/ tests/ src/ Functional/ Rest/ LayoutRestTestBase.php, line 109
Class
- LayoutRestTestBase
- Base class for Layout Builder REST tests.
Namespace
Drupal\Tests\layout_builder\Functional\RestCode
protected function setUpAuthorization($method) {
$permissions = array_keys($this->container
->get('user.permissions')
->getPermissions());
// Give the test user all permissions on the site. There should be no
// permission that gives the user access to layout sections over REST.
$this->account = $this
->drupalCreateUser($permissions);
}