You are here

protected function FileUploadTest::setUpAuthorization in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/tests/src/Functional/FileUploadTest.php \Drupal\Tests\jsonapi\Functional\FileUploadTest::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()

12 calls to FileUploadTest::setUpAuthorization()
FileUploadTest::testFileUploadInvalidFileType in core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
Tests using the file upload route with an invalid file type.
FileUploadTest::testFileUploadLargerFileSize in core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
Tests using the file upload route with a file size larger than allowed.
FileUploadTest::testFileUploadMaliciousExtension in core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
Tests using the file upload POST route with malicious extensions.
FileUploadTest::testFileUploadNoExtensionSetting in core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
Tests using the file upload POST route no extension configured.
FileUploadTest::testFileUploadStrippedFilePath in core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
Tests using the file upload route with any path prefixes being stripped.

... See full list

File

core/modules/jsonapi/tests/src/Functional/FileUploadTest.php, line 876

Class

FileUploadTest
Tests binary data file upload route.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function setUpAuthorization($method) {
  switch ($method) {
    case 'GET':
      $this
        ->grantPermissionsToTestedRole([
        'view test entity',
      ]);
      break;
    case 'POST':
      $this
        ->grantPermissionsToTestedRole([
        'create entity_test entity_test_with_bundle entities',
        'access content',
      ]);
      break;
    case 'PATCH':
      $this
        ->grantPermissionsToTestedRole([
        'administer entity_test content',
        'access content',
      ]);
      break;
  }
}