def test_auth_hook_before_method_auth_info(self, mock_cls): state = mock.Mock(request=fakes.FakePecanRequest()) state.request.environ['keystone.token_info'] = 'assert_this' hook = auth.AuthInformationHook() hook.before(state) ctx = state.request.security_context self.assertIsInstance(ctx, context.RequestContext) self.assertEqual(fakes.fakeAuthTokenHeaders['X-Auth-Token'], ctx.auth_token) self.assertEqual('assert_this', ctx.auth_token_info)
def test_auth_hook_before_method(self, mock_cls): state = mock.Mock(request=fakes.FakePecanRequest()) hook = auth.AuthInformationHook() hook.before(state) ctx = state.request.security_context self.assertIsInstance(ctx, context.RequestContext) self.assertEqual(ctx.auth_token, fakes.fakeAuthTokenHeaders['X-Auth-Token']) self.assertEqual(ctx.tenant, fakes.fakeAuthTokenHeaders['X-Project-Id']) self.assertEqual(ctx.user, fakes.fakeAuthTokenHeaders['X-User-Id']) self.assertEqual(ctx.roles, [u'admin', u'ResellerAdmin', u'_member_']) self.assertEqual(ctx.auth_url, fakes.fakeAuthTokenHeaders['X-Auth-Url']) self.assertEqual(ctx.user_name, fakes.fakeAuthTokenHeaders['X-User-Name']) self.assertEqual(ctx.domain, fakes.fakeAuthTokenHeaders['X-Domain-Name']) self.assertEqual(ctx.project_domain, fakes.fakeAuthTokenHeaders['X-Project-Domain-Id']) self.assertEqual(ctx.user_domain, fakes.fakeAuthTokenHeaders['X-User-Domain-Id']) self.assertIsNone(ctx.auth_token_info)
# a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from solum.api import auth from solum.api import release # Pecan Application Configurations app = { 'root': 'solum.api.controllers.root.RootController', 'modules': ['solum.api'], 'debug': False, 'hooks': [ auth.AuthInformationHook(), release.ReleaseReporter(), ] } # Custom Configurations must be in Python dictionary format:: # # foo = {'bar':'baz'} # # All configurations are accessible at:: # pecan.conf
# Copyright 2014 - Rackspace Hosting # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from solum.api import auth # Pecan Application Configurations app = { 'root': 'solum.builder.controllers.root.RootController', 'modules': ['solum.builder'], 'debug': True, 'hooks': [auth.AuthInformationHook()] } # Custom Configurations must be in Python dictionary format:: # # foo = {'bar':'baz'} # # All configurations are accessible at:: # pecan.conf