mirror of
https://github.com/ansible/awx.git
synced 2026-03-15 16:07:30 -02:30
Omit placeholder vars with survey password defaults
WFJT nodes & schedules (launch configs) will accept POST/PATCH/PUT with variables in extra_data that have $encrypted$ for their value if a valid survey default exists. In this case, the variable is simply removed from the extra_data. This is done so that it does not affect pre-existing value substitution for $encrypted$ values from the config itself
This commit is contained in:
@@ -215,6 +215,24 @@ class TestWorkflowJobTemplateNodeSerializerSurveyPasswords():
|
||||
assert 'var1' in attrs['survey_passwords']
|
||||
assert attrs['extra_data']['var1'] == '$encrypted$foooooo'
|
||||
|
||||
def test_accept_password_default(self, jt, mocker):
|
||||
'''
|
||||
If user provides "$encrypted$" without a corresponding DB value for the
|
||||
node, but survey question has a default, then variables are accepted
|
||||
with that particular var omitted so on launch time the default takes effect
|
||||
'''
|
||||
serializer = WorkflowJobTemplateNodeSerializer()
|
||||
wfjt = WorkflowJobTemplate(name='fake-wfjt')
|
||||
jt.survey_spec['spec'][0]['default'] = '$encrypted$bar'
|
||||
attrs = serializer.validate({
|
||||
'unified_job_template': jt,
|
||||
'workflow_job_template': wfjt,
|
||||
'extra_data': {'var1': '$encrypted$'}
|
||||
})
|
||||
assert 'survey_passwords' in attrs
|
||||
assert attrs['survey_passwords'] == {}
|
||||
assert attrs['extra_data'] == {}
|
||||
|
||||
|
||||
@mock.patch('awx.api.serializers.WorkflowJobTemplateNodeSerializer.get_related', lambda x,y: {})
|
||||
class TestWorkflowJobNodeSerializerGetRelated():
|
||||
|
||||
Reference in New Issue
Block a user