public function ClientCredentialsFunctionalTest::testClientCredentialsGrant in Simple OAuth (OAuth2) & OpenID Connect 8.2
Same name and namespace in other branches
- 8.3 simple_oauth_extras/tests/src/Functional/ClientCredentialsFunctionalTest.php \Drupal\Tests\simple_oauth_extras\Functional\ClientCredentialsFunctionalTest::testClientCredentialsGrant()
Test the valid ClientCredentials grant.
File
- simple_oauth_extras/
tests/ src/ Functional/ ClientCredentialsFunctionalTest.php, line 20
Class
- ClientCredentialsFunctionalTest
- @group simple_oauth_extras
Namespace
Drupal\Tests\simple_oauth_extras\FunctionalCode
public function testClientCredentialsGrant() {
// 1. Test the valid response.
$valid_payload = [
'grant_type' => 'client_credentials',
'client_id' => $this->client
->uuid(),
'client_secret' => $this->clientSecret,
'scope' => $this->scope,
];
$response = $this
->request('POST', $this->url, [
'form_params' => $valid_payload,
]);
$this
->assertValidTokenResponse($response, FALSE);
// 2. Test the valid without scopes.
$payload_no_scope = $valid_payload;
unset($payload_no_scope['scope']);
$response = $this
->request('POST', $this->url, [
'form_params' => $payload_no_scope,
]);
$this
->assertValidTokenResponse($response, FALSE);
}