You are here

protected function AuthenticationOAuthTest::createOauthConsumer in Entity Share 8.3

Create a service consumer for OAuth.

Parameters

\Drupal\user\UserInterface $account: The user whose credentials will be used for the plugin.

\Drupal\user\RoleInterface $role: The user role for OAuth consumer.

1 call to AuthenticationOAuthTest::createOauthConsumer()
AuthenticationOAuthTest::serverOauthSetup in modules/entity_share_client/tests/src/Functional/AuthenticationOAuthTest.php
Helper function: creates needed server-side entities needed for OAuth.

File

modules/entity_share_client/tests/src/Functional/AuthenticationOAuthTest.php, line 396

Class

AuthenticationOAuthTest
Functional test class for import with "OAuth" authorization.

Namespace

Drupal\Tests\entity_share_client\Functional

Code

protected function createOauthConsumer(UserInterface $account, RoleInterface $role) {

  // Create a Consumer.
  $client = Consumer::create([
    'owner_id' => '',
    'user_id' => $account
      ->id(),
    'label' => $this
      ->getRandomGenerator()
      ->name(),
    'secret' => $this->clientSecret,
    'confidential' => FALSE,
    'third_party' => TRUE,
    'roles' => [
      [
        'target_id' => $role
          ->id(),
      ],
    ],
  ]);
  $client
    ->save();
  $this->clients[$account
    ->id()] = $client;
}