-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Name and formatting changes -Add userid to result dictionary no matter what Signed-off-by: Elijah Swift <elijah.swift@ibm.com>
- Loading branch information
1 parent
8a227de
commit 000b71f
Showing
35 changed files
with
243 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
"""Exception to use when no data is returned by IRRSMO00.""" | ||
from typing import Union | ||
|
||
|
||
class DownstreamFatalError(Exception): | ||
""" | ||
Raised when no xml string is returned by IRRSMO00. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
xml_str: str, | ||
request_xml: bytes, | ||
run_as_userid: Union[str, None] = None, | ||
result_dict: dict = None, | ||
) -> None: | ||
self.message = "Security request made to IRRSMO00 failed." | ||
self.saf_return_code = xml_str[0] | ||
self.racf_return_code = xml_str[1] | ||
self.racf_reason_code = xml_str[2] | ||
self.request_xml = request_xml.decode("utf-8") | ||
self.message += ( | ||
f"\n\nSAF Return Code: {self.saf_return_code}\nRACF Return Code:" | ||
+ f" {self.racf_return_code}\nRACF Reason Code: {self.racf_reason_code}" | ||
) | ||
if result_dict is not None: | ||
self.message += ( | ||
"\n\nSee results dictionary " | ||
+ f"'{self.__class__.__name__}.result' for more details.\n" | ||
+ "\n\nYou can also check the specified return and reason codes against" | ||
+ " the IRRSMO00 documented return and reason codes for more information" | ||
+ " about this error.\n" | ||
+ "https://www.ibm.com/docs/en/zos/3.1.0?topic=operations-return-reason-codes" | ||
) | ||
self.result = result_dict | ||
elif ( | ||
(self.saf_return_code == 8) | ||
and (self.racf_return_code == 200) | ||
and (self.racf_reason_code == 16) | ||
): | ||
self.message += ( | ||
"\n\nCheck to see if the proper RACF permissions are in place.\n" | ||
+ "For `set` or `alter` functions, you must have at least READ " | ||
+ "access to `IRR.IRRSMO00.PRECHECK` in the `XFACILIT` class." | ||
) | ||
elif ( | ||
(self.saf_return_code == 8) | ||
and (self.racf_return_code == 200) | ||
and (self.racf_reason_code == 8) | ||
): | ||
self.message += ( | ||
"\n\nCheck to see if the proper RACF permissions are in place.\n" | ||
+ "For the `run_as_userid` feature, you must have at least UPDATE" | ||
+ f" access to `{run_as_userid}.IRRSMO00` in the `SURROGAT` class." | ||
) | ||
else: | ||
self.message += ( | ||
"\n\nPlease check the specified return and reason codes against" | ||
+ " the IRRSMO00 documented return and reason codes for more information" | ||
+ " about this error.\n" | ||
+ "https://www.ibm.com/docs/en/zos/3.1.0?topic=operations-return-reason-codes" | ||
) | ||
self.message = f"({self.__class__.__name__}) {self.message}" | ||
|
||
def __str__(self) -> str: | ||
return self.message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,34 @@ | ||
"""Exception to use when no data is returned by IRRSMO00.""" | ||
from typing import Union | ||
"""Exception to use when data returned by IRRSMO00 indicates that the request failed.""" | ||
|
||
|
||
class SecurityRequestError(Exception): | ||
""" | ||
Raised when no xml string is returned by IRRSMO00. | ||
Raised when the return code of a security result returned by IRRSMO00 is NOT equal to 0. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
xml_str: str, | ||
request_xml: bytes, | ||
run_as_userid: Union[str, None] = None, | ||
result_dict: dict = None, | ||
) -> None: | ||
def __init__(self, result: dict) -> None: | ||
self.message = "Security request made to IRRSMO00 failed." | ||
self.saf_return_code = xml_str[0] | ||
self.racf_return_code = xml_str[1] | ||
self.racf_reason_code = xml_str[2] | ||
self.request_xml = request_xml.decode("utf-8") | ||
self.result = result | ||
self.message += ( | ||
f"\n\nSAF Return Code: {self.saf_return_code}\nRACF Return Code:" | ||
+ f" {self.racf_return_code}\nRACF Reason Code: {self.racf_reason_code}" | ||
"\n\nSee results dictionary " | ||
+ f"'{self.__class__.__name__}.result' for more details." | ||
) | ||
if result_dict is not None: | ||
self.message += ( | ||
"\n\nSee results dictionary " | ||
+ f"'{self.__class__.__name__}.result' for more details.\n" | ||
+ "\n\nYou can also check the specified return and reason codes against" | ||
+ " the IRRSMO00 documented return and reason codes for more information" | ||
+ " about this error.\n" | ||
+ "https://www.ibm.com/docs/en/zos/3.1.0?topic=operations-return-reason-codes" | ||
) | ||
self.result = result_dict | ||
elif ( | ||
(self.saf_return_code == 8) | ||
and (self.racf_return_code == 200) | ||
and (self.racf_reason_code == 16) | ||
): | ||
self.message += ( | ||
"\n\nCheck to see if the proper RACF permissions are in place.\n" | ||
+ "For `set` or `alter` functions, you must have at least READ " | ||
+ "access to `IRR.IRRSMO00.PRECHECK` in the `XFACILIT` class." | ||
) | ||
elif ( | ||
(self.saf_return_code == 8) | ||
and (self.racf_return_code == 200) | ||
and (self.racf_reason_code == 8) | ||
): | ||
self.message += ( | ||
"\n\nCheck to see if the proper RACF permissions are in place.\n" | ||
+ "For the `run_as_userid` feature, you must have at least UPDATE" | ||
+ f" access to `{run_as_userid}.IRRSMO00` in the `SURROGAT` class." | ||
) | ||
else: | ||
self.message += ( | ||
"\n\nPlease check the specified return and reason codes against" | ||
+ " the IRRSMO00 documented return and reason codes for more information" | ||
+ " about this error.\n" | ||
+ "https://www.ibm.com/docs/en/zos/3.1.0?topic=operations-return-reason-codes" | ||
) | ||
self.message = f"({self.__class__.__name__}) {self.message}" | ||
|
||
def __str__(self) -> str: | ||
return self.message | ||
|
||
def contains_error_message( | ||
self, security_definition_tag: str, error_message_id: str | ||
): | ||
"""Checks to see if specific error message id appears in the security request error""" | ||
commands = self.result["securityResult"][security_definition_tag].get( | ||
"commands" | ||
) | ||
if not isinstance(commands, list): | ||
return False | ||
messages = commands[0].get("messages", []) | ||
if error_message_id in "".join(messages): | ||
return True | ||
else: | ||
return False |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.