You are here

protected function ApiTestBase::generateKeys in Lightning API 8

Same name and namespace in other branches
  1. 8.2 modules/api_test/tests/src/Functional/ApiTestBase.php \Drupal\Tests\api_test\Functional\ApiTestBase::generateKeys()

Generates and store OAuth keys.

1 call to ApiTestBase::generateKeys()
ApiTestBase::setUp in modules/api_test/tests/src/Functional/ApiTestBase.php

File

modules/api_test/tests/src/Functional/ApiTestBase.php, line 58

Class

ApiTestBase

Namespace

Drupal\Tests\api_test\Functional

Code

protected function generateKeys() {
  $account = $this
    ->drupalCreateUser([], NULL, TRUE);
  $this
    ->drupalLogin($account);
  $url = Url::fromRoute('lightning_api.generate_keys');
  $this
    ->drupalGet($url);
  $values = [
    'dir' => drupal_realpath('temporary://'),
    'private_key' => 'private.key',
    'public_key' => 'public.key',
  ];
  $conf = getenv('OPENSSL_CONF');
  if ($conf) {
    $values['conf'] = $conf;
  }
  $this
    ->drupalPostForm(NULL, $values, 'Generate keys');
  $this
    ->assertSession()
    ->pageTextContains('A key pair was generated successfully.');
  $this
    ->drupalLogout();
}