protected function ApiTest::setUp in Lightning API 8.4
Same name and namespace in other branches
- 8.3 tests/src/Functional/ApiTest.php \Drupal\Tests\lightning_api\Functional\ApiTest::setUp()
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ ApiTest.php, line 35
Class
- ApiTest
- Tests that OAuth and JSON:API authenticate and authorize entity operations.
Namespace
Drupal\Tests\lightning_api\FunctionalCode
protected function setUp() {
parent::setUp();
// Allow writing via JSON:API.
$this
->config('jsonapi.settings')
->set('read_only', FALSE)
->save();
// Log in as an administrator so that we can generate security keys for
// OAuth.
$account = $this
->drupalCreateUser([], NULL, TRUE);
$this
->drupalLogin($account);
$url = Url::fromRoute('lightning_api.generate_keys');
$values = [
'dir' => \Drupal::service('file_system')
->realpath('temporary://'),
'private_key' => 'private.key',
'public_key' => 'public.key',
];
$conf = getenv('OPENSSL_CONF');
if ($conf) {
$values['conf'] = $conf;
}
$this
->drupalPostForm($url, $values, 'Generate keys');
$this
->assertSession()
->pageTextContains('A key pair was generated successfully.');
$this
->drupalLogout();
}