Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixup: allow Applid to include special chars #144

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/modules/region_jcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this type definitely right? Looking at this doc, where an applid is between 2-8 characters if this is what we are taking as the standard.
And I think type dd allows for 1 char length?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah DD would allow for 1 char as per its regex r"^[A-Z$#@][A-Z0-9@#$]{0,7}$"
But so would qualifier the one were currently using r"^[A-Z]{1}[A-Z0-9]{0,7}$"

Maybe we should add an additional length check into here somewhere

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good point. Happy for this to merge as we are only improving the existing then, but should raise issue for the length atleast or just add this onto this PR if you have time? Whatever is easiest

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make an issue for length, suspect its gonna be a trickier one to do

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")
Expand Down
19 changes: 18 additions & 1 deletion tests/unit/modules/test_region_jcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Loading