public function ClientCredentialsFunctionalTest::testClientCredentialsGrant in Simple OAuth (OAuth2) & OpenID Connect 8.4
Same name and namespace in other branches
- 5.x tests/src/Functional/ClientCredentialsFunctionalTest.php \Drupal\Tests\simple_oauth\Functional\ClientCredentialsFunctionalTest::testClientCredentialsGrant()
Test the valid ClientCredentials grant.
File
- tests/
src/ Functional/ ClientCredentialsFunctionalTest.php, line 17
Class
- ClientCredentialsFunctionalTest
- The client credentials test.
Namespace
Drupal\Tests\simple_oauth\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
->post($this->url, $valid_payload);
$this
->assertValidTokenResponse($response, FALSE);
// 2. Test the valid without scopes.
$payload_no_scope = $valid_payload;
unset($payload_no_scope['scope']);
$response = $this
->post($this->url, $payload_no_scope);
$this
->assertValidTokenResponse($response, FALSE);
}