mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-15 17:58:56 +05:30
Added exception message testing
This commit is contained in:
parent
9ac56ad547
commit
b5217271b0
@ -13,7 +13,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
function testCompleteFlowMissingClientId()
|
function testCompleteFlowMissingClientId()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', '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.');
|
||||||
|
|
||||||
$_POST['grant_type'] = 'client_credentials';
|
$_POST['grant_type'] = 'client_credentials';
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testCompleteFlowMissingClientSecret()
|
function testCompleteFlowMissingClientSecret()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', '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.');
|
||||||
|
|
||||||
$_POST = [
|
$_POST = [
|
||||||
'grant_type' => 'client_credentials',
|
'grant_type' => 'client_credentials',
|
||||||
@ -43,7 +43,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testCompleteFlowInvalidClient()
|
function testCompleteFlowInvalidClient()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'Client authentication failed');
|
||||||
|
|
||||||
$_POST = [
|
$_POST = [
|
||||||
'grant_type' => 'client_credentials',
|
'grant_type' => 'client_credentials',
|
||||||
@ -66,7 +66,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testCompleteFlowInvalidScope()
|
function testCompleteFlowInvalidScope()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The requested scope is invalid, unknown, or malformed. Check the "foo" scope.');
|
||||||
|
|
||||||
$_POST = [
|
$_POST = [
|
||||||
'grant_type' => 'client_credentials',
|
'grant_type' => 'client_credentials',
|
||||||
|
@ -14,7 +14,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
function testCompleteFlowMissingClientId()
|
function testCompleteFlowMissingClientId()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', '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.');
|
||||||
|
|
||||||
$_POST['grant_type'] = 'password';
|
$_POST['grant_type'] = 'password';
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testCompleteFlowMissingClientSecret()
|
function testCompleteFlowMissingClientSecret()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', '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.');
|
||||||
|
|
||||||
$_POST = [
|
$_POST = [
|
||||||
'grant_type' => 'password',
|
'grant_type' => 'password',
|
||||||
@ -44,7 +44,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testCompleteFlowInvalidClient()
|
function testCompleteFlowInvalidClient()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'Client authentication failed');
|
||||||
|
|
||||||
$_POST = [
|
$_POST = [
|
||||||
'grant_type' => 'password',
|
'grant_type' => 'password',
|
||||||
@ -67,7 +67,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testNoUsername()
|
function testNoUsername()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "username" parameter.');
|
||||||
|
|
||||||
$_POST = [
|
$_POST = [
|
||||||
'grant_type' => 'password',
|
'grant_type' => 'password',
|
||||||
@ -109,7 +109,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testNoPassword()
|
function testNoPassword()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "password" parameter.');
|
||||||
|
|
||||||
$_POST = [
|
$_POST = [
|
||||||
'grant_type' => 'password',
|
'grant_type' => 'password',
|
||||||
@ -152,7 +152,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testNoCallable()
|
function testNoCallable()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidGrantTypeException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidGrantTypeException', 'Null or non-callable callback set on Password grant');
|
||||||
|
|
||||||
$_POST = [
|
$_POST = [
|
||||||
'grant_type' => 'password',
|
'grant_type' => 'password',
|
||||||
@ -196,12 +196,14 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testCompleteFlowInvalidScope()
|
function testCompleteFlowInvalidScope()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The requested scope is invalid, unknown, or malformed. Check the "foo" scope.');
|
||||||
|
|
||||||
$_POST = [
|
$_POST = [
|
||||||
'grant_type' => 'password',
|
'grant_type' => 'password',
|
||||||
'client_id' => 'testapp',
|
'client_id' => 'testapp',
|
||||||
'client_secret' => 'foobar',
|
'client_secret' => 'foobar',
|
||||||
|
'username' => 'foo',
|
||||||
|
'password' => 'foobar',
|
||||||
'scope' => 'foo'
|
'scope' => 'foo'
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -242,7 +244,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testCompleteFlowNoScopes()
|
function testCompleteFlowNoScopes()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "scope" parameter.');
|
||||||
|
|
||||||
$_POST = [
|
$_POST = [
|
||||||
'grant_type' => 'password',
|
'grant_type' => 'password',
|
||||||
@ -291,7 +293,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testCompleteFlowInvalidCredentials()
|
function testCompleteFlowInvalidCredentials()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The user credentials were incorrect.');
|
||||||
|
|
||||||
$_POST = [
|
$_POST = [
|
||||||
'grant_type' => 'password',
|
'grant_type' => 'password',
|
||||||
|
@ -27,7 +27,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testCompleteFlowMissingClientId()
|
function testCompleteFlowMissingClientId()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', '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.');
|
||||||
|
|
||||||
$_POST['grant_type'] = 'refresh_token';
|
$_POST['grant_type'] = 'refresh_token';
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testCompleteFlowMissingClientSecret()
|
function testCompleteFlowMissingClientSecret()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', '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.');
|
||||||
|
|
||||||
$_POST = [
|
$_POST = [
|
||||||
'grant_type' => 'refresh_token',
|
'grant_type' => 'refresh_token',
|
||||||
@ -56,7 +56,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testCompleteFlowInvalidClient()
|
function testCompleteFlowInvalidClient()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'Client authentication failed');
|
||||||
|
|
||||||
$_POST = [
|
$_POST = [
|
||||||
'grant_type' => 'refresh_token',
|
'grant_type' => 'refresh_token',
|
||||||
@ -79,7 +79,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testCompleteFlowMissingRefreshToken()
|
function testCompleteFlowMissingRefreshToken()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "refresh_token" parameter.');
|
||||||
|
|
||||||
$_POST = [
|
$_POST = [
|
||||||
'grant_type' => 'refresh_token',
|
'grant_type' => 'refresh_token',
|
||||||
@ -113,7 +113,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
function testCompleteFlowInvalidRefreshToken()
|
function testCompleteFlowInvalidRefreshToken()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The refresh token is invalid.');
|
||||||
|
|
||||||
$_POST = [
|
$_POST = [
|
||||||
'grant_type' => 'refresh_token',
|
'grant_type' => 'refresh_token',
|
||||||
@ -352,7 +352,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$server->addGrantType($grant);
|
$server->addGrantType($grant);
|
||||||
|
|
||||||
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
|
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The requested scope is invalid, unknown, or malformed. Check the "blah" scope.');
|
||||||
|
|
||||||
$server->issueAccessToken();
|
$server->issueAccessToken();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user