def test_auth_with_experimental_access(self): paste_file = \ "zun/tests/unit/api/controllers/auth-experimental-access.ini" app = self.make_app(paste_file) response = app.get('/', expect_errors=True) self.assertEqual(401, response.status_int) response = app.get('/experimental/') self.assertEqual(self.experimental_expected, response.json)
def test_auth_with_no_public_routes(self): # All apis need auth when access paste_file = "zun/tests/unit/api/controllers/auth-paste.ini" app = self.make_app(paste_file) response = app.get('/', expect_errors=True) self.assertEqual(401, response.status_int) response = app.get('/v1/', expect_errors=True) self.assertEqual(401, response.status_int)
def test_auth_with_v1_access(self): # Only /v1 can access without auth paste_file = "zun/tests/unit/api/controllers/auth-v1-access.ini" app = self.make_app(paste_file) response = app.get('/', expect_errors=True) self.assertEqual(401, response.status_int) response = app.get('/v1/') self.assertEqual(self.v1_expected, response.json) response = app.get('/v1/containers', expect_errors=True) self.assertEqual(401, response.status_int)
def test_noauth(self): # Don't need to auth paste_file = "zun/tests/unit/api/controllers/noauth-paste.ini" app = self.make_app(paste_file) response = app.get('/') self.assertEqual(self.root_expected, response.json) response = app.get('/v1/') self.assertEqual(self.v1_expected, response.json) response = app.get('/v1/containers/') self.assertEqual(200, response.status_int)
def test_noauth(self): # Don't need to auth paste_file = "zun/tests/unit/api/controllers/noauth-paste.ini" headers = {'OpenStack-API-Version': CURRENT_VERSION} app = self.make_app(paste_file) response = app.get('/', headers=headers) self.assertEqual(self.root_expected, response.json) response = app.get('/v1/', headers=headers) self.assertEqual(self.v1_expected, response.json) response = app.get('/v1/containers/', headers=headers) self.assertEqual(200, response.status_int)