diff --git a/awx/main/tests/functional/api/test_survey_spec.py b/awx/main/tests/functional/api/test_survey_spec.py index 1aff4b8eea..f954538973 100644 --- a/awx/main/tests/functional/api/test_survey_spec.py +++ b/awx/main/tests/functional/api/test_survey_spec.py @@ -211,7 +211,7 @@ def test_launch_with_non_empty_survey_spec_no_license(job_template_factory, post @pytest.mark.django_db @pytest.mark.survey def test_redact_survey_passwords_in_activity_stream(job_template_with_survey_passwords): - job_template_with_survey_passwords.create_unified_job(extra_vars={'secret_key':''}) + job_template_with_survey_passwords.create_unified_job() AS_record = ActivityStream.objects.filter(object1='job').all()[0] changes_dict = json.loads(AS_record.changes) extra_vars = json.loads(changes_dict['extra_vars']) diff --git a/awx/main/tests/unit/models/test_survey_models.py b/awx/main/tests/unit/models/test_survey_models.py index 584a4cc7f0..eefc5d97ab 100644 --- a/awx/main/tests/unit/models/test_survey_models.py +++ b/awx/main/tests/unit/models/test_survey_models.py @@ -4,6 +4,7 @@ import json from awx.main.tasks import RunJob from awx.main.models import ( Job, + JobTemplate, WorkflowJobTemplate ) @@ -78,6 +79,18 @@ def test_job_args_unredacted_passwords(job): assert extra_vars['secret_key'] == 'my_password' +def test_update_kwargs_survey_invalid_default(survey_spec_factory): + spec = survey_spec_factory('var2') + spec['spec'][0]['required'] = False + spec['spec'][0]['min'] = 3 + spec['spec'][0]['default'] = 1 + jt = JobTemplate(name="test-jt", survey_spec=spec, survey_enabled=True, extra_vars="var2: 2") + defaulted_extra_vars = jt._update_unified_job_kwargs() + assert 'extra_vars' in defaulted_extra_vars + # Make sure we did not set the invalid default of 1 + assert json.loads(defaulted_extra_vars['extra_vars'])['var2'] == 2 + + class TestWorkflowSurveys: def test_update_kwargs_survey_defaults(self, survey_spec_factory): "Assure that the survey default over-rides a JT variable"