You are here

public function SimpleOauthTestTrait::setUpKeys in Simple OAuth (OAuth2) & OpenID Connect 5.x

Same name and namespace in other branches
  1. 8.4 tests/src/Functional/SimpleOauthTestTrait.php \Drupal\Tests\simple_oauth\Functional\SimpleOauthTestTrait::setUpKeys()
  2. 8.3 tests/src/Functional/SimpleOauthTestTrait.php \Drupal\Tests\simple_oauth\Functional\SimpleOauthTestTrait::setUpKeys()

Set up public and private keys.

2 calls to SimpleOauthTestTrait::setUpKeys()
RolesNegotiationFunctionalTest::setUp in tests/src/Functional/RolesNegotiationFunctionalTest.php
TokenBearerFunctionalTestBase::setUp in tests/src/Functional/TokenBearerFunctionalTestBase.php

File

tests/src/Functional/SimpleOauthTestTrait.php, line 51

Class

SimpleOauthTestTrait
Trait with methods needed by tests.

Namespace

Drupal\Tests\simple_oauth\Functional

Code

public function setUpKeys() {
  $public_key_path = 'private://public.key';
  $private_key_path = 'private://private.key';
  file_put_contents($public_key_path, $this->publicKey);
  file_put_contents($private_key_path, $this->privateKey);
  chmod($public_key_path, 0660);
  chmod($private_key_path, 0660);
  $settings = $this
    ->config('simple_oauth.settings');
  $settings
    ->set('public_key', $public_key_path);
  $settings
    ->set('private_key', $private_key_path);
  $settings
    ->save();
}