1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

Merge pull request #84 from chrismeyersfsu/feature-survey_password_redact

don't try and decode extra_vars if there are no extra_vars. Further, if ...
This commit is contained in:
Chris Meyers 2015-02-20 15:38:49 -05:00
commit 41b4a66640
2 changed files with 11 additions and 7 deletions

View File

@ -1422,11 +1422,15 @@ class JobSerializer(UnifiedJobSerializer, JobOptionsSerializer):
ret['job_template'] = None ret['job_template'] = None
if obj.job_template and obj.job_template.survey_enabled: if obj.job_template and obj.job_template.survey_enabled:
extra_vars = json.loads(ret['extra_vars']) if ret['extra_vars']:
for key in obj.job_template.survey_password_variables(): try:
if key in extra_vars: extra_vars = json.loads(ret['extra_vars'])
extra_vars[key] = REPLACE_STR for key in obj.job_template.survey_password_variables():
ret['extra_vars'] = json.dumps(extra_vars) if key in extra_vars:
extra_vars[key] = REPLACE_STR
ret['extra_vars'] = json.dumps(extra_vars)
except ValueError:
pass
return ret return ret

View File

@ -6,7 +6,7 @@ from django.core.urlresolvers import reverse
# AWX # AWX
from awx.main.models import * # noqa from awx.main.models import * # noqa
from awx.main.tests.base import BaseTest from awx.main.tests.base import BaseTest, QueueStartStopTestMixin
__all__ = ['SurveyPasswordRedactedTest'] __all__ = ['SurveyPasswordRedactedTest']
@ -141,7 +141,7 @@ TESTS = {
} }
} }
class SurveyPasswordBaseTest(BaseTest): class SurveyPasswordBaseTest(BaseTest, QueueStartStopTestMixin):
def setUp(self): def setUp(self):
super(SurveyPasswordBaseTest, self).setUp() super(SurveyPasswordBaseTest, self).setUp()
self.setup_instances() self.setup_instances()