Integration Testing
updated some classes dependencies to allow xunit added DI by contructor on some classes Change-Id: Ib25c5ed8e9a3e17e1768d1380796928bfb513d65 Implements: blueprint openid-oauth2-integration-testing
This commit is contained in:
parent
cfb6ddbd41
commit
b3a1fa7027
@ -9,7 +9,10 @@ use openid\services\IMementoOpenIdRequestService;
|
|||||||
use openid\services\ITrustedSitesService;
|
use openid\services\ITrustedSitesService;
|
||||||
use openid\services\IUserService;
|
use openid\services\IUserService;
|
||||||
use openid\services\IServerConfigurationService;
|
use openid\services\IServerConfigurationService;
|
||||||
|
use openid\requests\OpenIdAuthenticationRequest;
|
||||||
use openid\XRDS\XRDSDocumentBuilder;
|
use openid\XRDS\XRDSDocumentBuilder;
|
||||||
|
use strategies\OpenIdLoginStrategy;
|
||||||
|
use strategies\OpenIdConsentStrategy;
|
||||||
use utils\IPHelper;
|
use utils\IPHelper;
|
||||||
use services\IUserActionService;
|
use services\IUserActionService;
|
||||||
use strategies\DefaultLoginStrategy;
|
use strategies\DefaultLoginStrategy;
|
||||||
@ -73,16 +76,16 @@ class UserController extends BaseController
|
|||||||
//openid stuff
|
//openid stuff
|
||||||
$this->beforeFilter('openid.save.request');
|
$this->beforeFilter('openid.save.request');
|
||||||
$this->beforeFilter('openid.needs.auth.request', array('only' => array('getConsent')));
|
$this->beforeFilter('openid.needs.auth.request', array('only' => array('getConsent')));
|
||||||
$this->login_strategy = new OpenIdLoginStrategy($openid_memento_service, $user_action_service, $auth_service);
|
$this->login_strategy = new OpenIdLoginStrategy($openid_memento_service, $user_action_service, $auth_service);
|
||||||
$this->consent_strategy = new OpenIdConsentStrategy($openid_memento_service, $auth_service, $server_configuration_service, $user_action_service);
|
$this->consent_strategy = new OpenIdConsentStrategy($openid_memento_service, $auth_service, $server_configuration_service, $user_action_service);
|
||||||
} else if (!is_null($oauth2_msg) && $oauth2_msg->isValid()) {
|
} else if (!is_null($oauth2_msg) && $oauth2_msg->isValid()) {
|
||||||
$this->beforeFilter('oauth2.save.request');
|
$this->beforeFilter('oauth2.save.request');
|
||||||
$this->beforeFilter('oauth2.needs.auth.request', array('only' => array('getConsent')));
|
$this->beforeFilter('oauth2.needs.auth.request', array('only' => array('getConsent')));
|
||||||
$this->login_strategy = new OAuth2LoginStrategy();
|
$this->login_strategy = new OAuth2LoginStrategy();
|
||||||
$this->consent_strategy = new OAuth2ConsentStrategy($auth_service, $oauth2_memento_service, $scope_service, $client_service);
|
$this->consent_strategy = new OAuth2ConsentStrategy($auth_service, $oauth2_memento_service, $scope_service, $client_service);
|
||||||
} else {
|
} else {
|
||||||
//default stuff
|
//default stuff
|
||||||
$this->login_strategy = new DefaultLoginStrategy($user_action_service, $auth_service);
|
$this->login_strategy = new DefaultLoginStrategy($user_action_service, $auth_service);
|
||||||
$this->consent_strategy = null;
|
$this->consent_strategy = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,38 +111,37 @@ Route::filter('ajax', function()
|
|||||||
|
|
||||||
Route::filter("openid.needs.auth.request", function () {
|
Route::filter("openid.needs.auth.request", function () {
|
||||||
|
|
||||||
$memento_service = App::make(OpenIdServiceCatalog::MementoService);
|
$memento_service = ServiceLocator::getInstance()->getService(OpenIdServiceCatalog::MementoService);
|
||||||
$openid_message = $memento_service->getCurrentRequest();
|
$openid_message = $memento_service->getCurrentRequest();
|
||||||
|
|
||||||
if ($openid_message == null || !$openid_message->isValid())
|
if ($openid_message == null || !$openid_message->isValid())
|
||||||
throw new InvalidOpenIdMessageException();
|
throw new InvalidOpenIdMessageException();
|
||||||
|
$configuration_service = ServiceLocator::getInstance()->getService(OpenIdServiceCatalog::ServerConfigurationService);
|
||||||
$auth_request = new OpenIdAuthenticationRequest($openid_message);
|
$auth_request = new OpenIdAuthenticationRequest($openid_message, $configuration_service->getUserIdentityEndpointURL('@identifier'));
|
||||||
if (!$auth_request->isValid())
|
if (!$auth_request->isValid())
|
||||||
throw new InvalidOpenIdMessageException();
|
throw new InvalidOpenIdMessageException();
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::filter("openid.save.request", function () {
|
Route::filter("openid.save.request", function () {
|
||||||
|
|
||||||
$memento_service = App::make(OpenIdServiceCatalog::MementoService);
|
$memento_service = ServiceLocator::getInstance()->getService(OpenIdServiceCatalog::MementoService);
|
||||||
$memento_service->saveCurrentRequest();
|
$memento_service->saveCurrentRequest();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::filter("oauth2.save.request", function () {
|
Route::filter("oauth2.save.request", function () {
|
||||||
|
|
||||||
$memento_service = App::make(OAuth2ServiceCatalog::MementoService);
|
$memento_service = ServiceLocator::getInstance()->getService(OAuth2ServiceCatalog::MementoService);
|
||||||
$memento_service->saveCurrentAuthorizationRequest();
|
$memento_service->saveCurrentAuthorizationRequest();
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::filter("oauth2.needs.auth.request", function () {
|
Route::filter("oauth2.needs.auth.request", function () {
|
||||||
|
|
||||||
$memento_service = App::make(OAuth2ServiceCatalog::MementoService);
|
$memento_service = ServiceLocator::getInstance()->getService(OAuth2ServiceCatalog::MementoService);
|
||||||
$oauth2_message = $memento_service->getCurrentAuthorizationRequest();
|
$oauth2_message = $memento_service->getCurrentAuthorizationRequest();
|
||||||
|
|
||||||
if ($oauth2_message == null || !$oauth2_message->isValid())
|
if ($oauth2_message == null || !$oauth2_message->isValid())
|
||||||
throw new InvalidAuthorizationRequestException();
|
throw new InvalidAuthorizationRequestException();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::filter("ssl", function () {
|
Route::filter("ssl", function () {
|
||||||
@ -150,7 +149,7 @@ Route::filter("ssl", function () {
|
|||||||
$openid_memento_service = ServiceLocator::getInstance()->getService(OpenIdServiceCatalog::MementoService);
|
$openid_memento_service = ServiceLocator::getInstance()->getService(OpenIdServiceCatalog::MementoService);
|
||||||
$openid_memento_service->saveCurrentRequest();
|
$openid_memento_service->saveCurrentRequest();
|
||||||
|
|
||||||
$oauth2_memento_service = App::make(OAuth2ServiceCatalog::MementoService);
|
$oauth2_memento_service = ServiceLocator::getInstance()->getService(OAuth2ServiceCatalog::MementoService);
|
||||||
$oauth2_memento_service->saveCurrentAuthorizationRequest();
|
$oauth2_memento_service->saveCurrentAuthorizationRequest();
|
||||||
|
|
||||||
return Redirect::secure(Request::getRequestUri());
|
return Redirect::secure(Request::getRequestUri());
|
||||||
@ -159,8 +158,8 @@ Route::filter("ssl", function () {
|
|||||||
|
|
||||||
Route::filter('user.owns.client.policy',function($route, $request){
|
Route::filter('user.owns.client.policy',function($route, $request){
|
||||||
try{
|
try{
|
||||||
$authentication_service = App::make(UtilsServiceCatalog::AuthenticationService);
|
$authentication_service = ServiceLocator::getInstance()->getService(UtilsServiceCatalog::AuthenticationService);
|
||||||
$client_service = App::make(OAuth2ServiceCatalog::ClientService);
|
$client_service = ServiceLocator::getInstance()->getService(OAuth2ServiceCatalog::ClientService);
|
||||||
$client_id = $route->getParameter('id');
|
$client_id = $route->getParameter('id');
|
||||||
$client = $client_service->getClientByIdentifier($client_id);
|
$client = $client_service->getClientByIdentifier($client_id);
|
||||||
$user = $authentication_service->getCurrentUser();
|
$user = $authentication_service->getCurrentUser();
|
||||||
@ -175,7 +174,7 @@ Route::filter('user.owns.client.policy',function($route, $request){
|
|||||||
|
|
||||||
Route::filter('is.current.user',function($route, $request){
|
Route::filter('is.current.user',function($route, $request){
|
||||||
try{
|
try{
|
||||||
$authentication_service = App::make(UtilsServiceCatalog::AuthenticationService);
|
$authentication_service = ServiceLocator::getInstance()->getService(UtilsServiceCatalog::AuthenticationService);
|
||||||
$used_id = Input::get('user_id',null);
|
$used_id = Input::get('user_id',null);
|
||||||
|
|
||||||
if(is_null($used_id))
|
if(is_null($used_id))
|
||||||
|
Loading…
Reference in New Issue
Block a user