Skip to content
Snippets Groups Projects
Unverified Commit f50fab69 authored by Patrick's avatar Patrick Committed by GitHub
Browse files

Merge pull request #24 from sigmunau/test-fixes

Fix OAuth2ResponseHandlerTest namespace usage
parents 077bae66 13f95e60
No related branches found
No related tags found
No related merge requests found
...@@ -101,15 +101,15 @@ class OAuth2ResponseHandlerTest extends \PHPUnit_Framework_TestCase ...@@ -101,15 +101,15 @@ class OAuth2ResponseHandlerTest extends \PHPUnit_Framework_TestCase
], $queryParams); ], $queryParams);
$stateValue = serialize([ $stateValue = serialize([
SimpleSAML\Auth\State::ID => 'validStateId', State::ID => 'validStateId',
SimpleSAML\Auth\State::STAGE => 'authouath2:init', State::STAGE => 'authouath2:init',
'authouath2:AuthId' => 'mockAuthSource', 'authouath2:AuthId' => 'mockAuthSource',
]); ]);
$this->mockAuthSource->method('getConfig')->willReturn( $this->mockAuthSource->method('getConfig')->willReturn(
new \SimpleSAML\Configuration(['useConsentErrorPage' => false], 'authsources:oauth2') new \SimpleSAML\Configuration(['useConsentErrorPage' => false], 'authsources:oauth2')
); );
SimpleSAML\Session::getSessionFromRequest()->setData('SimpleSAML\Auth\State', 'validStateId', $stateValue); Session::getSessionFromRequest()->setData('\SimpleSAML\Auth\State', 'validStateId', $stateValue);
$this->responseHandler->handleResponseFromRequest($request); $this->responseHandler->handleResponseFromRequest($request);
} }
...@@ -119,37 +119,37 @@ class OAuth2ResponseHandlerTest extends \PHPUnit_Framework_TestCase ...@@ -119,37 +119,37 @@ class OAuth2ResponseHandlerTest extends \PHPUnit_Framework_TestCase
// OAuth2 AS did not return error code or a authz code // OAuth2 AS did not return error code or a authz code
[ [
[], [],
SimpleSAML\Error\AuthSource::class, AuthSource::class,
"Error with authentication source 'mockAuthSource': Authentication failed: []" "Error with authentication source 'mockAuthSource': Authentication failed: []"
], ],
// OAuth2 AS says client not allowed // OAuth2 AS says client not allowed
[ [
['error' => 'unauthorized_client'], ['error' => 'unauthorized_client'],
SimpleSAML\Error\AuthSource::class, AuthSource::class,
"Error with authentication source 'mockAuthSource': Authentication failed: [unauthorized_client]" "Error with authentication source 'mockAuthSource': Authentication failed: [unauthorized_client]"
], ],
// OAuth2 AS has custom error code // OAuth2 AS has custom error code
[ [
['error' => 'special_code', 'error_description' => 'Closed'], ['error' => 'special_code', 'error_description' => 'Closed'],
SimpleSAML\Error\AuthSource::class, AuthSource::class,
"Error with authentication source 'mockAuthSource': Authentication failed: [special_code] Closed" "Error with authentication source 'mockAuthSource': Authentication failed: [special_code] Closed"
], ],
// OAuth2 AS says users denied access // OAuth2 AS says users denied access
[ [
['error' => 'access_denied', 'error_description' => 'User declined'], ['error' => 'access_denied', 'error_description' => 'User declined'],
SimpleSAML\Error\UserAborted::class, UserAborted::class,
"USERABORTED" "USERABORTED"
], ],
// OAuth2 AS says users denied access, no description // OAuth2 AS says users denied access, no description
[ [
['error' => 'access_denied'], ['error' => 'access_denied'],
SimpleSAML\Error\UserAborted::class, UserAborted::class,
"USERABORTED" "USERABORTED"
], ],
// LinkedIn uses their own error code // LinkedIn uses their own error code
[ [
['error' => 'user_cancelled_authorize', 'error_description' => 'The user cancelled the authorization'], ['error' => 'user_cancelled_authorize', 'error_description' => 'The user cancelled the authorization'],
SimpleSAML\Error\UserAborted::class, UserAborted::class,
"USERABORTED" "USERABORTED"
], ],
...@@ -166,8 +166,8 @@ class OAuth2ResponseHandlerTest extends \PHPUnit_Framework_TestCase ...@@ -166,8 +166,8 @@ class OAuth2ResponseHandlerTest extends \PHPUnit_Framework_TestCase
]; ];
$stateValue = serialize([ $stateValue = serialize([
SimpleSAML\Auth\State::ID => 'validStateId', State::ID => 'validStateId',
SimpleSAML\Auth\State::STAGE => 'authouath2:init', State::STAGE => 'authouath2:init',
'authouath2:AuthId' => 'mockAuthSource', 'authouath2:AuthId' => 'mockAuthSource',
]); ]);
// Mock completeAuth so we can verify its called later // Mock completeAuth so we can verify its called later
...@@ -183,7 +183,7 @@ class OAuth2ResponseHandlerTest extends \PHPUnit_Framework_TestCase ...@@ -183,7 +183,7 @@ class OAuth2ResponseHandlerTest extends \PHPUnit_Framework_TestCase
$this->equalTo('authCode') $this->equalTo('authCode')
); );
SimpleSAML\Session::getSessionFromRequest()->setData('SimpleSAML\Auth\State', 'validStateId', $stateValue); Session::getSessionFromRequest()->setData('\SimpleSAML\Auth\State', 'validStateId', $stateValue);
// when: handling the response // when: handling the response
$this->responseHandler->handleResponseFromRequest($request); $this->responseHandler->handleResponseFromRequest($request);
...@@ -223,12 +223,12 @@ class OAuth2ResponseHandlerTest extends \PHPUnit_Framework_TestCase ...@@ -223,12 +223,12 @@ class OAuth2ResponseHandlerTest extends \PHPUnit_Framework_TestCase
]; ];
$stateValue = serialize([ $stateValue = serialize([
SimpleSAML\Auth\State::ID => 'validStateId', State::ID => 'validStateId',
SimpleSAML\Auth\State::STAGE => 'authouath2:init', State::STAGE => 'authouath2:init',
'authouath2:AuthId' => 'mockAuthSource', 'authouath2:AuthId' => 'mockAuthSource',
]); ]);
SimpleSAML\Session::getSessionFromRequest()->setData('SimpleSAML\Auth\State', 'validStateId', $stateValue); Session::getSessionFromRequest()->setData('\SimpleSAML\Auth\State', 'validStateId', $stateValue);
try { try {
$this->responseHandler->handleResponseFromRequest($request); $this->responseHandler->handleResponseFromRequest($request);
$this->fail("Redirect expected"); $this->fail("Redirect expected");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment