refstack should display error message returned from openstack openid.
Closes-Bug: #1507730 Change-Id: I396f68e62b0b1ce49d9bc83c9eaf9ab35d5d8718
This commit is contained in:
parent
bf25d59edb
commit
e35a0e3429
@ -70,7 +70,7 @@
|
|||||||
controller: 'ProfileController as ctrl'
|
controller: 'ProfileController as ctrl'
|
||||||
}).
|
}).
|
||||||
state('authFailure', {
|
state('authFailure', {
|
||||||
url: '/auth_failure/:message',
|
url: '/auth_failure',
|
||||||
templateUrl: '/components/home/home.html',
|
templateUrl: '/components/home/home.html',
|
||||||
controller: 'AuthFailureController as ctrl'
|
controller: 'AuthFailureController as ctrl'
|
||||||
}).
|
}).
|
||||||
|
@ -19,13 +19,15 @@
|
|||||||
.module('refstackApp')
|
.module('refstackApp')
|
||||||
.controller('AuthFailureController', AuthFailureController);
|
.controller('AuthFailureController', AuthFailureController);
|
||||||
|
|
||||||
AuthFailureController.$inject = ['$stateParams', '$state', 'raiseAlert'];
|
AuthFailureController.$inject = ['$location', '$state', 'raiseAlert'];
|
||||||
/**
|
/**
|
||||||
* Refstack Auth Failure Controller
|
* Refstack Auth Failure Controller
|
||||||
* This controller handles messages from Refstack API if user auth fails.
|
* This controller handles messages from Refstack API if user auth fails.
|
||||||
*/
|
*/
|
||||||
function AuthFailureController($stateParams, $state, raiseAlert) {
|
function AuthFailureController($location, $state, raiseAlert) {
|
||||||
raiseAlert('danger', 'Authentication Failure:', $stateParams.message);
|
var ctrl = this;
|
||||||
|
ctrl.message = $location.search().message;
|
||||||
|
raiseAlert('danger', 'Authentication Failure:', ctrl.message);
|
||||||
$state.go('home');
|
$state.go('home');
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
@ -627,4 +627,21 @@ describe('Refstack controllers', function () {
|
|||||||
expect(modalInstance.close).toHaveBeenCalledWith();
|
expect(modalInstance.close).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('AuthFailureController', function() {
|
||||||
|
var $location, ctrl;
|
||||||
|
|
||||||
|
beforeEach(inject(function ($controller, _$location_) {
|
||||||
|
$location = _$location_;
|
||||||
|
$location.url('/auth_failure?message=some_error_message');
|
||||||
|
ctrl = $controller('AuthFailureController', {});
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should set the authentication failure url based on error message',
|
||||||
|
function () {
|
||||||
|
expect($location.url()).toBe('/auth_failure?message=' +
|
||||||
|
'some_error_message');
|
||||||
|
expect(ctrl.message).toBe('some_error_message');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -105,8 +105,12 @@ class AuthController(rest.RestController):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def _auth_failure(self, message):
|
def _auth_failure(self, message):
|
||||||
pecan.redirect(parse.urljoin(CONF.ui_url,
|
params = {
|
||||||
'/#/auth_failure/%s') % message)
|
'message': message
|
||||||
|
}
|
||||||
|
url = parse.urljoin(CONF.ui_url,
|
||||||
|
'/#/auth_failure?' + parse.urlencode(params))
|
||||||
|
pecan.redirect(url)
|
||||||
|
|
||||||
@pecan.expose()
|
@pecan.expose()
|
||||||
def signin(self):
|
def signin(self):
|
||||||
|
@ -454,7 +454,7 @@ class AuthControllerTestCase(BaseControllerTestCase):
|
|||||||
self.assertRaises(webob.exc.HTTPRedirection,
|
self.assertRaises(webob.exc.HTTPRedirection,
|
||||||
self.controller.signin_return)
|
self.controller.signin_return)
|
||||||
mock_redirect.assert_called_once_with(
|
mock_redirect.assert_called_once_with(
|
||||||
'http://127.0.0.1/#/auth_failure/foo is not bar!!!')
|
'http://127.0.0.1/#/auth_failure?message=foo+is+not+bar%21%21%21')
|
||||||
self.assertNotIn(const.CSRF_TOKEN,
|
self.assertNotIn(const.CSRF_TOKEN,
|
||||||
self.mock_request.environ['beaker.session'])
|
self.mock_request.environ['beaker.session'])
|
||||||
|
|
||||||
@ -468,7 +468,7 @@ class AuthControllerTestCase(BaseControllerTestCase):
|
|||||||
self.assertRaises(webob.exc.HTTPRedirection,
|
self.assertRaises(webob.exc.HTTPRedirection,
|
||||||
self.controller.signin_return)
|
self.controller.signin_return)
|
||||||
mock_redirect.assert_called_once_with(
|
mock_redirect.assert_called_once_with(
|
||||||
'http://127.0.0.1/#/auth_failure/Authentication canceled.')
|
'http://127.0.0.1/#/auth_failure?message=Authentication+canceled.')
|
||||||
self.assertNotIn(const.CSRF_TOKEN,
|
self.assertNotIn(const.CSRF_TOKEN,
|
||||||
self.mock_request.environ['beaker.session'])
|
self.mock_request.environ['beaker.session'])
|
||||||
|
|
||||||
@ -480,8 +480,8 @@ class AuthControllerTestCase(BaseControllerTestCase):
|
|||||||
self.assertRaises(webob.exc.HTTPRedirection,
|
self.assertRaises(webob.exc.HTTPRedirection,
|
||||||
self.controller.signin_return)
|
self.controller.signin_return)
|
||||||
mock_redirect.assert_called_once_with(
|
mock_redirect.assert_called_once_with(
|
||||||
'http://127.0.0.1/#/auth_failure/'
|
'http://127.0.0.1/#/auth_failure'
|
||||||
'Authentication failed. Please try again.')
|
'?message=Authentication+failed.+Please+try+again.')
|
||||||
self.assertNotIn(const.CSRF_TOKEN,
|
self.assertNotIn(const.CSRF_TOKEN,
|
||||||
self.mock_request.environ['beaker.session'])
|
self.mock_request.environ['beaker.session'])
|
||||||
|
|
||||||
@ -494,8 +494,8 @@ class AuthControllerTestCase(BaseControllerTestCase):
|
|||||||
self.assertRaises(webob.exc.HTTPRedirection,
|
self.assertRaises(webob.exc.HTTPRedirection,
|
||||||
self.controller.signin_return)
|
self.controller.signin_return)
|
||||||
mock_redirect.assert_called_once_with(
|
mock_redirect.assert_called_once_with(
|
||||||
'http://127.0.0.1/#/auth_failure/'
|
'http://127.0.0.1/#/auth_failure'
|
||||||
'Authentication failed. Please try again.')
|
'?message=Authentication+failed.+Please+try+again.')
|
||||||
self.assertNotIn(const.CSRF_TOKEN,
|
self.assertNotIn(const.CSRF_TOKEN,
|
||||||
self.mock_request.environ['beaker.session'])
|
self.mock_request.environ['beaker.session'])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user