fix bug saving extra_data and follow prompts rules

display_extra_vars was not taking a copy of the data before
acting on it - this causes a bug where the activity stream will
modify the existing object on the model. That leads to new data
not being accepted.

Also moved the processing of extra_data to prior to the accept
or ignore kwargs logic so that we pass the right (post-encryption)
form of the variables.
This commit is contained in:
AlanCoding
2017-12-18 09:40:04 -05:00
parent 1e1839915d
commit c8e10adc96
5 changed files with 34 additions and 24 deletions

View File

@@ -197,7 +197,7 @@ class TestWorkflowJobTemplateNodeSerializerSurveyPasswords():
assert attrs['extra_data']['var1'].startswith('$encrypted$')
assert len(attrs['extra_data']['var1']) > len('$encrypted$')
def test_use_db_answer(self, jt):
def test_use_db_answer(self, jt, mocker):
serializer = WorkflowJobTemplateNodeSerializer()
wfjt = WorkflowJobTemplate(name='fake-wfjt')
serializer.instance = WorkflowJobTemplateNode(
@@ -205,11 +205,12 @@ class TestWorkflowJobTemplateNodeSerializerSurveyPasswords():
unified_job_template=jt,
extra_data={'var1': '$encrypted$foooooo'}
)
attrs = serializer.validate({
'unified_job_template': jt,
'workflow_job_template': wfjt,
'extra_data': {'var1': '$encrypted$'}
})
with mocker.patch('awx.main.models.mixins.decrypt_value', return_value='foo'):
attrs = serializer.validate({
'unified_job_template': jt,
'workflow_job_template': wfjt,
'extra_data': {'var1': '$encrypted$'}
})
assert 'survey_passwords' in attrs
assert 'var1' in attrs['survey_passwords']
assert attrs['extra_data']['var1'] == '$encrypted$foooooo'