API test list receiver negative

Change-Id: I510052c54562760d5da35f8b8e8b4a8a04baece7
This commit is contained in:
likangkang01 2022-01-11 13:45:34 +08:00
parent f300314aa3
commit fd13cbe70e
1 changed files with 57 additions and 0 deletions

View File

@ -24,3 +24,60 @@ class TestReceiverListNegativeBadRequest(base.BaseSenlinAPITest):
self.assertRaises(exceptions.BadRequest,
self.client.list_objs,
'receivers', {'bogus': 'foo'})
@decorators.attr(type=['negative'])
@decorators.idempotent_id('6b93221e-ca14-443b-be54-4423a636672a')
def test_receiver_list_limit_not_int(self):
ex = self.assertRaises(exceptions.BadRequest,
self.client.list_objs,
'receivers', {'limit': 'not-int'})
message = ex.resp_body['error']['message']
self.assertEqual(
"The value for limit must be an integer: 'not-int'.",
str(message))
@decorators.attr(type=['negative'])
@decorators.idempotent_id('d13e3011-32b5-4f9d-bb57-3532c4c46228')
def test_receiver_list_global_project_false(self):
ex = self.assertRaises(exceptions.Forbidden,
self.client.list_objs,
'receivers', {'global_project': 'True'})
message = ex.resp_body['error']['message']
self.assertEqual("You are not authorized to complete this operation.",
str(message))
@decorators.attr(type=['negative'])
@decorators.idempotent_id('d7804b5e-6efd-4084-adec-531d0a8399dc')
def test_receiver_list_global_project_not_bool(self):
ex = self.assertRaises(exceptions.BadRequest,
self.client.list_objs,
'receivers', {'global_project': 'not-bool'})
message = ex.resp_body['error']['message']
self.assertEqual("Invalid value 'not-bool' specified for "
"'global_project'", str(message))
@decorators.attr(type=['negative'])
@decorators.idempotent_id('6ca48051-6030-4333-9483-074e03da5ba0')
def test_receiver_list_invalid_sort(self):
ex = self.assertRaises(exceptions.BadRequest,
self.client.list_objs,
'receivers', {'sort': 'bad-sort'})
message = ex.resp_body['error']['message']
self.assertEqual("Unsupported sort key 'bad-sort' for 'sort'.",
str(message))
@decorators.attr(type=['negative'])
@decorators.idempotent_id('588517ed-bfcf-4d92-9d7c-5ed11fc2c2ee')
def test_receiver_list_invalid_marker(self):
ex = self.assertRaises(exceptions.BadRequest,
self.client.list_objs,
'receivers', {'marker': 'bad-marker'})
message = ex.resp_body['error']['message']
self.assertEqual(
"The value for marker is not a valid UUID: 'bad-marker'.",
str(message))