From 4bf0f7c5e0f97ec383c41d53f042728facc596c4 Mon Sep 17 00:00:00 2001 From: Andrew Hughes Date: Mon, 28 Oct 2024 10:44:35 +0000 Subject: [PATCH] fixup: allow Applid to include special chars --- plugins/modules/region_jcl.py | 2 +- tests/unit/modules/test_region_jcl.py | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/plugins/modules/region_jcl.py b/plugins/modules/region_jcl.py index 078de8d6..0697ad38 100644 --- a/plugins/modules/region_jcl.py +++ b/plugins/modules/region_jcl.py @@ -300,7 +300,7 @@ def get_arg_defs(self): # type: () -> dict defs[STEPLIB]["options"][DATA_SETS].update({"elements": "data_set_base"}) defs[DFHRPL]["options"][TOP_DATA_SETS].update({"elements": "data_set_base"}) defs[DFHRPL]["options"][DATA_SETS].update({"elements": "data_set_base"}) - self.update_arg_def(defs[APPLID], "qualifier") + self.update_arg_def(defs[APPLID], "dd") if defs.get(JOB_PARAMETERS) and defs[JOB_PARAMETERS]["options"].get(JOB_NAME): # If they've provided a job_name we need to validate this too self.update_arg_def(defs[JOB_PARAMETERS]["options"][JOB_NAME], "qualifier") diff --git a/tests/unit/modules/test_region_jcl.py b/tests/unit/modules/test_region_jcl.py index 90d7ba38..92f76483 100644 --- a/tests/unit/modules/test_region_jcl.py +++ b/tests/unit/modules/test_region_jcl.py @@ -765,7 +765,24 @@ def test_validate_parameters_applid_too_long(): with pytest.raises(AnsibleFailJson) as exec_info: module = setup_and_update_parms({"applid": applid}) assert module.result["failed"] - assert exec_info.value.args[0]['msg'] == 'Invalid argument "{0}" for type "qualifier".'.format(applid) + assert exec_info.value.args[0]['msg'] == 'Invalid argument "{0}" for type "dd".'.format(applid) + + +def test_validate_parameters_applid_with_special_chars(): + prepare_for_exit() + applid = "APP$@#" + module = setup_and_update_parms({"applid": applid}) + module._exit() + assert not module.result["failed"] + + +def test_validate_parameters_applid_with_unacceptable_special_chars(): + prepare_for_fail() + applid = "AP$@#!£%" + with pytest.raises(AnsibleFailJson) as exec_info: + module = setup_and_update_parms({"applid": applid}) + assert module.result["failed"] + assert exec_info.value.args[0]['msg'] == 'Invalid argument "{0}" for type "dd".'.format(applid) def test_validate_parameters_steplib_library_too_long():