def test_context_hook_before_method_auth_info(self): state = mock.Mock(request=fakes.FakePecanRequest()) state.request.environ['keystone.token_info'] = 'assert_this' hook = hooks.ContextHook() hook.before(state) ctx = state.request.context self.assertIsInstance(ctx, magnum_context.RequestContext) self.assertEqual(fakes.fakeAuthTokenHeaders['X-Auth-Token'], ctx.auth_token) self.assertEqual('assert_this', ctx.auth_token_info)
def test_context_hook_before_method(self): state = mock.Mock(request=fakes.FakePecanRequest()) hook = hooks.ContextHook() hook.before(state) ctx = state.request.context self.assertIsInstance(ctx, magnum_context.RequestContext) self.assertEqual(ctx.auth_token, fakes.fakeAuthTokenHeaders['X-Auth-Token']) self.assertEqual(ctx.project_id, fakes.fakeAuthTokenHeaders['X-Project-Id']) self.assertEqual(ctx.user_id, fakes.fakeAuthTokenHeaders['X-User-Id']) self.assertEqual(ctx.auth_url, fakes.fakeAuthTokenHeaders['X-Auth-Url']) self.assertEqual(ctx.domain_name, fakes.fakeAuthTokenHeaders['X-User-Domain-Name']) self.assertEqual(ctx.domain_id, fakes.fakeAuthTokenHeaders['X-User-Domain-Id']) self.assertIsNone(ctx.auth_token_info)