add test for get_one() when server_uuid not found

Closes-Bug:#1808918

Change-Id: I265defee39a8c5795f3d23c617af00bc1d5c3c96
This commit is contained in:
zhaodan 2018-12-18 14:50:00 +08:00 committed by zhaodan7597
parent 1c9b721b5c
commit 03eba771f4
1 changed files with 16 additions and 0 deletions

View File

@ -140,6 +140,14 @@ class TestServerAuthorization(v1_test.APITestV1):
headers=headers)
self.assertNotIn('node', resp)
def test_server_get_one_by_owner_with_wrong_uuid(self):
# not admin but the owner
self.context.tenant = self.server1.project_id
headers = self.gen_headers(self.context, roles="no-admin")
resp = self.get_json('/servers/%s' % uuidutils.generate_uuid(),
expect_errors=True, headers=headers)
self.assertEqual(resp.status_code, 404)
def test_server_get_one_by_admin(self):
# when the evil tenant is admin, he can do everything.
self.context.tenant = self.evil_project
@ -148,6 +156,14 @@ class TestServerAuthorization(v1_test.APITestV1):
headers=headers)
self.assertIn('node', resp)
def test_server_get_one_by_admin_with_wrong_uuid(self):
# when the evil tenant is admin, he can do everything.
self.context.tenant = self.evil_project
headers = self.gen_headers(self.context, roles="admin")
resp = self.get_json('/servers/%s' % uuidutils.generate_uuid(),
expect_errors=True, headers=headers)
self.assertEqual(resp.status_code, 404)
def test_server_get_one_unauthorized(self):
# not admin and not the owner
self.context.tenant = self.evil_project