mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-01-03 10:41:51 +05:30
More client credentials test
This commit is contained in:
parent
f3705865a3
commit
775d42115a
@ -2,7 +2,7 @@
|
|||||||
$I = new ApiTester($scenario);
|
$I = new ApiTester($scenario);
|
||||||
$I->wantTo('get an access token using the client credentials grant');
|
$I->wantTo('get an access token using the client credentials grant');
|
||||||
$I->sendPOST(
|
$I->sendPOST(
|
||||||
'access_token',
|
'client_credentials.php/access_token',
|
||||||
[
|
[
|
||||||
'grant_type' => 'client_credentials',
|
'grant_type' => 'client_credentials',
|
||||||
'client_id' => 'myawesomeapp',
|
'client_id' => 'myawesomeapp',
|
||||||
|
17
tests/api/ClientCredentialsInvalidClientIdCept.php
Normal file
17
tests/api/ClientCredentialsInvalidClientIdCept.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
$I = new ApiTester($scenario);
|
||||||
|
$I->wantTo('get an access token using the client credentials grant, invalid client id');
|
||||||
|
$I->sendPOST(
|
||||||
|
'client_credentials.php/access_token',
|
||||||
|
[
|
||||||
|
'grant_type' => 'client_credentials',
|
||||||
|
'client_id' => 'myawesomeapp-wrong',
|
||||||
|
'client_secret' => 'foobar'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$I->canSeeResponseCodeIs(401);
|
||||||
|
$I->canSeeResponseIsJson();
|
||||||
|
$I->seeResponseContainsJson([
|
||||||
|
'error' => 'invalid_client',
|
||||||
|
'message' => 'Client authentication failed.'
|
||||||
|
]);
|
17
tests/api/ClientCredentialsInvalidClientSecretCept.php
Normal file
17
tests/api/ClientCredentialsInvalidClientSecretCept.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
$I = new ApiTester($scenario);
|
||||||
|
$I->wantTo('get an access token using the client credentials grant, invalid client secret');
|
||||||
|
$I->sendPOST(
|
||||||
|
'client_credentials.php/access_token',
|
||||||
|
[
|
||||||
|
'grant_type' => 'client_credentials',
|
||||||
|
'client_id' => 'myawesomeapp',
|
||||||
|
'client_secret' => 'foobar'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$I->canSeeResponseCodeIs(401);
|
||||||
|
$I->canSeeResponseIsJson();
|
||||||
|
$I->seeResponseContainsJson([
|
||||||
|
'error' => 'invalid_client',
|
||||||
|
'message' => 'Client authentication failed.'
|
||||||
|
]);
|
15
tests/api/ClientCredentialsMissingClientIdCept.php
Normal file
15
tests/api/ClientCredentialsMissingClientIdCept.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
$I = new ApiTester($scenario);
|
||||||
|
$I->wantTo('get an access token using the client credentials grant, missing client id');
|
||||||
|
$I->sendPOST(
|
||||||
|
'client_credentials.php/access_token',
|
||||||
|
[
|
||||||
|
'grant_type' => 'client_credentials'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$I->canSeeResponseCodeIs(400);
|
||||||
|
$I->canSeeResponseIsJson();
|
||||||
|
$I->seeResponseContainsJson([
|
||||||
|
'error' => 'invalid_request',
|
||||||
|
'message' => 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "client_id" parameter.'
|
||||||
|
]);
|
16
tests/api/ClientCredentialsMissingClientSecretCept.php
Normal file
16
tests/api/ClientCredentialsMissingClientSecretCept.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
$I = new ApiTester($scenario);
|
||||||
|
$I->wantTo('get an access token using the client credentials grant, missing client secret');
|
||||||
|
$I->sendPOST(
|
||||||
|
'client_credentials.php/access_token',
|
||||||
|
[
|
||||||
|
'grant_type' => 'client_credentials',
|
||||||
|
'client_id' => 'myawesomeapp'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$I->canSeeResponseCodeIs(400);
|
||||||
|
$I->canSeeResponseIsJson();
|
||||||
|
$I->seeResponseContainsJson([
|
||||||
|
'error' => 'invalid_request',
|
||||||
|
'message' => 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "client_secret" parameter.'
|
||||||
|
]);
|
Loading…
Reference in New Issue
Block a user