Allow to PUT an empty object model

It was impossible to delete the last component from the env via
CLI, because it was prohibited to make put request with empty body.

APIImpact
Change-Id: I462072ad7c90eec1790b74cae958809aa316c25c
Closes-bug: #1511645
This commit is contained in:
Valerii Kovalchuk 2016-09-22 14:04:38 +03:00
parent 849b8ea600
commit 57cc16da68
3 changed files with 77 additions and 0 deletions

View File

@ -196,6 +196,19 @@ class ApplicationCatalogClient(rest_client.RestClient):
self.expected_success(200, resp.status)
return self._parse_resp(body)
def update_services(self, environment_id, session_id, put_body=None):
headers = self.get_headers()
headers.update(
{'X-Configuration-Session': session_id}
)
uri = 'v1/environments/{0}/services'.format(environment_id)
resp, body = self.put(uri, json.dumps(put_body), headers)
self.expected_success(200, resp.status)
# TODO(freerunner): Need to replace json.loads() to _parse_resp
# method, when fix for https://bugs.launchpad.net/tempest/+bug/1539927
# will resolved and new version of tempest-lib released.
return json.loads(body)
def delete_service(self, environment_id, session_id, service_id):
headers = self.get_headers()
headers.update(

View File

@ -65,6 +65,44 @@ class TestServices(base.BaseApplicationCatalogTest):
get_services_list(self.environment['id'], session['id'])
self.assertEqual(len(services_list), len(services_list_))
@testtools.testcase.attr('smoke')
def test_update_services_via_put(self):
session = self.application_catalog_client.\
create_session(self.environment['id'])
self.addCleanup(self.application_catalog_client.delete_session,
self.environment['id'], session['id'])
put_body = [self._get_demo_app()]
self.application_catalog_client.\
update_services(self.environment['id'], session['id'], put_body)
services_list = self.application_catalog_client.\
get_services_list(self.environment['id'], session['id'])
self.assertEqual(1, len(services_list))
@testtools.testcase.attr('smoke')
def test_clear_services_via_put(self):
session = self.application_catalog_client.\
create_session(self.environment['id'])
self.addCleanup(self.application_catalog_client.delete_session,
self.environment['id'], session['id'])
services_list = self.application_catalog_client.\
get_services_list(self.environment['id'], session['id'])
post_body = self._get_demo_app()
self.application_catalog_client.\
create_service(self.environment['id'], session['id'], post_body)
services_list_ = self.application_catalog_client.\
get_services_list(self.environment['id'], session['id'])
self.assertEqual(len(services_list) + 1, len(services_list_))
self.application_catalog_client.\
update_services(self.environment['id'], session['id'])
services_list_ = self.application_catalog_client.\
get_services_list(self.environment['id'], session['id'])
self.assertEqual(0, len(services_list_))
self.application_catalog_client.\
create_service(self.environment['id'], session['id'], post_body)
services_list_ = self.application_catalog_client.\
get_services_list(self.environment['id'], session['id'])
self.assertEqual(1, len(services_list_))
@testtools.testcase.attr('smoke')
def test_get_service(self):
session = self.application_catalog_client.\

View File

@ -159,6 +159,32 @@ class TestServicesNegative(base.BaseApplicationCatalogTest):
session['id'],
service['?']['id'])
@testtools.testcase.attr('negative')
def test_put_services_without_env_id(self):
session = self.application_catalog_client.\
create_session(self.environment['id'])
self.addCleanup(self.application_catalog_client.delete_session,
self.environment['id'], session['id'])
put_body = [self._get_demo_app()]
self.assertRaises(exceptions.NotFound,
self.application_catalog_client.update_services,
None,
session['id'],
put_body)
@testtools.testcase.attr('negative')
def test_put_services_without_sess_id(self):
session = self.application_catalog_client.\
create_session(self.environment['id'])
self.addCleanup(self.application_catalog_client.delete_session,
self.environment['id'], session['id'])
put_body = [self._get_demo_app()]
self.assertRaises(exceptions.BadRequest,
self.application_catalog_client.update_services,
self.environment['id'],
"",
put_body)
class TestServicesNegativeTenantIsolation(base.BaseApplicationCatalogTest):