def test_adds_default_auth_url_from_keystone_authtoken(self, mock_cfg): self.config = {} mock_cfg.keystone_authtoken.auth_uri = 'foobar' mock_cfg.auth_password.multi_cloud = False self.middleware = auth_url.AuthUrlFilter(self.app, self.config) req = webob.Request.blank('/tenant_id/') self.middleware(req) self.assertIn('X-Auth-Url', req.headers) self.assertEqual('foobar', req.headers['X-Auth-Url'])
def test_adds_default_auth_url_from_clients_keystone(self, mock_cfg): self.config = {} mock_cfg.clients_keystone.auth_uri = 'foobar' mock_cfg.keystone_authtoken.auth_uri = 'this-should-be-ignored' mock_cfg.auth_password.multi_cloud = False with mock.patch('keystoneauth1.discover.Discover') as discover: class MockDiscover(object): def url_for(self, endpoint): return 'foobar/v3' discover.return_value = MockDiscover() self.middleware = auth_url.AuthUrlFilter(self.app, self.config) req = webob.Request.blank('/tenant_id/') self.middleware(req) self.assertIn('X-Auth-Url', req.headers) self.assertEqual('foobar/v3', req.headers['X-Auth-Url'])
def setUp(self): super(AuthUrlFilterTest, self).setUp() self.app = FakeApp() self.config = {'auth_uri': 'foobar'} self.middleware = auth_url.AuthUrlFilter(self.app, self.config)
def test_reads_auth_url_from_local_config(self): self.middleware = auth_url.AuthUrlFilter(self.app, self.config) req = webob.Request.blank('/tenant_id/') self.middleware(req) self.assertIn('X-Auth-Url', req.headers) self.assertEqual('foobar', req.headers['X-Auth-Url'])
def test_overwrites_auth_url_from_headers_with_local_config(self): self.middleware = auth_url.AuthUrlFilter(self.app, self.config) req = webob.Request.blank('/tenant_id/') req.headers['X-Auth-Url'] = 'should_be_overwritten' self.middleware(req) self.assertEqual('foobar', req.headers['X-Auth-Url'])