protected function AuthCodeFunctionalTest::setUp in Simple OAuth (OAuth2) & OpenID Connect 8.4
Same name and namespace in other branches
- 5.x tests/src/Functional/AuthCodeFunctionalTest.php \Drupal\Tests\simple_oauth\Functional\AuthCodeFunctionalTest::setUp()
Overrides TokenBearerFunctionalTestBase::setUp
File
- tests/
src/ Functional/ AuthCodeFunctionalTest.php, line 50
Class
- AuthCodeFunctionalTest
- The auth code test.
Namespace
Drupal\Tests\simple_oauth\FunctionalCode
protected function setUp() {
parent::setUp();
$this->redirectUri = Url::fromRoute('oauth2_token.test_token', [], [
'absolute' => TRUE,
])
->toString();
$this->client
->set('redirect', $this->redirectUri);
$this->client
->set('description', $this
->getRandomGenerator()
->paragraphs());
$this->client
->save();
$this->authorizeUrl = Url::fromRoute('oauth2_token.authorize');
$this
->grantPermissions(Role::load(RoleInterface::AUTHENTICATED_ID), [
'grant simple_oauth codes',
]);
// Add a scope so we can ensure all tests have at least 2 roles. That way we
// can test dropping a scope and still have at least one scope.
$additional_scope = $this
->getRandomGenerator()
->name(8, TRUE);
Role::create([
'id' => $additional_scope,
'label' => $this
->getRandomGenerator()
->word(5),
'is_admin' => FALSE,
])
->save();
$this->scope = $this->scope . ' ' . $additional_scope;
// Add a random scope that is not in the base scopes list to request so we
// can make extra checks on it.
$this->extraRole = Role::create([
'id' => $this
->getRandomGenerator()
->name(8, TRUE),
'label' => $this
->getRandomGenerator()
->word(5),
'is_admin' => FALSE,
]);
$this->extraRole
->save();
}