You are here

protected function AuthenticationBasicAuthTest::setUp in Entity Share 8.3

Overrides EntityShareClientFunctionalTestBase::setUp

File

modules/entity_share_client/tests/src/Functional/AuthenticationBasicAuthTest.php, line 28

Class

AuthenticationBasicAuthTest
Functional test class for import with "Basic Auth" authorization.

Namespace

Drupal\Tests\entity_share_client\Functional

Code

protected function setUp() : void {
  parent::setUp();
  Role::load(AccountInterface::AUTHENTICATED_ROLE)
    ->grantPermission('entity_share_server_access_channels')
    ->save();

  // Change the initial remote configuration: it will use the admin user
  // to authenticate. We first test as administrative user because they have
  // access to all nodes, so we can in the beginning of the test pull the
  // channel and use `checkCreatedEntities()`.
  $plugin = $this
    ->createAuthenticationPlugin($this->adminUser, $this->remote);
  $this->remote
    ->mergePluginConfig($plugin);
  $this->remote
    ->save();

  // Give admin user access to all channels (channel user already has it).
  foreach ($this->channels as $channel) {
    $authorized_users = $channel
      ->get('authorized_users');
    $authorized_users = array_merge($authorized_users, [
      $this->adminUser
        ->uuid(),
    ]);
    $channel
      ->set('authorized_users', $authorized_users);
    $channel
      ->save();
  }

  // Create Key with channel user's credentials.
  $this
    ->createKey();
  $this
    ->postSetupFixture();
}