Пример #1
0
 def test_set_survey_passwords_modify(self, jt):
     serializer = WorkflowJobTemplateNodeSerializer()
     wfjt = WorkflowJobTemplate(name='fake-wfjt')
     serializer.instance = WorkflowJobTemplateNode(workflow_job_template=wfjt, unified_job_template=jt)
     attrs = serializer.validate({'unified_job_template': jt, 'workflow_job_template': wfjt, 'extra_data': {'var1': 'secret_answer'}})
     assert 'survey_passwords' in attrs
     assert 'var1' in attrs['survey_passwords']
     assert attrs['extra_data']['var1'].startswith('$encrypted$')
     assert len(attrs['extra_data']['var1']) > len('$encrypted$')
Пример #2
0
 def test_use_db_answer(self, jt, mocker):
     serializer = WorkflowJobTemplateNodeSerializer()
     wfjt = WorkflowJobTemplate(name='fake-wfjt')
     serializer.instance = WorkflowJobTemplateNode(workflow_job_template=wfjt, unified_job_template=jt, extra_data={'var1': '$encrypted$foooooo'})
     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'
Пример #3
0
 def WFJT_serializer(self):
     serializer = WorkflowJobTemplateNodeSerializer()
     node = WorkflowJobTemplateNode(pk=1)
     node.char_prompts = {'limit': 'webservers'}
     serializer.instance = node
     view = FakeView(node)
     view.request = FakeRequest()
     view.request.method = "PATCH"
     serializer.context = {'view': view}
     return serializer