コード例 #1
0
 def test_set_survey_passwords_create(self, jt):
     serializer = WorkflowJobTemplateNodeSerializer()
     wfjt = WorkflowJobTemplate(name='fake-wfjt')
     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
コード例 #4
0
 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'] == {}
コード例 #5
0
ファイル: test_workflow_serializers.py プロジェクト: opt9/awx
 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']
コード例 #6
0
 def test_workflow_unified_job_template_absent(self, workflow_job_template_node):
     related = WorkflowJobTemplateNodeSerializer().get_related(workflow_job_template_node)
     assert 'unified_job_template' not in related