Merge "Adds standardised error messages"
This commit is contained in:
commit
66b435134d
|
@ -57,9 +57,39 @@ class ParsableErrorMiddleware(object):
|
||||||
return start_response(status, headers, exc_info)
|
return start_response(status, headers, exc_info)
|
||||||
|
|
||||||
app_iter = self.app(environ, replacement_start_response)
|
app_iter = self.app(environ, replacement_start_response)
|
||||||
|
|
||||||
if (state['status_code'] // 100) not in (2, 3):
|
if (state['status_code'] // 100) not in (2, 3):
|
||||||
body = [six.b(json.dumps({'error_message':
|
errs = []
|
||||||
six.b('\n').join(app_iter).decode('utf-8')}))]
|
for err_str in app_iter:
|
||||||
|
err = {}
|
||||||
|
try:
|
||||||
|
err = json.loads(err_str.decode('utf-8'))
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if 'title' in err and 'description' in err:
|
||||||
|
title = err['title']
|
||||||
|
desc = err['description']
|
||||||
|
elif 'faultstring' in err:
|
||||||
|
title = err['faultstring'].split('.', 1)[0]
|
||||||
|
desc = err['faultstring']
|
||||||
|
else:
|
||||||
|
title = ''
|
||||||
|
desc = ''
|
||||||
|
|
||||||
|
code = err['faultcode'].lower() if 'faultcode' in err else ''
|
||||||
|
|
||||||
|
errs.append({
|
||||||
|
'request_id': '',
|
||||||
|
'code': code,
|
||||||
|
'status': state['status_code'],
|
||||||
|
'title': title,
|
||||||
|
'detail': desc,
|
||||||
|
'links': []
|
||||||
|
})
|
||||||
|
|
||||||
|
body = [six.b(json.dumps({'errors': errs}))]
|
||||||
|
|
||||||
state['headers'].append(('Content-Type', 'application/json'))
|
state['headers'].append(('Content-Type', 'application/json'))
|
||||||
state['headers'].append(('Content-Length', str(len(body[0]))))
|
state['headers'].append(('Content-Length', str(len(body[0]))))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
@ -89,7 +88,7 @@ class TestListBay(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_get_one_by_name_multiple_bay(self):
|
def test_get_one_by_name_multiple_bay(self):
|
||||||
obj_utils.create_test_bay(self.context, name='test_bay',
|
obj_utils.create_test_bay(self.context, name='test_bay',
|
||||||
|
@ -99,7 +98,7 @@ class TestListBay(api_base.FunctionalTest):
|
||||||
response = self.get_json('/bays/test_bay', expect_errors=True)
|
response = self.get_json('/bays/test_bay', expect_errors=True)
|
||||||
self.assertEqual(409, response.status_int)
|
self.assertEqual(409, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_get_all_with_pagination_marker(self):
|
def test_get_all_with_pagination_marker(self):
|
||||||
bay_list = []
|
bay_list = []
|
||||||
|
@ -266,7 +265,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_code)
|
self.assertEqual(400, response.status_code)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch('oslo_utils.timeutils.utcnow')
|
@mock.patch('oslo_utils.timeutils.utcnow')
|
||||||
def test_replace_ok_by_name_multiple_bay(self, mock_utcnow):
|
def test_replace_ok_by_name_multiple_bay(self, mock_utcnow):
|
||||||
|
@ -293,7 +292,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_code)
|
self.assertEqual(400, response.status_code)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_replace_invalid_node_count(self):
|
def test_replace_invalid_node_count(self):
|
||||||
response = self.patch_json('/bays/%s' % self.bay.uuid,
|
response = self.patch_json('/bays/%s' % self.bay.uuid,
|
||||||
|
@ -302,7 +301,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_code)
|
self.assertEqual(400, response.status_code)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_replace_non_existent_bay(self):
|
def test_replace_non_existent_bay(self):
|
||||||
response = self.patch_json('/bays/%s' % utils.generate_uuid(),
|
response = self.patch_json('/bays/%s' % utils.generate_uuid(),
|
||||||
|
@ -312,7 +311,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_replace_bay_name_failed(self):
|
def test_replace_bay_name_failed(self):
|
||||||
response = self.patch_json('/bays/%s' % self.bay.uuid,
|
response = self.patch_json('/bays/%s' % self.bay.uuid,
|
||||||
|
@ -322,7 +321,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_add_non_existent_property(self):
|
def test_add_non_existent_property(self):
|
||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
|
@ -331,7 +330,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_remove_ok(self):
|
def test_remove_ok(self):
|
||||||
response = self.get_json('/bays/%s' % self.bay.uuid)
|
response = self.get_json('/bays/%s' % self.bay.uuid)
|
||||||
|
@ -357,7 +356,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_remove_baymodel_id(self):
|
def test_remove_baymodel_id(self):
|
||||||
response = self.patch_json('/bays/%s' % self.bay.uuid,
|
response = self.patch_json('/bays/%s' % self.bay.uuid,
|
||||||
|
@ -365,7 +364,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_remove_non_existent_property(self):
|
def test_remove_non_existent_property(self):
|
||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
|
@ -374,7 +373,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_code)
|
self.assertEqual(400, response.status_code)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
|
|
||||||
class TestPost(api_base.FunctionalTest):
|
class TestPost(api_base.FunctionalTest):
|
||||||
|
@ -460,7 +459,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/bays', bdict, expect_errors=True)
|
response = self.post_json('/bays', bdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_bay_with_baymodel_name(self):
|
def test_create_bay_with_baymodel_name(self):
|
||||||
bdict = apiutils.bay_post_data(baymodel_id=self.baymodel.name)
|
bdict = apiutils.bay_post_data(baymodel_id=self.baymodel.name)
|
||||||
|
@ -474,7 +473,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/bays', bdict, expect_errors=True)
|
response = self.post_json('/bays', bdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_bay_with_node_count_negative(self):
|
def test_create_bay_with_node_count_negative(self):
|
||||||
bdict = apiutils.bay_post_data()
|
bdict = apiutils.bay_post_data()
|
||||||
|
@ -482,7 +481,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/bays', bdict, expect_errors=True)
|
response = self.post_json('/bays', bdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_bay_with_no_node_count(self):
|
def test_create_bay_with_no_node_count(self):
|
||||||
bdict = apiutils.bay_post_data()
|
bdict = apiutils.bay_post_data()
|
||||||
|
@ -498,7 +497,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/bays', bdict, expect_errors=True)
|
response = self.post_json('/bays', bdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_bay_with_no_master_count(self):
|
def test_create_bay_with_no_master_count(self):
|
||||||
bdict = apiutils.bay_post_data()
|
bdict = apiutils.bay_post_data()
|
||||||
|
@ -513,14 +512,14 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/bays', bdict, expect_errors=True)
|
response = self.post_json('/bays', bdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_bay_with_invalid_empty_name(self):
|
def test_create_bay_with_invalid_empty_name(self):
|
||||||
bdict = apiutils.bay_post_data(name='')
|
bdict = apiutils.bay_post_data(name='')
|
||||||
response = self.post_json('/bays', bdict, expect_errors=True)
|
response = self.post_json('/bays', bdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_bay_without_name(self):
|
def test_create_bay_without_name(self):
|
||||||
bdict = apiutils.bay_post_data()
|
bdict = apiutils.bay_post_data()
|
||||||
|
@ -554,7 +553,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/bays', bdict, expect_errors=True)
|
response = self.post_json('/bays', bdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_bay_with_timeout_zero(self):
|
def test_create_bay_with_timeout_zero(self):
|
||||||
bdict = apiutils.bay_post_data()
|
bdict = apiutils.bay_post_data()
|
||||||
|
@ -638,14 +637,14 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_delete_bay_not_found(self):
|
def test_delete_bay_not_found(self):
|
||||||
uuid = utils.generate_uuid()
|
uuid = utils.generate_uuid()
|
||||||
response = self.delete('/bays/%s' % uuid, expect_errors=True)
|
response = self.delete('/bays/%s' % uuid, expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_delete_bay_with_pods(self):
|
def test_delete_bay_with_pods(self):
|
||||||
obj_utils.create_test_pod(self.context, bay_uuid=self.bay.uuid)
|
obj_utils.create_test_pod(self.context, bay_uuid=self.bay.uuid)
|
||||||
|
@ -669,7 +668,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
response = self.delete('/bays/not_found', expect_errors=True)
|
response = self.delete('/bays/not_found', expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_delete_bay_with_name(self):
|
def test_delete_bay_with_name(self):
|
||||||
response = self.delete('/bays/%s' % self.bay.name,
|
response = self.delete('/bays/%s' % self.bay.name,
|
||||||
|
@ -684,7 +683,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
response = self.delete('/bays/test_bay', expect_errors=True)
|
response = self.delete('/bays/test_bay', expect_errors=True)
|
||||||
self.assertEqual(409, response.status_int)
|
self.assertEqual(409, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
|
|
||||||
class TestBayPolicyEnforcement(api_base.FunctionalTest):
|
class TestBayPolicyEnforcement(api_base.FunctionalTest):
|
||||||
|
@ -700,7 +699,7 @@ class TestBayPolicyEnforcement(api_base.FunctionalTest):
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
"Policy doesn't allow %s to be performed." % rule,
|
"Policy doesn't allow %s to be performed." % rule,
|
||||||
json.loads(response.json['error_message'])['faultstring'])
|
response.json['errors'][0]['detail'])
|
||||||
|
|
||||||
def test_policy_disallow_get_all(self):
|
def test_policy_disallow_get_all(self):
|
||||||
self._common_policy_check(
|
self._common_policy_check(
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
@ -89,7 +88,7 @@ class TestListBayModel(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_get_one_by_name_multiple_baymodel(self):
|
def test_get_one_by_name_multiple_baymodel(self):
|
||||||
obj_utils.create_test_baymodel(
|
obj_utils.create_test_baymodel(
|
||||||
|
@ -103,7 +102,7 @@ class TestListBayModel(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(409, response.status_int)
|
self.assertEqual(409, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_get_all_with_pagination_marker(self):
|
def test_get_all_with_pagination_marker(self):
|
||||||
bm_list = []
|
bm_list = []
|
||||||
|
@ -217,7 +216,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_update_baymodel_with_bay(self):
|
def test_update_baymodel_with_bay(self):
|
||||||
baymodel = obj_utils.create_test_baymodel(self.context)
|
baymodel = obj_utils.create_test_baymodel(self.context)
|
||||||
|
@ -230,8 +229,8 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
self.assertIn(baymodel.uuid, response.json['error_message'])
|
self.assertIn(baymodel.uuid, response.json['errors'][0]['detail'])
|
||||||
|
|
||||||
@mock.patch.object(magnum_policy, 'enforce')
|
@mock.patch.object(magnum_policy, 'enforce')
|
||||||
def test_update_public_baymodel_success(self, mock_policy):
|
def test_update_public_baymodel_success(self, mock_policy):
|
||||||
|
@ -334,7 +333,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_code)
|
self.assertEqual(400, response.status_code)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_remove_mandatory_property_fail(self):
|
def test_remove_mandatory_property_fail(self):
|
||||||
mandatory_properties = ('/image_id', '/keypair_id',
|
mandatory_properties = ('/image_id', '/keypair_id',
|
||||||
|
@ -348,7 +347,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_code)
|
self.assertEqual(400, response.status_code)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_add_root_non_existent(self):
|
def test_add_root_non_existent(self):
|
||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
|
@ -357,7 +356,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_remove_uuid(self):
|
def test_remove_uuid(self):
|
||||||
response = self.patch_json('/baymodels/%s' % self.baymodel.uuid,
|
response = self.patch_json('/baymodels/%s' % self.baymodel.uuid,
|
||||||
|
@ -365,7 +364,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
|
|
||||||
class TestPost(api_base.FunctionalTest):
|
class TestPost(api_base.FunctionalTest):
|
||||||
|
@ -746,7 +745,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_delete_baymodel_with_bay(self):
|
def test_delete_baymodel_with_bay(self):
|
||||||
baymodel = obj_utils.create_test_baymodel(self.context)
|
baymodel = obj_utils.create_test_baymodel(self.context)
|
||||||
|
@ -755,15 +754,15 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
self.assertIn(baymodel.uuid, response.json['error_message'])
|
self.assertIn(baymodel.uuid, response.json['errors'][0]['detail'])
|
||||||
|
|
||||||
def test_delete_baymodel_not_found(self):
|
def test_delete_baymodel_not_found(self):
|
||||||
uuid = utils.generate_uuid()
|
uuid = utils.generate_uuid()
|
||||||
response = self.delete('/baymodels/%s' % uuid, expect_errors=True)
|
response = self.delete('/baymodels/%s' % uuid, expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_delete_baymodel_with_name(self):
|
def test_delete_baymodel_with_name(self):
|
||||||
baymodel = obj_utils.create_test_baymodel(self.context)
|
baymodel = obj_utils.create_test_baymodel(self.context)
|
||||||
|
@ -775,7 +774,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
response = self.delete('/baymodels/not_found', expect_errors=True)
|
response = self.delete('/baymodels/not_found', expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_delete_multiple_baymodel_by_name(self):
|
def test_delete_multiple_baymodel_by_name(self):
|
||||||
obj_utils.create_test_baymodel(self.context, name='test_baymodel',
|
obj_utils.create_test_baymodel(self.context, name='test_baymodel',
|
||||||
|
@ -785,7 +784,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
response = self.delete('/baymodels/test_baymodel', expect_errors=True)
|
response = self.delete('/baymodels/test_baymodel', expect_errors=True)
|
||||||
self.assertEqual(409, response.status_int)
|
self.assertEqual(409, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
|
|
||||||
class TestBayModelPolicyEnforcement(api_base.FunctionalTest):
|
class TestBayModelPolicyEnforcement(api_base.FunctionalTest):
|
||||||
|
@ -797,7 +796,7 @@ class TestBayModelPolicyEnforcement(api_base.FunctionalTest):
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
"Policy doesn't allow %s to be performed." % rule,
|
"Policy doesn't allow %s to be performed." % rule,
|
||||||
json.loads(response.json['error_message'])['faultstring'])
|
response.json['errors'][0]['detail'])
|
||||||
|
|
||||||
def test_policy_disallow_get_all(self):
|
def test_policy_disallow_get_all(self):
|
||||||
self._common_policy_check(
|
self._common_policy_check(
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from magnum.api.controllers.v1 import certificate as api_cert
|
from magnum.api.controllers.v1 import certificate as api_cert
|
||||||
|
@ -79,7 +78,7 @@ class TestGetCertificate(api_base.FunctionalTest):
|
||||||
|
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_get_one_by_name_multiple_bay(self):
|
def test_get_one_by_name_multiple_bay(self):
|
||||||
obj_utils.create_test_bay(self.context, name='test_bay',
|
obj_utils.create_test_bay(self.context, name='test_bay',
|
||||||
|
@ -92,7 +91,7 @@ class TestGetCertificate(api_base.FunctionalTest):
|
||||||
|
|
||||||
self.assertEqual(409, response.status_int)
|
self.assertEqual(409, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_links(self):
|
def test_links(self):
|
||||||
fake_cert = apiutils.cert_post_data()
|
fake_cert = apiutils.cert_post_data()
|
||||||
|
@ -159,7 +158,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
|
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
|
|
||||||
class TestCertPolicyEnforcement(api_base.FunctionalTest):
|
class TestCertPolicyEnforcement(api_base.FunctionalTest):
|
||||||
|
@ -174,7 +173,7 @@ class TestCertPolicyEnforcement(api_base.FunctionalTest):
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
"Policy doesn't allow %s to be performed." % rule,
|
"Policy doesn't allow %s to be performed." % rule,
|
||||||
json.loads(response.json['error_message'])['faultstring'])
|
response.json['errors'][0]['detail'])
|
||||||
|
|
||||||
def test_policy_disallow_get_one(self):
|
def test_policy_disallow_get_one(self):
|
||||||
self._common_policy_check(
|
self._common_policy_check(
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
import mock
|
import mock
|
||||||
from mock import patch
|
from mock import patch
|
||||||
from webtest.app import AppError
|
from webtest.app import AppError
|
||||||
|
@ -641,7 +640,7 @@ class TestContainerEnforcement(api_base.FunctionalTest):
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
"Policy doesn't allow %s to be performed." % rule,
|
"Policy doesn't allow %s to be performed." % rule,
|
||||||
json.loads(response.json['error_message'])['faultstring'])
|
response.json['errors'][0]['detail'])
|
||||||
|
|
||||||
def test_policy_disallow_get_all(self):
|
def test_policy_disallow_get_all(self):
|
||||||
self._common_policy_check(
|
self._common_policy_check(
|
||||||
|
|
|
@ -10,9 +10,6 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from magnum.api.controllers.v1 import magnum_services as mservice
|
from magnum.api.controllers.v1 import magnum_services as mservice
|
||||||
|
@ -96,7 +93,7 @@ class TestMagnumServiceEnforcement(api_base.FunctionalTest):
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
"Policy doesn't allow %s to be performed." % rule,
|
"Policy doesn't allow %s to be performed." % rule,
|
||||||
json.loads(response.json['error_message'])['faultstring'])
|
response.json['errors'][0]['detail'])
|
||||||
|
|
||||||
def test_policy_disallow_get_all(self):
|
def test_policy_disallow_get_all(self):
|
||||||
self._common_policy_check(
|
self._common_policy_check(
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
@ -93,7 +92,7 @@ class TestListPod(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'pod_show')
|
@mock.patch.object(rpcapi.API, 'pod_show')
|
||||||
def test_get_one_by_name_multiple_pod(self, mock_pod_show):
|
def test_get_one_by_name_multiple_pod(self, mock_pod_show):
|
||||||
|
@ -108,7 +107,7 @@ class TestListPod(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'pod_list')
|
@mock.patch.object(rpcapi.API, 'pod_list')
|
||||||
def test_get_all_with_pagination_marker(self, mock_pod_list):
|
def test_get_all_with_pagination_marker(self, mock_pod_list):
|
||||||
|
@ -236,7 +235,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_code)
|
self.assertEqual(400, response.status_code)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_replace_internal_field(self):
|
def test_replace_internal_field(self):
|
||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
|
@ -245,7 +244,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_code)
|
self.assertEqual(400, response.status_code)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_replace_non_existent_pod(self):
|
def test_replace_non_existent_pod(self):
|
||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
|
@ -256,7 +255,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'pod_update')
|
@mock.patch.object(rpcapi.API, 'pod_update')
|
||||||
@mock.patch.object(api_pod.Pod, 'parse_manifest')
|
@mock.patch.object(api_pod.Pod, 'parse_manifest')
|
||||||
|
@ -280,7 +279,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'pod_update')
|
@mock.patch.object(rpcapi.API, 'pod_update')
|
||||||
@mock.patch.object(rpcapi.API, 'pod_show')
|
@mock.patch.object(rpcapi.API, 'pod_show')
|
||||||
|
@ -311,7 +310,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_remove_bay_uuid(self):
|
def test_remove_bay_uuid(self):
|
||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
|
@ -320,7 +319,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_remove_internal_field(self):
|
def test_remove_internal_field(self):
|
||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
|
@ -329,7 +328,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_remove_non_existent_property(self):
|
def test_remove_non_existent_property(self):
|
||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
|
@ -338,7 +337,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_code)
|
self.assertEqual(400, response.status_code)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'pod_show')
|
@mock.patch.object(rpcapi.API, 'pod_show')
|
||||||
@mock.patch.object(rpcapi.API, 'pod_update')
|
@mock.patch.object(rpcapi.API, 'pod_update')
|
||||||
|
@ -475,7 +474,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/pods', pdict, expect_errors=True)
|
response = self.post_json('/pods', pdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_pod_with_invalid_manifest(self):
|
def test_create_pod_with_invalid_manifest(self):
|
||||||
pdict = apiutils.pod_post_data()
|
pdict = apiutils.pod_post_data()
|
||||||
|
@ -483,7 +482,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/pods', pdict, expect_errors=True)
|
response = self.post_json('/pods', pdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_pod_no_manifest(self):
|
def test_create_pod_no_manifest(self):
|
||||||
pdict = apiutils.pod_post_data()
|
pdict = apiutils.pod_post_data()
|
||||||
|
@ -491,7 +490,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/pods', pdict, expect_errors=True)
|
response = self.post_json('/pods', pdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_pod_no_id_in_manifest(self):
|
def test_create_pod_no_id_in_manifest(self):
|
||||||
pdict = apiutils.pod_post_data()
|
pdict = apiutils.pod_post_data()
|
||||||
|
@ -499,7 +498,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/pods', pdict, expect_errors=True)
|
response = self.post_json('/pods', pdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
|
|
||||||
class TestDelete(api_base.FunctionalTest):
|
class TestDelete(api_base.FunctionalTest):
|
||||||
|
@ -520,7 +519,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'pod_delete')
|
@mock.patch.object(rpcapi.API, 'pod_delete')
|
||||||
@mock.patch.object(rpcapi.API, 'pod_show')
|
@mock.patch.object(rpcapi.API, 'pod_show')
|
||||||
|
@ -534,7 +533,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'pod_delete')
|
@mock.patch.object(rpcapi.API, 'pod_delete')
|
||||||
def test_delete_pod_by_name_not_found(self, mock_pod_delete):
|
def test_delete_pod_by_name_not_found(self, mock_pod_delete):
|
||||||
|
@ -545,7 +544,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'pod_delete')
|
@mock.patch.object(rpcapi.API, 'pod_delete')
|
||||||
def test_delete_multiple_pod_by_name(self, mock_pod_delete):
|
def test_delete_multiple_pod_by_name(self, mock_pod_delete):
|
||||||
|
@ -558,7 +557,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
response = self.delete('/pods/test_pod', expect_errors=True)
|
response = self.delete('/pods/test_pod', expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'pod_delete')
|
@mock.patch.object(rpcapi.API, 'pod_delete')
|
||||||
def test_delete_pod_not_found(self, mock_pod_delete):
|
def test_delete_pod_not_found(self, mock_pod_delete):
|
||||||
|
@ -569,7 +568,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
|
|
||||||
class TestPodPolicyEnforcement(api_base.FunctionalTest):
|
class TestPodPolicyEnforcement(api_base.FunctionalTest):
|
||||||
|
@ -581,7 +580,7 @@ class TestPodPolicyEnforcement(api_base.FunctionalTest):
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
"Policy doesn't allow %s to be performed." % rule,
|
"Policy doesn't allow %s to be performed." % rule,
|
||||||
json.loads(response.json['error_message'])['faultstring'])
|
response.json['errors'][0]['detail'])
|
||||||
|
|
||||||
def test_policy_disallow_get_all(self):
|
def test_policy_disallow_get_all(self):
|
||||||
self._common_policy_check(
|
self._common_policy_check(
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
@ -82,7 +81,7 @@ class TestListRC(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'rc_show')
|
@mock.patch.object(rpcapi.API, 'rc_show')
|
||||||
def test_get_one_by_name_multiple_rc(self, mock_rc_show):
|
def test_get_one_by_name_multiple_rc(self, mock_rc_show):
|
||||||
|
@ -99,7 +98,7 @@ class TestListRC(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'rc_list')
|
@mock.patch.object(rpcapi.API, 'rc_list')
|
||||||
def test_get_all_with_pagination_marker(self, mock_rc_list):
|
def test_get_all_with_pagination_marker(self, mock_rc_list):
|
||||||
|
@ -257,7 +256,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_code)
|
self.assertEqual(400, response.status_code)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_replace_internal_field(self):
|
def test_replace_internal_field(self):
|
||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
|
@ -266,7 +265,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_code)
|
self.assertEqual(400, response.status_code)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_replace_non_existent_rc(self):
|
def test_replace_non_existent_rc(self):
|
||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
|
@ -278,7 +277,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'rc_update')
|
@mock.patch.object(rpcapi.API, 'rc_update')
|
||||||
@mock.patch.object(api_rc.ReplicationController, 'parse_manifest')
|
@mock.patch.object(api_rc.ReplicationController, 'parse_manifest')
|
||||||
|
@ -301,7 +300,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'rc_update')
|
@mock.patch.object(rpcapi.API, 'rc_update')
|
||||||
@mock.patch.object(rpcapi.API, 'rc_show')
|
@mock.patch.object(rpcapi.API, 'rc_show')
|
||||||
|
@ -331,7 +330,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_remove_bay_uuid(self):
|
def test_remove_bay_uuid(self):
|
||||||
response = self.patch_json('/rcs/%s/%s' % (self.rc.uuid,
|
response = self.patch_json('/rcs/%s/%s' % (self.rc.uuid,
|
||||||
|
@ -340,7 +339,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_remove_internal_field(self):
|
def test_remove_internal_field(self):
|
||||||
response = self.patch_json('/rcs/%s/%s' % (self.rc.uuid,
|
response = self.patch_json('/rcs/%s/%s' % (self.rc.uuid,
|
||||||
|
@ -349,7 +348,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_remove_non_existent_property(self):
|
def test_remove_non_existent_property(self):
|
||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
|
@ -358,7 +357,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_code)
|
self.assertEqual(400, response.status_code)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'rc_show')
|
@mock.patch.object(rpcapi.API, 'rc_show')
|
||||||
@mock.patch.object(rpcapi.API, 'rc_update')
|
@mock.patch.object(rpcapi.API, 'rc_update')
|
||||||
|
@ -491,7 +490,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/rcs', rc_dict, expect_errors=True)
|
response = self.post_json('/rcs', rc_dict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_rc_with_invalid_manifest(self):
|
def test_create_rc_with_invalid_manifest(self):
|
||||||
rc_dict = apiutils.rc_post_data()
|
rc_dict = apiutils.rc_post_data()
|
||||||
|
@ -499,7 +498,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/rcs', rc_dict, expect_errors=True)
|
response = self.post_json('/rcs', rc_dict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_rc_no_manifest(self):
|
def test_create_rc_no_manifest(self):
|
||||||
rc_dict = apiutils.rc_post_data()
|
rc_dict = apiutils.rc_post_data()
|
||||||
|
@ -507,7 +506,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/rcs', rc_dict, expect_errors=True)
|
response = self.post_json('/rcs', rc_dict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_rc_no_id_in_manifest(self):
|
def test_create_rc_no_id_in_manifest(self):
|
||||||
rc_dict = apiutils.rc_post_data()
|
rc_dict = apiutils.rc_post_data()
|
||||||
|
@ -515,7 +514,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/rcs', rc_dict, expect_errors=True)
|
response = self.post_json('/rcs', rc_dict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
|
|
||||||
class TestDelete(api_base.FunctionalTest):
|
class TestDelete(api_base.FunctionalTest):
|
||||||
|
@ -536,7 +535,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'rc_delete')
|
@mock.patch.object(rpcapi.API, 'rc_delete')
|
||||||
def test_delete_rc_not_found(self, mock_rc_delete):
|
def test_delete_rc_not_found(self, mock_rc_delete):
|
||||||
|
@ -547,7 +546,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'rc_delete')
|
@mock.patch.object(rpcapi.API, 'rc_delete')
|
||||||
def test_delete_rc_with_name_not_found(self, mock_rc_delete):
|
def test_delete_rc_with_name_not_found(self, mock_rc_delete):
|
||||||
|
@ -558,7 +557,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'rc_delete')
|
@mock.patch.object(rpcapi.API, 'rc_delete')
|
||||||
def test_delete_rc_with_name(self, mock_rc_delete):
|
def test_delete_rc_with_name(self, mock_rc_delete):
|
||||||
|
@ -579,7 +578,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
|
|
||||||
class TestRCEnforcement(api_base.FunctionalTest):
|
class TestRCEnforcement(api_base.FunctionalTest):
|
||||||
|
@ -591,7 +590,7 @@ class TestRCEnforcement(api_base.FunctionalTest):
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
"Policy doesn't allow %s to be performed." % rule,
|
"Policy doesn't allow %s to be performed." % rule,
|
||||||
json.loads(response.json['error_message'])['faultstring'])
|
response.json['errors'][0]['detail'])
|
||||||
|
|
||||||
def test_policy_disallow_get_all(self):
|
def test_policy_disallow_get_all(self):
|
||||||
self._common_policy_check(
|
self._common_policy_check(
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
@ -93,7 +92,7 @@ class TestListService(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'service_show')
|
@mock.patch.object(rpcapi.API, 'service_show')
|
||||||
def test_get_one_by_name_multiple_service(self, mock_service_show):
|
def test_get_one_by_name_multiple_service(self, mock_service_show):
|
||||||
|
@ -110,7 +109,7 @@ class TestListService(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'service_list')
|
@mock.patch.object(rpcapi.API, 'service_list')
|
||||||
def test_get_all_with_pagination_marker(self, mock_service_list):
|
def test_get_all_with_pagination_marker(self, mock_service_list):
|
||||||
|
@ -251,7 +250,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_code)
|
self.assertEqual(400, response.status_code)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'service_update')
|
@mock.patch.object(rpcapi.API, 'service_update')
|
||||||
def test_replace_internal_field(self, mock_service_update):
|
def test_replace_internal_field(self, mock_service_update):
|
||||||
|
@ -263,7 +262,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_code)
|
self.assertEqual(400, response.status_code)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'service_update')
|
@mock.patch.object(rpcapi.API, 'service_update')
|
||||||
def test_replace_non_existent_service(self, mock_service_update):
|
def test_replace_non_existent_service(self, mock_service_update):
|
||||||
|
@ -278,7 +277,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'service_update')
|
@mock.patch.object(rpcapi.API, 'service_update')
|
||||||
@mock.patch.object(api_service.Service, 'parse_manifest')
|
@mock.patch.object(api_service.Service, 'parse_manifest')
|
||||||
|
@ -303,7 +302,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_remove_uuid(self):
|
def test_remove_uuid(self):
|
||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
|
@ -312,7 +311,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_remove_bay_uuid(self):
|
def test_remove_bay_uuid(self):
|
||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
|
@ -321,7 +320,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_remove_internal_field(self):
|
def test_remove_internal_field(self):
|
||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
|
@ -330,7 +329,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_remove_non_existent_property(self):
|
def test_remove_non_existent_property(self):
|
||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
|
@ -339,7 +338,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(400, response.status_code)
|
self.assertEqual(400, response.status_code)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'service_show')
|
@mock.patch.object(rpcapi.API, 'service_show')
|
||||||
@mock.patch.object(rpcapi.API, 'service_update')
|
@mock.patch.object(rpcapi.API, 'service_update')
|
||||||
|
@ -487,7 +486,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/services', sdict, expect_errors=True)
|
response = self.post_json('/services', sdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_service_no_manifest(self):
|
def test_create_service_no_manifest(self):
|
||||||
sdict = apiutils.service_post_data()
|
sdict = apiutils.service_post_data()
|
||||||
|
@ -495,7 +494,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/services', sdict, expect_errors=True)
|
response = self.post_json('/services', sdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_service_invalid_manifest(self):
|
def test_create_service_invalid_manifest(self):
|
||||||
sdict = apiutils.service_post_data()
|
sdict = apiutils.service_post_data()
|
||||||
|
@ -503,7 +502,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/services', sdict, expect_errors=True)
|
response = self.post_json('/services', sdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_service_no_id_in_manifest(self):
|
def test_create_service_no_id_in_manifest(self):
|
||||||
sdict = apiutils.service_post_data()
|
sdict = apiutils.service_post_data()
|
||||||
|
@ -511,7 +510,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/services', sdict, expect_errors=True)
|
response = self.post_json('/services', sdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
|
|
||||||
class TestDelete(api_base.FunctionalTest):
|
class TestDelete(api_base.FunctionalTest):
|
||||||
|
@ -535,7 +534,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'service_delete')
|
@mock.patch.object(rpcapi.API, 'service_delete')
|
||||||
@mock.patch.object(rpcapi.API, 'service_show')
|
@mock.patch.object(rpcapi.API, 'service_show')
|
||||||
|
@ -549,7 +548,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'service_delete')
|
@mock.patch.object(rpcapi.API, 'service_delete')
|
||||||
@mock.patch.object(rpcapi.API, 'service_show')
|
@mock.patch.object(rpcapi.API, 'service_show')
|
||||||
|
@ -576,7 +575,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
@mock.patch.object(rpcapi.API, 'service_delete')
|
@mock.patch.object(rpcapi.API, 'service_delete')
|
||||||
def test_delete_multiple_service_by_name(self, mock_service_delete):
|
def test_delete_multiple_service_by_name(self, mock_service_delete):
|
||||||
|
@ -591,7 +590,7 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(500, response.status_int)
|
self.assertEqual(500, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
|
|
||||||
class TestServiceEnforcement(api_base.FunctionalTest):
|
class TestServiceEnforcement(api_base.FunctionalTest):
|
||||||
|
@ -603,7 +602,7 @@ class TestServiceEnforcement(api_base.FunctionalTest):
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
"Policy doesn't allow %s to be performed." % rule,
|
"Policy doesn't allow %s to be performed." % rule,
|
||||||
json.loads(response.json['error_message'])['faultstring'])
|
response.json['errors'][0]['detail'])
|
||||||
|
|
||||||
def test_policy_disallow_get_all(self):
|
def test_policy_disallow_get_all(self):
|
||||||
self._common_policy_check(
|
self._common_policy_check(
|
||||||
|
|
|
@ -96,7 +96,6 @@ class TestJsonPatchType(base.FunctionalTest):
|
||||||
patch = [{'path': '/internal', 'op': 'replace', 'value': 'foo'}]
|
patch = [{'path': '/internal', 'op': 'replace', 'value': 'foo'}]
|
||||||
ret = self._patch_json(patch, True)
|
ret = self._patch_json(patch, True)
|
||||||
self.assertEqual(400, ret.status_int)
|
self.assertEqual(400, ret.status_int)
|
||||||
self.assertTrue(ret.json['faultstring'])
|
|
||||||
|
|
||||||
def test_mandatory_attr(self):
|
def test_mandatory_attr(self):
|
||||||
patch = [{'op': 'replace', 'path': '/mandatory', 'value': 'foo'}]
|
patch = [{'op': 'replace', 'path': '/mandatory', 'value': 'foo'}]
|
||||||
|
@ -108,43 +107,36 @@ class TestJsonPatchType(base.FunctionalTest):
|
||||||
patch = [{'op': 'remove', 'path': '/mandatory'}]
|
patch = [{'op': 'remove', 'path': '/mandatory'}]
|
||||||
ret = self._patch_json(patch, True)
|
ret = self._patch_json(patch, True)
|
||||||
self.assertEqual(400, ret.status_int)
|
self.assertEqual(400, ret.status_int)
|
||||||
self.assertTrue(ret.json['faultstring'])
|
|
||||||
|
|
||||||
def test_missing_required_fields_path(self):
|
def test_missing_required_fields_path(self):
|
||||||
missing_path = [{'op': 'remove'}]
|
missing_path = [{'op': 'remove'}]
|
||||||
ret = self._patch_json(missing_path, True)
|
ret = self._patch_json(missing_path, True)
|
||||||
self.assertEqual(400, ret.status_int)
|
self.assertEqual(400, ret.status_int)
|
||||||
self.assertTrue(ret.json['faultstring'])
|
|
||||||
|
|
||||||
def test_missing_required_fields_op(self):
|
def test_missing_required_fields_op(self):
|
||||||
missing_op = [{'path': '/foo'}]
|
missing_op = [{'path': '/foo'}]
|
||||||
ret = self._patch_json(missing_op, True)
|
ret = self._patch_json(missing_op, True)
|
||||||
self.assertEqual(400, ret.status_int)
|
self.assertEqual(400, ret.status_int)
|
||||||
self.assertTrue(ret.json['faultstring'])
|
|
||||||
|
|
||||||
def test_invalid_op(self):
|
def test_invalid_op(self):
|
||||||
patch = [{'path': '/foo', 'op': 'invalid'}]
|
patch = [{'path': '/foo', 'op': 'invalid'}]
|
||||||
ret = self._patch_json(patch, True)
|
ret = self._patch_json(patch, True)
|
||||||
self.assertEqual(400, ret.status_int)
|
self.assertEqual(400, ret.status_int)
|
||||||
self.assertTrue(ret.json['faultstring'])
|
|
||||||
|
|
||||||
def test_invalid_path(self):
|
def test_invalid_path(self):
|
||||||
patch = [{'path': 'invalid-path', 'op': 'remove'}]
|
patch = [{'path': 'invalid-path', 'op': 'remove'}]
|
||||||
ret = self._patch_json(patch, True)
|
ret = self._patch_json(patch, True)
|
||||||
self.assertEqual(400, ret.status_int)
|
self.assertEqual(400, ret.status_int)
|
||||||
self.assertTrue(ret.json['faultstring'])
|
|
||||||
|
|
||||||
def test_cannot_add_with_no_value(self):
|
def test_cannot_add_with_no_value(self):
|
||||||
patch = [{'path': '/extra/foo', 'op': 'add'}]
|
patch = [{'path': '/extra/foo', 'op': 'add'}]
|
||||||
ret = self._patch_json(patch, True)
|
ret = self._patch_json(patch, True)
|
||||||
self.assertEqual(400, ret.status_int)
|
self.assertEqual(400, ret.status_int)
|
||||||
self.assertTrue(ret.json['faultstring'])
|
|
||||||
|
|
||||||
def test_cannot_replace_with_no_value(self):
|
def test_cannot_replace_with_no_value(self):
|
||||||
patch = [{'path': '/foo', 'op': 'replace'}]
|
patch = [{'path': '/foo', 'op': 'replace'}]
|
||||||
ret = self._patch_json(patch, True)
|
ret = self._patch_json(patch, True)
|
||||||
self.assertEqual(400, ret.status_int)
|
self.assertEqual(400, ret.status_int)
|
||||||
self.assertTrue(ret.json['faultstring'])
|
|
||||||
|
|
||||||
|
|
||||||
class TestMultiType(base.FunctionalTest):
|
class TestMultiType(base.FunctionalTest):
|
||||||
|
|
|
@ -80,7 +80,7 @@ class TestListX509KeyPair(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_get_one_by_name_multiple_x509keypair(self):
|
def test_get_one_by_name_multiple_x509keypair(self):
|
||||||
obj_utils.create_test_x509keypair(self.context,
|
obj_utils.create_test_x509keypair(self.context,
|
||||||
|
@ -93,7 +93,7 @@ class TestListX509KeyPair(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(409, response.status_int)
|
self.assertEqual(409, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_detail(self):
|
def test_detail(self):
|
||||||
x509keypair = obj_utils.create_test_x509keypair(self.context)
|
x509keypair = obj_utils.create_test_x509keypair(self.context)
|
||||||
|
@ -236,7 +236,7 @@ class TestPost(api_base.FunctionalTest):
|
||||||
response = self.post_json('/x509keypairs', cdict, expect_errors=True)
|
response = self.post_json('/x509keypairs', cdict, expect_errors=True)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_create_x509keypair_with_bay_name(self):
|
def test_create_x509keypair_with_bay_name(self):
|
||||||
cdict = apiutils.x509keypair_post_data(bay_uuid=self.bay.name)
|
cdict = apiutils.x509keypair_post_data(bay_uuid=self.bay.name)
|
||||||
|
@ -268,20 +268,20 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_delete_x509keypair_not_found(self):
|
def test_delete_x509keypair_not_found(self):
|
||||||
uuid = utils.generate_uuid()
|
uuid = utils.generate_uuid()
|
||||||
response = self.delete('/x509keypairs/%s' % uuid, expect_errors=True)
|
response = self.delete('/x509keypairs/%s' % uuid, expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_delete_x509keypair_with_name_not_found(self):
|
def test_delete_x509keypair_with_name_not_found(self):
|
||||||
response = self.delete('/x509keypairs/not_found', expect_errors=True)
|
response = self.delete('/x509keypairs/not_found', expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
||||||
def test_delete_x509keypair_with_name(self):
|
def test_delete_x509keypair_with_name(self):
|
||||||
response = self.delete('/x509keypairs/%s' % self.x509keypair.name,
|
response = self.delete('/x509keypairs/%s' % self.x509keypair.name,
|
||||||
|
@ -299,4 +299,4 @@ class TestDelete(api_base.FunctionalTest):
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(409, response.status_int)
|
self.assertEqual(409, response.status_int)
|
||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['errors'])
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
@ -90,7 +89,7 @@ class TestNoExceptionTracebackHook(api_base.FunctionalTest):
|
||||||
|
|
||||||
response = self.get_json('/', path_prefix='', expect_errors=True)
|
response = self.get_json('/', path_prefix='', expect_errors=True)
|
||||||
|
|
||||||
actual_msg = json.loads(response.json['error_message'])['faultstring']
|
actual_msg = response.json['errors'][0]['detail']
|
||||||
self.assertEqual(self.MSG_WITHOUT_TRACE, actual_msg)
|
self.assertEqual(self.MSG_WITHOUT_TRACE, actual_msg)
|
||||||
|
|
||||||
def test_hook_remote_error_success(self):
|
def test_hook_remote_error_success(self):
|
||||||
|
@ -112,7 +111,7 @@ class TestNoExceptionTracebackHook(api_base.FunctionalTest):
|
||||||
else:
|
else:
|
||||||
expected_msg = ("Remote error: %s %s"
|
expected_msg = ("Remote error: %s %s"
|
||||||
% (test_exc_type, self.MSG_WITHOUT_TRACE) + "\n['")
|
% (test_exc_type, self.MSG_WITHOUT_TRACE) + "\n['")
|
||||||
actual_msg = json.loads(response.json['error_message'])['faultstring']
|
actual_msg = response.json['errors'][0]['detail']
|
||||||
self.assertEqual(expected_msg, actual_msg)
|
self.assertEqual(expected_msg, actual_msg)
|
||||||
|
|
||||||
def test_hook_without_traceback(self):
|
def test_hook_without_traceback(self):
|
||||||
|
@ -121,7 +120,7 @@ class TestNoExceptionTracebackHook(api_base.FunctionalTest):
|
||||||
|
|
||||||
response = self.get_json('/', path_prefix='', expect_errors=True)
|
response = self.get_json('/', path_prefix='', expect_errors=True)
|
||||||
|
|
||||||
actual_msg = json.loads(response.json['error_message'])['faultstring']
|
actual_msg = response.json['errors'][0]['detail']
|
||||||
self.assertEqual(msg, actual_msg)
|
self.assertEqual(msg, actual_msg)
|
||||||
|
|
||||||
def test_hook_server_debug_on_serverfault(self):
|
def test_hook_server_debug_on_serverfault(self):
|
||||||
|
@ -130,8 +129,7 @@ class TestNoExceptionTracebackHook(api_base.FunctionalTest):
|
||||||
|
|
||||||
response = self.get_json('/', path_prefix='', expect_errors=True)
|
response = self.get_json('/', path_prefix='', expect_errors=True)
|
||||||
|
|
||||||
actual_msg = json.loads(
|
actual_msg = response.json['errors'][0]['detail']
|
||||||
response.json['error_message'])['faultstring']
|
|
||||||
self.assertEqual(self.MSG_WITHOUT_TRACE, actual_msg)
|
self.assertEqual(self.MSG_WITHOUT_TRACE, actual_msg)
|
||||||
|
|
||||||
def test_hook_server_debug_on_clientfault(self):
|
def test_hook_server_debug_on_clientfault(self):
|
||||||
|
@ -142,6 +140,5 @@ class TestNoExceptionTracebackHook(api_base.FunctionalTest):
|
||||||
|
|
||||||
response = self.get_json('/', path_prefix='', expect_errors=True)
|
response = self.get_json('/', path_prefix='', expect_errors=True)
|
||||||
|
|
||||||
actual_msg = json.loads(
|
actual_msg = response.json['errors'][0]['detail']
|
||||||
response.json['error_message'])['faultstring']
|
|
||||||
self.assertEqual(self.MSG_WITH_TRACE, actual_msg)
|
self.assertEqual(self.MSG_WITH_TRACE, actual_msg)
|
||||||
|
|
Loading…
Reference in New Issue