Fix to handle Str and JSON mix-in data correctly with settings API

- Fixed issue #5528

Signed-off-by: Hideki Saito <saito@fgrep.org>
This commit is contained in:
Hideki Saito
2019-12-19 02:15:25 +00:00
committed by Ryan Petrello
parent 490492e505
commit 437d9843d1
2 changed files with 13 additions and 2 deletions

View File

@@ -122,7 +122,7 @@ clean-api:
rm -rf awx/projects
clean-awxkit:
rm -rf awxkit/*.egg-info awxkit/.tox
rm -rf awxkit/*.egg-info awxkit/.tox awxkit/build/*
# convenience target to assert environment variables are defined
guard-%:

View File

@@ -1,4 +1,5 @@
import functools
import json
from six import with_metaclass
@@ -539,5 +540,15 @@ class SettingsModify(CustomAction):
def perform(self, key, value):
self.page.endpoint = self.page.endpoint + 'all/'
resp = self.page.patch(**{key: value})
patch_value = value
if self.is_json(value):
patch_value = json.loads(value)
resp = self.page.patch(**{key: patch_value})
return resp.from_json({'key': key, 'value': resp[key]})
def is_json(self, data):
try:
json.loads(data)
except json.decoder.JSONDecodeError:
return False
return True