예제 #1
0
 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)
예제 #2
0
 def test_auth_hook_before_method(self, mock_cls):
     state = mock.Mock(request=fakes.FakePecanRequest())
     hook = auth.ContextHook()
     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.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)