diff --git a/pyproject.toml b/pyproject.toml index 46884260..a2fbc483 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ [tool.poetry] name="pyracf" - version="1.0b5" + version="1.0b6" description="Python interface to RACF using IRRSMO00 RACF Callable Service." license = "Apache-2.0" authors = [ diff --git a/pyracf/common/security_admin.py b/pyracf/common/security_admin.py index d916b1fe..6a2b58b2 100644 --- a/pyracf/common/security_admin.py +++ b/pyracf/common/security_admin.py @@ -54,6 +54,8 @@ class SecurityAdmin: _valid_segment_traits = {} _extracted_key_value_pair_segment_traits_map = {} + # Use this structure to map traits to their RACF keywords and Message keywords for redaction + _racf_trait_and_message_key_map = {"trait_map": {}, "message_map": {}} _case_sensitive_extracted_values = [] __running_userid = None _logger = Logger() @@ -170,24 +172,49 @@ def __raw_dump(self) -> None: if self.__debug: # Note, since the hex dump is logged to the console, # secrets will be redacted. - self._logger.log_hex_dump(raw_result_xml, self.__secret_traits) + self._logger.log_hex_dump( + raw_result_xml, + self.__secret_traits, + self._racf_trait_and_message_key_map, + ) # ============================================================================ # Secrets Redaction # ============================================================================ def __add_additional_secret_traits(self, additional_secret_traits: list) -> None: """Add additional fields to be redacted in logger output.""" + unsupported_profile_types = ["permission", "groupConnection", "systemSettings"] + error_message = ( + f"Cannot add specified additional secrets to '{self._profile_type}' object." + ) + if self._profile_type in unsupported_profile_types: + error_message = error_message + ( + f"\n'{self._profile_type}' object does not support additional secrets redaction." + ) + raise ValueError(error_message) + bad_secret_traits = [] for secret in additional_secret_traits: if secret in self.__secret_traits: continue if ":" not in secret: + bad_secret_traits.append( + f"\nCould not map {secret} to a valid segment trait." + ) continue segment = secret.split(":")[0] if segment not in self._valid_segment_traits: + bad_secret_traits.append( + f"\nCould not map {secret} to a valid segment trait." + ) continue if secret not in self._valid_segment_traits[segment]: + bad_secret_traits.append( + f"\nCould not map {secret} to a valid segment trait." + ) continue self.__secret_traits[secret] = self._valid_segment_traits[segment][secret] + if bad_secret_traits: + raise ValueError(error_message + "".join(bad_secret_traits)) # ============================================================================ # Request Execution @@ -242,6 +269,7 @@ def _make_request( self.__running_userid, ), self.__secret_traits, + self._racf_trait_and_message_key_map, ) self.__clear_state(security_request) if isinstance(raw_result, list): diff --git a/pyracf/common/utilities/logger.py b/pyracf/common/utilities/logger.py index abe85099..fe6877f4 100644 --- a/pyracf/common/utilities/logger.py +++ b/pyracf/common/utilities/logger.py @@ -149,39 +149,110 @@ def __redact_request_dictionary( def __redact_string( self, input_string: Union[str, bytes], - start_ind: int, - end_pattern: Union[str, bytes], - ): - """ - Redacts characters in a string between a starting index and ending pattern. + trait_key: str, + ) -> Union[str, bytes]: + r""" + Redacts characters in a string between a starting index and ending tag. Replaces the identified characters with '********' regardless of the original length. + + This function employs the following regular expressions explained below + + Regex 1 ("quoted") - {trait_key.upper()}( +){{0,}}\(\'.*?(? Union[str, bytes]: - """ + r""" Redact a list of specific secret traits in a request xml string or bytes object. Based the following xml pattern: 'xml value' This function also accounts for any number of arbitrary xml attributes. + + This function employs the following regular expression: + {xml_key}(.*)>.*<\/{xml_key} - Designed to match the above pattern by starting and ending + with the xmltag string as shown, but the starting tag allows for any characters between + "xmltag" and the > character to allow for the attribute specification shown above. This + results in the starting of the xml as {xml_key}(.*)> and the ending as <\/{xml_key}. + The characters between the xml tags are "captured" as a variable and preserved by the + substitution operation through the use of the \1 supplied in the replacement string. + Between these tags, any non-newline characters are allowed using the .* expression. """ is_bytes = False if isinstance(xml_string, bytes): is_bytes = True xml_string = xml_string.decode("utf-8") for xml_key in secret_traits.values(): - match = re.search(rf"\<{xml_key}+[^>]*\>", xml_string) - if not match: - continue + start_tag_end_tag_regex = rf"{xml_key}(.*)>.*<\/{xml_key}" + redacted_regex = rf"{xml_key}\1>******** - if f"" not in xml_string: - continue - xml_string = self.__redact_string(xml_string, match.end(), f" str: - """ + r""" Redacts a list of specific secret traits in a result xml string. - Based on the following RACF command pattern: + Based on the following RACF command patterns: 'TRAIT (value)' + 'TRAIT (subtrait1(value) subtrait2(value)) + "TRAIT ('value')" This function also accounts for varied amounts of whitespace in the pattern. + + This function employs the following regular expression: + ([A-Z]*[0-9]*[A-Z]) [^<>]*{racf_key.upper()}[^<>]*<\/message>" - + Designed to match the above pattern by starting and ending with the message xml tag + string as shown, the value of the message is targeted based on the racf_key. This + should capture only messages that contain information about a redacted key. + The message identifier is "captured" as a variable and preserved by the substitution + operation through the use of the \1 supplied in the replacement string. """ if isinstance(security_result, list): return security_result for xml_key in secret_traits.values(): racf_key = xml_key.split(":")[1] if ":" in xml_key else xml_key - end_pattern = ")" + if racf_key in racf_trait_and_message_key_map.get("trait_map", {}): + racf_key = racf_trait_and_message_key_map["trait_map"][racf_key] + racf_command_argument_regex = rf"{racf_key.upper()}( +){{0,}}\(" if isinstance(security_result, bytes): match = re.search( - rf"{racf_key.upper()} +\(", security_result.decode("cp1047") + racf_command_argument_regex, security_result.decode("cp1047") ) - end_pattern = end_pattern.encode("cp1047") else: - match = re.search(rf"{racf_key.upper()} +\(", security_result) + match = re.search(rf"{racf_key.upper()}( +){{0,}}\(", security_result) if not match: continue - security_result = self.__redact_string( - security_result, match.end(), end_pattern + security_result = self.__redact_string(security_result, racf_key) + if racf_key in racf_trait_and_message_key_map.get("message_map", {}): + racf_key = racf_trait_and_message_key_map["message_map"][racf_key] + racf_message_regex = ( + r"([A-Z]*[0-9]*[A-Z]) [^<>]*" + + rf"{racf_key.upper()}[^<>]*<\/message>" + ) + redacted_racf_message_regex = ( + rf"REDACTED MESSAGE CONCERNING {racf_key.upper()}, " + + r"REVIEW DOCUMENTATION OF \1 FOR MORE INFORMATION" ) + if isinstance(security_result, bytes): + security_result = re.sub( + racf_message_regex, + redacted_racf_message_regex, + security_result.decode("cp1047"), + ).encode("cp1047") + else: + security_result = re.sub( + racf_message_regex, + redacted_racf_message_regex, + security_result, + ) return security_result def __colorize_json(self, json_text: str) -> str: @@ -355,7 +460,12 @@ def __indent_xml(self, minified_xml: str) -> str: indented_xml += f"{' ' * indent_level}{current_line}\n" return indented_xml[:-2] - def log_hex_dump(self, raw_result_xml: bytes, secret_traits: dict) -> None: + def log_hex_dump( + self, + raw_result_xml: bytes, + secret_traits: dict, + racf_trait_and_message_key_map: dict, + ) -> None: """ Log the raw result XML returned by IRRSMO00 as a hex dump. """ @@ -368,6 +478,7 @@ def log_hex_dump(self, raw_result_xml: bytes, secret_traits: dict) -> None: raw_result_xml = self.redact_result_xml( raw_result_xml, secret_traits, + racf_trait_and_message_key_map, ) for byte in raw_result_xml: color_function = self.__green diff --git a/pyracf/data_set/data_set_admin.py b/pyracf/data_set/data_set_admin.py index 9233ee0c..2b93359a 100644 --- a/pyracf/data_set/data_set_admin.py +++ b/pyracf/data_set/data_set_admin.py @@ -63,6 +63,16 @@ def __init__( "dfp": {"dfp:owner": "racf:resowner", "dfp:ckds_data_key": "racf:datakey"}, "tme": {"tme:roles": "racf:roles"}, } + self._racf_trait_and_message_key_map["trait_map"] = { + "audaltr": "audit", + "audcntl": "audit", + "audnone": "audit", + "audread": "audit", + "audupdt": "audit", + } + self._racf_trait_and_message_key_map["message_map"] = { + "uacc": "universal access" + } self._valid_segment_traits["base"].update( self._common_base_traits_data_set_generic ) diff --git a/pyracf/resource/resource_admin.py b/pyracf/resource/resource_admin.py index 940c37f3..39d23173 100644 --- a/pyracf/resource/resource_admin.py +++ b/pyracf/resource/resource_admin.py @@ -238,6 +238,16 @@ def __init__( "sigrequired": "signatureRequired", }, } + self._racf_trait_and_message_key_map["trait_map"] = { + "audaltr": "audit", + "audcntl": "audit", + "audnone": "audit", + "audread": "audit", + "audupdt": "audit", + } + self._racf_trait_and_message_key_map["message_map"] = { + "uacc": "universal access" + } super().__init__( "resource", irrsmo00_result_buffer_size=irrsmo00_result_buffer_size, diff --git a/tests/common/common_log_samples/alter_data_set_additional_secret_added_error.log b/tests/common/common_log_samples/alter_data_set_additional_secret_added_error.log new file mode 100644 index 00000000..9900478a --- /dev/null +++ b/tests/common/common_log_samples/alter_data_set_additional_secret_added_error.log @@ -0,0 +1,268 @@ + + [pyRACF:Debug] + Request Dictionary + DataSetAdmin.alter() + + +{} + + + [pyRACF:Debug] + Request XML + DataSetAdmin.alter() + + + + + + + + [pyRACF:Debug] + Result XML + DataSetAdmin.alter() + + + + + + + 0 + 0 + 0 + LISTDSD DATASET ('ESWIFT.TEST.T1136242.P3020470') + INFORMATION FOR DATASET ESWIFT.TEST.T1136242.P3020470 + + LEVEL OWNER UNIVERSAL ACCESS WARNING ERASE + ----- -------- ---------------- ------- ----- + 00 ESWIFT READ NO NO + + AUDITING + -------- + FAILURES(READ) + + NOTIFY + -------- + NO USER TO BE NOTIFIED + + YOUR ACCESS CREATION GROUP DATASET TYPE + ----------- -------------- ------------ + ALTER SYS1 NON-VSAM + + VOLUMES ON WHICH DATASET RESIDES + -------------------------------- + USRAT2 + + NO INSTALLATION DATA + + + 0 + 0 + + + + [pyRACF:Debug] + Result Dictionary + DataSetAdmin.alter() + + +{ + "securityResult": { + "dataSet": { + "name": "ESWIFT.TEST.T1136242.P3020470", + "operation": "listdata", + "generic": "no", + "requestId": "DatasetRequest", + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "LISTDSD DATASET ('ESWIFT.TEST.T1136242.P3020470')", + "messages": [ + "INFORMATION FOR DATASET ESWIFT.TEST.T1136242.P3020470", + null, + "LEVEL OWNER UNIVERSAL ACCESS WARNING ERASE", + "----- -------- ---------------- ------- -----", + " 00 ESWIFT READ NO NO", + null, + "AUDITING", + "--------", + "FAILURES(READ)", + null, + "NOTIFY", + "--------", + "NO USER TO BE NOTIFIED", + null, + "YOUR ACCESS CREATION GROUP DATASET TYPE", + "----------- -------------- ------------", + " ALTER SYS1 NON-VSAM", + null, + "VOLUMES ON WHICH DATASET RESIDES", + "--------------------------------", + "USRAT2", + null, + "NO INSTALLATION DATA" + ] + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + + + [pyRACF:Debug] + Result Dictionary (Formatted Profile) + DataSetAdmin.alter() + + +{ + "securityResult": { + "dataSet": { + "name": "ESWIFT.TEST.T1136242.P3020470", + "operation": "listdata", + "generic": "no", + "requestId": "DatasetRequest", + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "LISTDSD DATASET ('ESWIFT.TEST.T1136242.P3020470')", + "profiles": [ + { + "base": { + "name": "eswift.test.t1136242.p3020470", + "level": 0, + "owner": "eswift", + "universalAccess": "read", + "warning": null, + "erase": null, + "auditing": { + "failures": "read" + }, + "notify": null, + "yourAccess": "alter", + "creationGroup": "sys1", + "dataSetType": "non-vsam", + "volumes": [ + "usrat2" + ], + "installationData": null, + "generic": false + } + } + ] + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + + + [pyRACF:Debug] + Request Dictionary + DataSetAdmin.alter() + + +{ + "base": { + "base:universal_access": { + "value": "********", + "operation": null + }, + "base:owner": { + "value": "eswift", + "operation": null + } + } +} + + + [pyRACF:Debug] + Request XML + DataSetAdmin.alter() + + + + + + ******** + eswift + + + + + + [pyRACF:Debug] + Result XML + DataSetAdmin.alter() + + + + + + + 8 + 16 + 4 + ADDSD ('ESWIFT.TEST.T113622.P3020470') + ICH09005I ESWIFT.TEST.T113622.P3020470 NOT FOUND IN CATALOG + + + 8 + 16 + 4 + ALTDSD ('ESWIFT.TEST.T113622.P3020470') UACC (********) + ICH22001I ESWIFT.TEST.T113622.P3020470 NOT DEFINED TO RACF + + + 4 + 0 + + + + [pyRACF:Debug] + Result Dictionary + DataSetAdmin.alter() + + +{ + "securityResult": { + "dataSet": { + "name": "ESWIFT.TEST.T113622.P3020470", + "operation": "set", + "generic": "no", + "requestId": "DatasetRequest", + "commands": [ + { + "safReturnCode": 8, + "returnCode": 16, + "reasonCode": 4, + "image": "ADDSD ('ESWIFT.TEST.T113622.P3020470')", + "messages": [ + "ICH09005I ESWIFT.TEST.T113622.P3020470 NOT FOUND IN CATALOG" + ] + }, + { + "safReturnCode": 8, + "returnCode": 16, + "reasonCode": 4, + "image": "ALTDSD ('ESWIFT.TEST.T113622.P3020470') UACC (********)", + "messages": [ + "ICH22001I ESWIFT.TEST.T113622.P3020470 NOT DEFINED TO RACF" + ] + } + ] + }, + "returnCode": 4, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + diff --git a/tests/common/common_log_samples/alter_data_set_additional_secret_added_success.log b/tests/common/common_log_samples/alter_data_set_additional_secret_added_success.log new file mode 100644 index 00000000..af803124 --- /dev/null +++ b/tests/common/common_log_samples/alter_data_set_additional_secret_added_success.log @@ -0,0 +1,252 @@ + + [pyRACF:Debug] + Request Dictionary + DataSetAdmin.alter() + + +{} + + + [pyRACF:Debug] + Request XML + DataSetAdmin.alter() + + + + + + + + [pyRACF:Debug] + Result XML + DataSetAdmin.alter() + + + + + + + 0 + 0 + 0 + LISTDSD DATASET ('ESWIFT.TEST.T1136242.P3020470') + INFORMATION FOR DATASET ESWIFT.TEST.T1136242.P3020470 + + LEVEL OWNER UNIVERSAL ACCESS WARNING ERASE + ----- -------- ---------------- ------- ----- + 00 ESWIFT READ NO NO + + AUDITING + -------- + FAILURES(READ) + + NOTIFY + -------- + NO USER TO BE NOTIFIED + + YOUR ACCESS CREATION GROUP DATASET TYPE + ----------- -------------- ------------ + ALTER SYS1 NON-VSAM + + VOLUMES ON WHICH DATASET RESIDES + -------------------------------- + USRAT2 + + NO INSTALLATION DATA + + + 0 + 0 + + + + [pyRACF:Debug] + Result Dictionary + DataSetAdmin.alter() + + +{ + "securityResult": { + "dataSet": { + "name": "ESWIFT.TEST.T1136242.P3020470", + "operation": "listdata", + "generic": "no", + "requestId": "DatasetRequest", + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "LISTDSD DATASET ('ESWIFT.TEST.T1136242.P3020470')", + "messages": [ + "INFORMATION FOR DATASET ESWIFT.TEST.T1136242.P3020470", + null, + "LEVEL OWNER UNIVERSAL ACCESS WARNING ERASE", + "----- -------- ---------------- ------- -----", + " 00 ESWIFT READ NO NO", + null, + "AUDITING", + "--------", + "FAILURES(READ)", + null, + "NOTIFY", + "--------", + "NO USER TO BE NOTIFIED", + null, + "YOUR ACCESS CREATION GROUP DATASET TYPE", + "----------- -------------- ------------", + " ALTER SYS1 NON-VSAM", + null, + "VOLUMES ON WHICH DATASET RESIDES", + "--------------------------------", + "USRAT2", + null, + "NO INSTALLATION DATA" + ] + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + + + [pyRACF:Debug] + Result Dictionary (Formatted Profile) + DataSetAdmin.alter() + + +{ + "securityResult": { + "dataSet": { + "name": "ESWIFT.TEST.T1136242.P3020470", + "operation": "listdata", + "generic": "no", + "requestId": "DatasetRequest", + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "LISTDSD DATASET ('ESWIFT.TEST.T1136242.P3020470')", + "profiles": [ + { + "base": { + "name": "eswift.test.t1136242.p3020470", + "level": 0, + "owner": "eswift", + "universalAccess": "read", + "warning": null, + "erase": null, + "auditing": { + "failures": "read" + }, + "notify": null, + "yourAccess": "alter", + "creationGroup": "sys1", + "dataSetType": "non-vsam", + "volumes": [ + "usrat2" + ], + "installationData": null, + "generic": false + } + } + ] + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + + + [pyRACF:Debug] + Request Dictionary + DataSetAdmin.alter() + + +{ + "base": { + "base:universal_access": { + "value": "Read", + "operation": null + }, + "base:owner": { + "value": "********", + "operation": null + } + } +} + + + [pyRACF:Debug] + Request XML + DataSetAdmin.alter() + + + + + + Read + ******** + + + + + + [pyRACF:Debug] + Result XML + DataSetAdmin.alter() + + + + + + Definition exists. Add command skipped due to precheck option + + 0 + 0 + 0 + ALTDSD ('ESWIFT.TEST.T1136242.P3020470') UACC (Read) OWNER (********) + + + 0 + 0 + + + + [pyRACF:Debug] + Result Dictionary + DataSetAdmin.alter() + + +{ + "securityResult": { + "dataSet": { + "name": "ESWIFT.TEST.T1136242.P3020470", + "operation": "set", + "generic": "no", + "requestId": "DatasetRequest", + "info": [ + "Definition exists. Add command skipped due to precheck option" + ], + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "ALTDSD ('ESWIFT.TEST.T1136242.P3020470') UACC (Read) OWNER (********)" + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + diff --git a/tests/common/common_log_samples/alter_group_additional_secret_added_error.log b/tests/common/common_log_samples/alter_group_additional_secret_added_error.log new file mode 100644 index 00000000..1a5a033f --- /dev/null +++ b/tests/common/common_log_samples/alter_group_additional_secret_added_error.log @@ -0,0 +1,246 @@ + + [pyRACF:Debug] + Request Dictionary + GroupAdmin.alter() + + +{} + + + [pyRACF:Debug] + Request XML + GroupAdmin.alter() + + + + + + + + [pyRACF:Debug] + Result XML + GroupAdmin.alter() + + + + + + + 0 + 0 + 0 + LISTGRP TESTGRP0 + INFORMATION FOR GROUP TESTGRP0 + SUPERIOR GROUP=SYS1 OWNER=ESWIFT CREATED=23.150 + NO INSTALLATION DATA + NO MODEL DATA SET + TERMUACC + NO SUBGROUPS + USER(S)= ACCESS= ACCESS COUNT= UNIVERSAL ACCESS= + ESWIFT USE 000000 NONE + CONNECT ATTRIBUTES=SPECIAL + REVOKE DATE=NONE RESUME DATE=NONE + LEONARD USE 000000 NONE + CONNECT ATTRIBUTES=OPERATIONS + REVOKE DATE=NONE RESUME DATE=NONE + + + 0 + 0 + + + + [pyRACF:Debug] + Result Dictionary + GroupAdmin.alter() + + +{ + "securityResult": { + "group": { + "name": "testgrp0", + "operation": "listdata", + "requestId": "GroupRequest", + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "LISTGRP TESTGRP0 ", + "messages": [ + "INFORMATION FOR GROUP TESTGRP0", + " SUPERIOR GROUP=SYS1 OWNER=ESWIFT CREATED=23.150", + " NO INSTALLATION DATA", + " NO MODEL DATA SET", + " TERMUACC", + " NO SUBGROUPS", + " USER(S)= ACCESS= ACCESS COUNT= UNIVERSAL ACCESS=", + " ESWIFT USE 000000 NONE", + " CONNECT ATTRIBUTES=SPECIAL", + " REVOKE DATE=NONE RESUME DATE=NONE", + " LEONARD USE 000000 NONE", + " CONNECT ATTRIBUTES=OPERATIONS", + " REVOKE DATE=NONE RESUME DATE=NONE" + ] + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + + + [pyRACF:Debug] + Result Dictionary (Formatted Profile) + GroupAdmin.alter() + + +{ + "securityResult": { + "group": { + "name": "testgrp0", + "operation": "listdata", + "requestId": "GroupRequest", + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "LISTGRP TESTGRP0 ", + "profiles": [ + { + "base": { + "name": "testgrp0", + "superiorGroup": "sys1", + "owner": "eswift", + "created": "5/30/2023", + "installationData": null, + "modelDataSet": null, + "terminalUniversalAccess": true, + "subgroups": [], + "users": [ + { + "userid": "eswift", + "access": "use", + "accessCount": 0, + "universalAccess": null, + "connectAttributes": [ + "special" + ], + "revokeDate": null, + "resumeDate": null + }, + { + "userid": "leonard", + "access": "use", + "accessCount": 0, + "universalAccess": null, + "connectAttributes": [ + "operations" + ], + "revokeDate": null, + "resumeDate": null + } + ] + } + } + ] + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + + + [pyRACF:Debug] + Request Dictionary + GroupAdmin.alter() + + +{ + "omvs": { + "omvs:gid": { + "value": "********", + "operation": null + } + } +} + + + [pyRACF:Debug] + Request XML + GroupAdmin.alter() + + + + + + ******** + + + + + + [pyRACF:Debug] + Result XML + GroupAdmin.alter() + + + + + + Definition exists. Add command skipped due to precheck option + + 8 + 16 + 8 + ALTGROUP TESTGRP0 OMVS (GID (********)) + REDACTED MESSAGE CONCERNING GID, REVIEW DOCUMENTATION OF IKJ56702I FOR MORE INFORMATION + REDACTED MESSAGE CONCERNING GID, REVIEW DOCUMENTATION OF IKJ56701I FOR MORE INFORMATION + REDACTED MESSAGE CONCERNING GID, REVIEW DOCUMENTATION OF IKJ56701I FOR MORE INFORMATION + + + 4 + 0 + + + + [pyRACF:Debug] + Result Dictionary + GroupAdmin.alter() + + +{ + "securityResult": { + "group": { + "name": "testgrp0", + "operation": "set", + "requestId": "GroupRequest", + "info": [ + "Definition exists. Add command skipped due to precheck option" + ], + "commands": [ + { + "safReturnCode": 8, + "returnCode": 16, + "reasonCode": 8, + "image": "ALTGROUP TESTGRP0 OMVS (GID (********))", + "messages": [ + "REDACTED MESSAGE CONCERNING GID, REVIEW DOCUMENTATION OF IKJ56702I FOR MORE INFORMATION", + "REDACTED MESSAGE CONCERNING GID, REVIEW DOCUMENTATION OF IKJ56701I FOR MORE INFORMATION", + "REDACTED MESSAGE CONCERNING GID, REVIEW DOCUMENTATION OF IKJ56701I FOR MORE INFORMATION" + ] + } + ] + }, + "returnCode": 4, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + diff --git a/tests/common/common_log_samples/alter_group_additional_secret_added_success.log b/tests/common/common_log_samples/alter_group_additional_secret_added_success.log new file mode 100644 index 00000000..16ef1aa4 --- /dev/null +++ b/tests/common/common_log_samples/alter_group_additional_secret_added_success.log @@ -0,0 +1,238 @@ + + [pyRACF:Debug] + Request Dictionary + GroupAdmin.alter() + + +{} + + + [pyRACF:Debug] + Request XML + GroupAdmin.alter() + + + + + + + + [pyRACF:Debug] + Result XML + GroupAdmin.alter() + + + + + + + 0 + 0 + 0 + LISTGRP TESTGRP0 + INFORMATION FOR GROUP TESTGRP0 + SUPERIOR GROUP=SYS1 OWNER=ESWIFT CREATED=23.150 + NO INSTALLATION DATA + NO MODEL DATA SET + TERMUACC + NO SUBGROUPS + USER(S)= ACCESS= ACCESS COUNT= UNIVERSAL ACCESS= + ESWIFT USE 000000 NONE + CONNECT ATTRIBUTES=SPECIAL + REVOKE DATE=NONE RESUME DATE=NONE + LEONARD USE 000000 NONE + CONNECT ATTRIBUTES=OPERATIONS + REVOKE DATE=NONE RESUME DATE=NONE + + + 0 + 0 + + + + [pyRACF:Debug] + Result Dictionary + GroupAdmin.alter() + + +{ + "securityResult": { + "group": { + "name": "testgrp0", + "operation": "listdata", + "requestId": "GroupRequest", + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "LISTGRP TESTGRP0 ", + "messages": [ + "INFORMATION FOR GROUP TESTGRP0", + " SUPERIOR GROUP=SYS1 OWNER=ESWIFT CREATED=23.150", + " NO INSTALLATION DATA", + " NO MODEL DATA SET", + " TERMUACC", + " NO SUBGROUPS", + " USER(S)= ACCESS= ACCESS COUNT= UNIVERSAL ACCESS=", + " ESWIFT USE 000000 NONE", + " CONNECT ATTRIBUTES=SPECIAL", + " REVOKE DATE=NONE RESUME DATE=NONE", + " LEONARD USE 000000 NONE", + " CONNECT ATTRIBUTES=OPERATIONS", + " REVOKE DATE=NONE RESUME DATE=NONE" + ] + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + + + [pyRACF:Debug] + Result Dictionary (Formatted Profile) + GroupAdmin.alter() + + +{ + "securityResult": { + "group": { + "name": "testgrp0", + "operation": "listdata", + "requestId": "GroupRequest", + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "LISTGRP TESTGRP0 ", + "profiles": [ + { + "base": { + "name": "testgrp0", + "superiorGroup": "sys1", + "owner": "eswift", + "created": "5/30/2023", + "installationData": null, + "modelDataSet": null, + "terminalUniversalAccess": true, + "subgroups": [], + "users": [ + { + "userid": "eswift", + "access": "use", + "accessCount": 0, + "universalAccess": null, + "connectAttributes": [ + "special" + ], + "revokeDate": null, + "resumeDate": null + }, + { + "userid": "leonard", + "access": "use", + "accessCount": 0, + "universalAccess": null, + "connectAttributes": [ + "operations" + ], + "revokeDate": null, + "resumeDate": null + } + ] + } + } + ] + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + + + [pyRACF:Debug] + Request Dictionary + GroupAdmin.alter() + + +{ + "omvs": { + "omvs:gid": { + "value": "********", + "operation": null + } + } +} + + + [pyRACF:Debug] + Request XML + GroupAdmin.alter() + + + + + + ******** + + + + + + [pyRACF:Debug] + Result XML + GroupAdmin.alter() + + + + + + Definition exists. Add command skipped due to precheck option + + 0 + 0 + 0 + ALTGROUP TESTGRP0 OMVS (GID (********)) + + + 0 + 0 + + + + [pyRACF:Debug] + Result Dictionary + GroupAdmin.alter() + + +{ + "securityResult": { + "group": { + "name": "testgrp0", + "operation": "set", + "requestId": "GroupRequest", + "info": [ + "Definition exists. Add command skipped due to precheck option" + ], + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "ALTGROUP TESTGRP0 OMVS (GID (********))" + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + diff --git a/tests/common/common_log_samples/alter_resource_additional_secret_added_error.log b/tests/common/common_log_samples/alter_resource_additional_secret_added_error.log new file mode 100644 index 00000000..c371a5ea --- /dev/null +++ b/tests/common/common_log_samples/alter_resource_additional_secret_added_error.log @@ -0,0 +1,257 @@ + + [pyRACF:Debug] + Request Dictionary + ResourceAdmin.alter() + + +{} + + + [pyRACF:Debug] + Request XML + ResourceAdmin.alter() + + + + + + + + [pyRACF:Debug] + Result XML + ResourceAdmin.alter() + + + + + + + 0 + 0 + 0 + RLIST ELIJTEST (TESTING) + CLASS NAME + ----- ---- + ELIJTEST TESTING + + LEVEL OWNER UNIVERSAL ACCESS YOUR ACCESS WARNING + ----- -------- ---------------- ----------- ------- + 00 ESWIFT READ READ NO + + INSTALLATION DATA + ----------------- + NONE + + APPLICATION DATA + ---------------- + NONE + + AUDITING + -------- + SUCCESS(UPDATE),FAILURES(READ) + + NOTIFY + ------ + NO USER TO BE NOTIFIED + + + 0 + 0 + + + + [pyRACF:Debug] + Result Dictionary + ResourceAdmin.alter() + + +{ + "securityResult": { + "resource": { + "name": "TESTING", + "class": "ELIJTEST", + "operation": "listdata", + "requestId": "ResourceRequest", + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "RLIST ELIJTEST (TESTING) ", + "messages": [ + "CLASS NAME", + "----- ----", + "ELIJTEST TESTING", + " ", + "LEVEL OWNER UNIVERSAL ACCESS YOUR ACCESS WARNING", + "----- -------- ---------------- ----------- -------", + " 00 ESWIFT READ READ NO", + " ", + "INSTALLATION DATA", + "-----------------", + "NONE", + " ", + "APPLICATION DATA", + "----------------", + "NONE", + " ", + "AUDITING", + "--------", + "SUCCESS(UPDATE),FAILURES(READ)", + " ", + "NOTIFY", + "------", + "NO USER TO BE NOTIFIED" + ] + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + + + [pyRACF:Debug] + Result Dictionary (Formatted Profile) + ResourceAdmin.alter() + + +{ + "securityResult": { + "resource": { + "name": "TESTING", + "class": "ELIJTEST", + "operation": "listdata", + "requestId": "ResourceRequest", + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "RLIST ELIJTEST (TESTING) ", + "profiles": [ + { + "base": { + "class": "elijtest", + "name": "testing", + "level": 0, + "owner": "eswift", + "universalAccess": "read", + "yourAccess": "read", + "warning": null, + "installationData": null, + "applicationData": null, + "auditing": { + "success": "update", + "failures": "read" + }, + "notify": null, + "generic": false + } + } + ] + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + + + [pyRACF:Debug] + Request Dictionary + ResourceAdmin.alter() + + +{ + "base": { + "base:universal_access": { + "value": "********", + "operation": null + }, + "base:owner": { + "value": "eswift", + "operation": null + } + } +} + + + [pyRACF:Debug] + Request XML + ResourceAdmin.alter() + + + + + + ******** + eswift + + + + + + [pyRACF:Debug] + Result XML + ResourceAdmin.alter() + + + + + + Definition exists. Add command skipped due to precheck option + + 8 + 16 + 8 + RALTER ELIJTEST (TESTING) UACC (********) OWNER (eswift) + REDACTED MESSAGE CONCERNING UNIVERSAL ACCESS, REVIEW DOCUMENTATION OF IKJ56702I FOR MORE INFORMATION + REDACTED MESSAGE CONCERNING UNIVERSAL ACCESS, REVIEW DOCUMENTATION OF IKJ56701I FOR MORE INFORMATION + IKJ56701I MISSING ALTER, CONTROL, UPDATE, READ, EXECUTE, OR NONE + + + 4 + 0 + + + + [pyRACF:Debug] + Result Dictionary + ResourceAdmin.alter() + + +{ + "securityResult": { + "resource": { + "name": "TESTING", + "class": "ELIJTEST", + "operation": "set", + "requestId": "ResourceRequest", + "info": [ + "Definition exists. Add command skipped due to precheck option" + ], + "commands": [ + { + "safReturnCode": 8, + "returnCode": 16, + "reasonCode": 8, + "image": "RALTER ELIJTEST (TESTING) UACC (********) OWNER (eswift)", + "messages": [ + "REDACTED MESSAGE CONCERNING UNIVERSAL ACCESS, REVIEW DOCUMENTATION OF IKJ56702I FOR MORE INFORMATION", + "REDACTED MESSAGE CONCERNING UNIVERSAL ACCESS, REVIEW DOCUMENTATION OF IKJ56701I FOR MORE INFORMATION", + "IKJ56701I MISSING ALTER, CONTROL, UPDATE, READ, EXECUTE, OR NONE" + ] + } + ] + }, + "returnCode": 4, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + diff --git a/tests/common/common_log_samples/alter_resource_additional_secret_added_success.log b/tests/common/common_log_samples/alter_resource_additional_secret_added_success.log new file mode 100644 index 00000000..e86e04a5 --- /dev/null +++ b/tests/common/common_log_samples/alter_resource_additional_secret_added_success.log @@ -0,0 +1,253 @@ + + [pyRACF:Debug] + Request Dictionary + ResourceAdmin.alter() + + +{} + + + [pyRACF:Debug] + Request XML + ResourceAdmin.alter() + + + + + + + + [pyRACF:Debug] + Result XML + ResourceAdmin.alter() + + + + + + + 0 + 0 + 0 + RLIST ELIJTEST (TESTING) + CLASS NAME + ----- ---- + ELIJTEST TESTING + + LEVEL OWNER UNIVERSAL ACCESS YOUR ACCESS WARNING + ----- -------- ---------------- ----------- ------- + 00 ESWIFT READ READ NO + + INSTALLATION DATA + ----------------- + NONE + + APPLICATION DATA + ---------------- + NONE + + AUDITING + -------- + SUCCESS(UPDATE),FAILURES(READ) + + NOTIFY + ------ + NO USER TO BE NOTIFIED + + + 0 + 0 + + + + [pyRACF:Debug] + Result Dictionary + ResourceAdmin.alter() + + +{ + "securityResult": { + "resource": { + "name": "TESTING", + "class": "ELIJTEST", + "operation": "listdata", + "requestId": "ResourceRequest", + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "RLIST ELIJTEST (TESTING) ", + "messages": [ + "CLASS NAME", + "----- ----", + "ELIJTEST TESTING", + " ", + "LEVEL OWNER UNIVERSAL ACCESS YOUR ACCESS WARNING", + "----- -------- ---------------- ----------- -------", + " 00 ESWIFT READ READ NO", + " ", + "INSTALLATION DATA", + "-----------------", + "NONE", + " ", + "APPLICATION DATA", + "----------------", + "NONE", + " ", + "AUDITING", + "--------", + "SUCCESS(UPDATE),FAILURES(READ)", + " ", + "NOTIFY", + "------", + "NO USER TO BE NOTIFIED" + ] + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + + + [pyRACF:Debug] + Result Dictionary (Formatted Profile) + ResourceAdmin.alter() + + +{ + "securityResult": { + "resource": { + "name": "TESTING", + "class": "ELIJTEST", + "operation": "listdata", + "requestId": "ResourceRequest", + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "RLIST ELIJTEST (TESTING) ", + "profiles": [ + { + "base": { + "class": "elijtest", + "name": "testing", + "level": 0, + "owner": "eswift", + "universalAccess": "read", + "yourAccess": "read", + "warning": null, + "installationData": null, + "applicationData": null, + "auditing": { + "success": "update", + "failures": "read" + }, + "notify": null, + "generic": false + } + } + ] + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + + + [pyRACF:Debug] + Request Dictionary + ResourceAdmin.alter() + + +{ + "base": { + "base:universal_access": { + "value": "Read", + "operation": null + }, + "base:owner": { + "value": "********", + "operation": null + } + } +} + + + [pyRACF:Debug] + Request XML + ResourceAdmin.alter() + + + + + + Read + ******** + + + + + + [pyRACF:Debug] + Result XML + ResourceAdmin.alter() + + + + + + Definition exists. Add command skipped due to precheck option + + 0 + 0 + 0 + RALTER ELIJTEST (TESTING) UACC (Read) OWNER (********) + ICH11009I RACLISTED PROFILES FOR ELIJTEST WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED. + + + 0 + 0 + + + + [pyRACF:Debug] + Result Dictionary + ResourceAdmin.alter() + + +{ + "securityResult": { + "resource": { + "name": "TESTING", + "class": "ELIJTEST", + "operation": "set", + "requestId": "ResourceRequest", + "info": [ + "Definition exists. Add command skipped due to precheck option" + ], + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "RALTER ELIJTEST (TESTING) UACC (Read) OWNER (********)", + "messages": [ + "ICH11009I RACLISTED PROFILES FOR ELIJTEST WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED." + ] + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} + diff --git a/tests/user/user_log_samples/alter_user_additional_secret_added_error.log b/tests/common/common_log_samples/alter_user_additional_secret_added_error.log similarity index 94% rename from tests/user/user_log_samples/alter_user_additional_secret_added_error.log rename to tests/common/common_log_samples/alter_user_additional_secret_added_error.log index 2e02e6c4..78e2dbb6 100644 --- a/tests/user/user_log_samples/alter_user_additional_secret_added_error.log +++ b/tests/common/common_log_samples/alter_user_additional_secret_added_error.log @@ -240,9 +240,9 @@ 16 8 ALTUSER SQUIDWRD NOSPECIAL OMVS (HOME ('/u/clarinet') NOPROGRAM UID (********)) - IKJ56702I INVALID UID, 90000000000 - IKJ56701I MISSING OMVS UID+ - IKJ56701I MISSING OMVS USER ID (UID), 1-10 NUMERIC DIGITS + REDACTED MESSAGE CONCERNING UID, REVIEW DOCUMENTATION OF IKJ56702I FOR MORE INFORMATION + REDACTED MESSAGE CONCERNING UID, REVIEW DOCUMENTATION OF IKJ56701I FOR MORE INFORMATION + REDACTED MESSAGE CONCERNING UID, REVIEW DOCUMENTATION OF IKJ56701I FOR MORE INFORMATION 4 @@ -271,9 +271,9 @@ "reasonCode": 8, "image": "ALTUSER SQUIDWRD NOSPECIAL OMVS (HOME ('/u/clarinet') NOPROGRAM UID (********))", "messages": [ - "IKJ56702I INVALID UID, 90000000000", - "IKJ56701I MISSING OMVS UID+", - "IKJ56701I MISSING OMVS USER ID (UID), 1-10 NUMERIC DIGITS" + "REDACTED MESSAGE CONCERNING UID, REVIEW DOCUMENTATION OF IKJ56702I FOR MORE INFORMATION", + "REDACTED MESSAGE CONCERNING UID, REVIEW DOCUMENTATION OF IKJ56701I FOR MORE INFORMATION", + "REDACTED MESSAGE CONCERNING UID, REVIEW DOCUMENTATION OF IKJ56701I FOR MORE INFORMATION" ] } ] diff --git a/tests/user/user_log_samples/alter_user_additional_secret_added_success.log b/tests/common/common_log_samples/alter_user_additional_secret_added_success.log similarity index 100% rename from tests/user/user_log_samples/alter_user_additional_secret_added_success.log rename to tests/common/common_log_samples/alter_user_additional_secret_added_success.log diff --git a/tests/common/common_result_samples/alter_data_set_result_error_uacc_secret.json b/tests/common/common_result_samples/alter_data_set_result_error_uacc_secret.json new file mode 100644 index 00000000..cdf46ee5 --- /dev/null +++ b/tests/common/common_result_samples/alter_data_set_result_error_uacc_secret.json @@ -0,0 +1,33 @@ +{ + "securityResult": { + "dataSet": { + "name": "ESWIFT.TEST.T113622.P3020470", + "operation": "set", + "generic": "no", + "requestId": "DatasetRequest", + "commands": [ + { + "safReturnCode": 8, + "returnCode": 16, + "reasonCode": 4, + "image": "ADDSD ('ESWIFT.TEST.T113622.P3020470')", + "messages": [ + "ICH09005I ESWIFT.TEST.T113622.P3020470 NOT FOUND IN CATALOG" + ] + }, + { + "safReturnCode": 8, + "returnCode": 16, + "reasonCode": 4, + "image": "ALTDSD ('ESWIFT.TEST.T113622.P3020470') UACC (********)", + "messages": [ + "ICH22001I ESWIFT.TEST.T113622.P3020470 NOT DEFINED TO RACF" + ] + } + ] + }, + "returnCode": 4, + "reasonCode": 0, + "runningUserid": "testuser" + } +} \ No newline at end of file diff --git a/tests/common/common_result_samples/alter_data_set_result_success_owner_secret.json b/tests/common/common_result_samples/alter_data_set_result_success_owner_secret.json new file mode 100644 index 00000000..3d93043a --- /dev/null +++ b/tests/common/common_result_samples/alter_data_set_result_success_owner_secret.json @@ -0,0 +1,24 @@ +{ + "securityResult": { + "dataSet": { + "name": "ESWIFT.TEST.T1136242.P3020470", + "operation": "set", + "generic": "no", + "requestId": "DatasetRequest", + "info": [ + "Definition exists. Add command skipped due to precheck option" + ], + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "ALTDSD ('ESWIFT.TEST.T1136242.P3020470') UACC (Read) OWNER (********)" + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} \ No newline at end of file diff --git a/tests/common/common_result_samples/alter_group_result_error_gid_secret.json b/tests/common/common_result_samples/alter_group_result_error_gid_secret.json new file mode 100644 index 00000000..33de23bd --- /dev/null +++ b/tests/common/common_result_samples/alter_group_result_error_gid_secret.json @@ -0,0 +1,28 @@ +{ + "securityResult": { + "group": { + "name": "testgrp0", + "operation": "set", + "requestId": "GroupRequest", + "info": [ + "Definition exists. Add command skipped due to precheck option" + ], + "commands": [ + { + "safReturnCode": 8, + "returnCode": 16, + "reasonCode": 8, + "image": "ALTGROUP TESTGRP0 OMVS (GID (********))", + "messages": [ + "REDACTED MESSAGE CONCERNING GID, REVIEW DOCUMENTATION OF IKJ56702I FOR MORE INFORMATION", + "REDACTED MESSAGE CONCERNING GID, REVIEW DOCUMENTATION OF IKJ56701I FOR MORE INFORMATION", + "REDACTED MESSAGE CONCERNING GID, REVIEW DOCUMENTATION OF IKJ56701I FOR MORE INFORMATION" + ] + } + ] + }, + "returnCode": 4, + "reasonCode": 0, + "runningUserid": "testuser" + } +} \ No newline at end of file diff --git a/tests/common/common_result_samples/alter_group_result_success_gid_secret.json b/tests/common/common_result_samples/alter_group_result_success_gid_secret.json new file mode 100644 index 00000000..98e53f28 --- /dev/null +++ b/tests/common/common_result_samples/alter_group_result_success_gid_secret.json @@ -0,0 +1,23 @@ +{ + "securityResult": { + "group": { + "name": "testgrp0", + "operation": "set", + "requestId": "GroupRequest", + "info": [ + "Definition exists. Add command skipped due to precheck option" + ], + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "ALTGROUP TESTGRP0 OMVS (GID (********))" + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} \ No newline at end of file diff --git a/tests/common/common_result_samples/alter_resource_overwrite_audit_result_success.xml b/tests/common/common_result_samples/alter_resource_overwrite_audit_result_success.xml new file mode 100644 index 00000000..b7e01456 --- /dev/null +++ b/tests/common/common_result_samples/alter_resource_overwrite_audit_result_success.xml @@ -0,0 +1,15 @@ + + + + Definition exists. Add command skipped due to precheck option + + 0 + 0 + 0 + RALTER ELIJTEST (TESTING) AUDIT( ALL (UPDATE )) + ICH11009I RACLISTED PROFILES FOR ELIJTEST WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED. + + + 0 + 0 + \ No newline at end of file diff --git a/tests/common/common_result_samples/alter_resource_result_error_uacc_secret.json b/tests/common/common_result_samples/alter_resource_result_error_uacc_secret.json new file mode 100644 index 00000000..45dfdafc --- /dev/null +++ b/tests/common/common_result_samples/alter_resource_result_error_uacc_secret.json @@ -0,0 +1,29 @@ +{ + "securityResult": { + "resource": { + "name": "TESTING", + "class": "ELIJTEST", + "operation": "set", + "requestId": "ResourceRequest", + "info": [ + "Definition exists. Add command skipped due to precheck option" + ], + "commands": [ + { + "safReturnCode": 8, + "returnCode": 16, + "reasonCode": 8, + "image": "RALTER ELIJTEST (TESTING) UACC (********) OWNER (eswift)", + "messages": [ + "REDACTED MESSAGE CONCERNING UNIVERSAL ACCESS, REVIEW DOCUMENTATION OF IKJ56702I FOR MORE INFORMATION", + "REDACTED MESSAGE CONCERNING UNIVERSAL ACCESS, REVIEW DOCUMENTATION OF IKJ56701I FOR MORE INFORMATION", + "IKJ56701I MISSING ALTER, CONTROL, UPDATE, READ, EXECUTE, OR NONE" + ] + } + ] + }, + "returnCode": 4, + "reasonCode": 0, + "runningUserid": "testuser" + } +} \ No newline at end of file diff --git a/tests/common/common_result_samples/alter_resource_result_success_audit_secret.json b/tests/common/common_result_samples/alter_resource_result_success_audit_secret.json new file mode 100644 index 00000000..0d456a97 --- /dev/null +++ b/tests/common/common_result_samples/alter_resource_result_success_audit_secret.json @@ -0,0 +1,29 @@ +{ + "step1": { + "securityResult": { + "resource": { + "name": "TESTING", + "class": "ELIJTEST", + "operation": "set", + "requestId": "ResourceRequest", + "info": [ + "Definition exists. Add command skipped due to precheck option" + ], + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "RALTER ELIJTEST (TESTING) AUDIT(********)", + "messages": [ + "ICH11009I RACLISTED PROFILES FOR ELIJTEST WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED." + ] + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } + } +} \ No newline at end of file diff --git a/tests/common/common_result_samples/alter_resource_result_success_owner_secret.json b/tests/common/common_result_samples/alter_resource_result_success_owner_secret.json new file mode 100644 index 00000000..bbe64c25 --- /dev/null +++ b/tests/common/common_result_samples/alter_resource_result_success_owner_secret.json @@ -0,0 +1,27 @@ +{ + "securityResult": { + "resource": { + "name": "TESTING", + "class": "ELIJTEST", + "operation": "set", + "requestId": "ResourceRequest", + "info": [ + "Definition exists. Add command skipped due to precheck option" + ], + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "RALTER ELIJTEST (TESTING) UACC (Read) OWNER (********)", + "messages": [ + "ICH11009I RACLISTED PROFILES FOR ELIJTEST WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED." + ] + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} \ No newline at end of file diff --git a/tests/user/user_result_samples/alter_user_result_error_uid_secret.json b/tests/common/common_result_samples/alter_user_result_error_uid_secret.json similarity index 66% rename from tests/user/user_result_samples/alter_user_result_error_uid_secret.json rename to tests/common/common_result_samples/alter_user_result_error_uid_secret.json index 7bfd2100..65939e45 100644 --- a/tests/user/user_result_samples/alter_user_result_error_uid_secret.json +++ b/tests/common/common_result_samples/alter_user_result_error_uid_secret.json @@ -14,9 +14,9 @@ "reasonCode": 8, "image": "ALTUSER SQUIDWRD NOSPECIAL OMVS (HOME ('/u/clarinet') NOPROGRAM UID (********))", "messages": [ - "IKJ56702I INVALID UID, 90000000000", - "IKJ56701I MISSING OMVS UID+", - "IKJ56701I MISSING OMVS USER ID (UID), 1-10 NUMERIC DIGITS" + "REDACTED MESSAGE CONCERNING UID, REVIEW DOCUMENTATION OF IKJ56702I FOR MORE INFORMATION", + "REDACTED MESSAGE CONCERNING UID, REVIEW DOCUMENTATION OF IKJ56701I FOR MORE INFORMATION", + "REDACTED MESSAGE CONCERNING UID, REVIEW DOCUMENTATION OF IKJ56701I FOR MORE INFORMATION" ] } ] diff --git a/tests/common/common_result_samples/alter_user_result_success_inst_data.xml b/tests/common/common_result_samples/alter_user_result_success_inst_data.xml new file mode 100644 index 00000000..341d1ff6 --- /dev/null +++ b/tests/common/common_result_samples/alter_user_result_success_inst_data.xml @@ -0,0 +1,14 @@ + + + + Definition exists. Add command skipped due to precheck option + + 0 + 0 + 0 + ALTUSER SQUIDWRD NAME ('Squidward') OWNER (leonard) SPECIAL DATA ('Test = Value; Other(stuff goes here)'')') OMVS (UID (2424) HOME ('/u/squidwrd') PROGRAM ('/bin/sh')) + + + 0 + 0 + \ No newline at end of file diff --git a/tests/common/common_result_samples/alter_user_result_success_inst_data_secret.json b/tests/common/common_result_samples/alter_user_result_success_inst_data_secret.json new file mode 100644 index 00000000..bed7176d --- /dev/null +++ b/tests/common/common_result_samples/alter_user_result_success_inst_data_secret.json @@ -0,0 +1,23 @@ +{ + "securityResult": { + "user": { + "name": "SQUIDWRD", + "operation": "set", + "requestId": "UserRequest", + "info": [ + "Definition exists. Add command skipped due to precheck option" + ], + "commands": [ + { + "safReturnCode": 0, + "returnCode": 0, + "reasonCode": 0, + "image": "ALTUSER SQUIDWRD NAME ('Squidward') OWNER (leonard) SPECIAL DATA ('********') OMVS (UID (2424) HOME ('/u/squidwrd') PROGRAM ('/bin/sh'))" + } + ] + }, + "returnCode": 0, + "reasonCode": 0, + "runningUserid": "testuser" + } +} \ No newline at end of file diff --git a/tests/user/user_result_samples/alter_user_result_extended_success.json b/tests/common/common_result_samples/alter_user_result_success_uid_secret.json similarity index 100% rename from tests/user/user_result_samples/alter_user_result_extended_success.json rename to tests/common/common_result_samples/alter_user_result_success_uid_secret.json diff --git a/tests/common/test_additional_secrets_redaction.py b/tests/common/test_additional_secrets_redaction.py new file mode 100644 index 00000000..4faa1a27 --- /dev/null +++ b/tests/common/test_additional_secrets_redaction.py @@ -0,0 +1,608 @@ +"""Test customizing security admin segment traits.""" + +import contextlib +import io +import re +import unittest +from unittest.mock import Mock, patch + +import __init__ + +import tests.common.test_common_constants as TestCommonConstants +import tests.data_set.test_data_set_constants as TestDataSetConstants +import tests.group.test_group_constants as TestGroupConstants +import tests.resource.test_resource_constants as TestResourceConstants +import tests.user.test_user_constants as TestUserConstants +from pyracf import ( + AccessAdmin, + ConnectionAdmin, + DataSetAdmin, + GroupAdmin, + ResourceAdmin, + SecurityRequestError, + SetroptsAdmin, + UserAdmin, +) + +# Resolves F401 +__init__ + + +class TestAdditionalSecretsResultRedaction(unittest.TestCase): + maxDiff = None + ansi_escape = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])") + + # ============================================================================ + # User Administration + # ============================================================================ + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_user_admin_custom_secret_redacted_on_success( + self, + call_racf_mock: Mock, + ): + user_admin = UserAdmin(additional_secret_traits=["omvs:uid"]) + call_racf_mock.side_effect = [ + TestUserConstants.TEST_EXTRACT_USER_RESULT_BASE_ONLY_SUCCESS_XML, + TestUserConstants.TEST_ALTER_USER_RESULT_EXTENDED_SUCCESS_XML, + ] + result = user_admin.alter( + "squidwrd", + traits=TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_EXTENDED, + ) + self.assertEqual( + result, + TestCommonConstants.TEST_ALTER_USER_RESULT_SUCCESS_UID_SECRET_DICTIONARY, + ) + self.assertNotIn( + str(TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_EXTENDED["omvs:uid"]), + str(result), + ) + + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_user_admin_custom_secret_redacted_on_error( + self, + call_racf_mock: Mock, + ): + user_admin = UserAdmin(additional_secret_traits=["omvs:uid"]) + call_racf_mock.side_effect = [ + TestUserConstants.TEST_EXTRACT_USER_RESULT_BASE_ONLY_SUCCESS_XML, + TestUserConstants.TEST_ALTER_USER_RESULT_ERROR_XML, + ] + with self.assertRaises(SecurityRequestError) as exception: + user_admin.alter( + "squidwrd", + traits=TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_UID_ERROR, + ) + self.assertEqual( + exception.exception.result, + TestCommonConstants.TEST_ALTER_USER_RESULT_ERROR_UID_SECRET_DICTIONARY, + ) + self.assertNotIn( + str(TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_UID_ERROR["omvs:uid"]), + str(exception.exception.result), + ) + + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_user_admin_custom_secret_redacted_when_complex_characters( + self, + call_racf_mock: Mock, + ): + user_admin = UserAdmin(additional_secret_traits=["base:installation_data"]) + call_racf_mock.side_effect = [ + TestUserConstants.TEST_EXTRACT_USER_RESULT_BASE_ONLY_SUCCESS_XML, + TestCommonConstants.TEST_ALTER_USER_RESULT_INST_DATA_SUCCESS_XML, + ] + result = user_admin.alter( + "squidwrd", + traits=TestCommonConstants.TEST_ALTER_USER_REQUEST_TRAITS_INST_DATA, + ) + self.assertEqual( + result, + TestCommonConstants.TEST_ALTER_USER_RESULT_SUCCESS_INST_DATA_SECRET_DICTIONARY, + ) + self.assertNotIn( + TestCommonConstants.TEST_ALTER_USER_REQUEST_TRAITS_INST_DATA[ + "base:installation_data" + ], + str(result), + ) + + def test_user_admin_custom_secret_redacted_request(self): + user_admin = UserAdmin( + additional_secret_traits=["omvs:uid"], generate_requests_only=True + ) + result = user_admin.alter( + "squidwrd", + traits=TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_EXTENDED, + ) + self.assertNotIn( + str(TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_EXTENDED["omvs:uid"]), + str(result), + ) + + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_alter_user_request_debug_log_additional_secret_added_get_redacted_on_success( + self, + call_racf_mock: Mock, + ): + user_admin = UserAdmin(debug=True, additional_secret_traits=["omvs:uid"]) + call_racf_mock.side_effect = [ + TestUserConstants.TEST_EXTRACT_USER_RESULT_BASE_ONLY_SUCCESS_XML, + TestUserConstants.TEST_ALTER_USER_RESULT_EXTENDED_SUCCESS_XML, + ] + stdout = io.StringIO() + with contextlib.redirect_stdout(stdout): + user_admin.alter( + "squidwrd", + traits=TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_EXTENDED, + ) + success_log = self.ansi_escape.sub("", stdout.getvalue()) + self.assertEqual( + success_log, + TestCommonConstants.TEST_ALTER_USER_ADDITIONAL_SECRET_ADDED_SUCCESS_LOG, + ) + self.assertNotIn( + str(TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_EXTENDED["omvs:uid"]), + success_log, + ) + + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_alter_user_request_debug_log_additional_secret_added_get_redacted_on_error( + self, + call_racf_mock: Mock, + ): + user_admin = UserAdmin(debug=True, additional_secret_traits=["omvs:uid"]) + call_racf_mock.side_effect = [ + TestUserConstants.TEST_EXTRACT_USER_RESULT_BASE_ONLY_SUCCESS_XML, + TestUserConstants.TEST_ALTER_USER_RESULT_ERROR_XML, + ] + stdout = io.StringIO() + with contextlib.redirect_stdout(stdout): + try: + user_admin.alter( + "squidwrd", + traits=TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_UID_ERROR, + ) + except SecurityRequestError: + pass + error_log = self.ansi_escape.sub("", stdout.getvalue()) + self.assertEqual( + error_log, + TestCommonConstants.TEST_ALTER_USER_ADDITIONAL_SECRET_ADDED_ERROR_LOG, + ) + self.assertNotIn( + str(TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_UID_ERROR["omvs:uid"]), + error_log, + ) + + # ============================================================================ + # Group Administration + # ============================================================================ + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_group_admin_custom_secret_redacted_on_success( + self, + call_racf_mock: Mock, + ): + group_admin = GroupAdmin(additional_secret_traits=["omvs:gid"]) + call_racf_mock.side_effect = [ + TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_ONLY_SUCCESS_XML, + TestGroupConstants.TEST_ALTER_GROUP_RESULT_SUCCESS_XML, + ] + result = group_admin.alter( + "testgrp0", + traits=TestGroupConstants.TEST_ALTER_GROUP_REQUEST_TRAITS, + ) + self.assertEqual( + result, + TestCommonConstants.TEST_ALTER_GROUP_RESULT_SUCCESS_GID_SECRET_DICTIONARY, + ) + self.assertNotIn( + str(TestGroupConstants.TEST_ALTER_GROUP_REQUEST_TRAITS["omvs:gid"]), + str(result), + ) + + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_group_admin_custom_secret_redacted_on_error( + self, + call_racf_mock: Mock, + ): + group_admin = GroupAdmin(additional_secret_traits=["omvs:gid"]) + call_racf_mock.side_effect = [ + TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_ONLY_SUCCESS_XML, + TestGroupConstants.TEST_ALTER_GROUP_RESULT_ERROR_XML, + ] + with self.assertRaises(SecurityRequestError) as exception: + group_admin.alter( + "testgrp0", + traits=TestGroupConstants.TEST_ALTER_GROUP_REQUEST_ERROR_TRAITS, + ) + self.assertEqual( + exception.exception.result, + TestCommonConstants.TEST_ALTER_GROUP_RESULT_ERROR_GID_SECRET_DICTIONARY, + ) + self.assertNotIn( + str(TestGroupConstants.TEST_ALTER_GROUP_REQUEST_ERROR_TRAITS["omvs:gid"]), + str(exception.exception.result), + ) + + def test_group_admin_custom_secret_redacted_request(self): + group_admin = GroupAdmin( + additional_secret_traits=["omvs:gid"], generate_requests_only=True + ) + result = group_admin.alter( + "squidwrd", + traits=TestGroupConstants.TEST_ALTER_GROUP_REQUEST_TRAITS, + ) + self.assertNotIn( + str(TestGroupConstants.TEST_ALTER_GROUP_REQUEST_TRAITS["omvs:gid"]), + str(result), + ) + + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_alter_group_request_debug_log_additional_secret_added_get_redacted_on_success( + self, + call_racf_mock: Mock, + ): + group_admin = GroupAdmin(debug=True, additional_secret_traits=["omvs:gid"]) + call_racf_mock.side_effect = [ + TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_ONLY_SUCCESS_XML, + TestGroupConstants.TEST_ALTER_GROUP_RESULT_SUCCESS_XML, + ] + stdout = io.StringIO() + with contextlib.redirect_stdout(stdout): + group_admin.alter( + "testgrp0", + traits=TestGroupConstants.TEST_ALTER_GROUP_REQUEST_TRAITS, + ) + success_log = self.ansi_escape.sub("", stdout.getvalue()) + self.assertEqual( + success_log, + TestCommonConstants.TEST_ALTER_GROUP_ADDITIONAL_SECRET_ADDED_SUCCESS_LOG, + ) + self.assertNotIn( + str(TestGroupConstants.TEST_ALTER_GROUP_REQUEST_TRAITS["omvs:gid"]), + success_log, + ) + + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_alter_group_request_debug_log_additional_secret_added_get_redacted_on_error( + self, + call_racf_mock: Mock, + ): + group_admin = GroupAdmin(debug=True, additional_secret_traits=["omvs:gid"]) + call_racf_mock.side_effect = [ + TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_ONLY_SUCCESS_XML, + TestGroupConstants.TEST_ALTER_GROUP_RESULT_ERROR_XML, + ] + stdout = io.StringIO() + with contextlib.redirect_stdout(stdout): + try: + group_admin.alter( + "testgrp0", + traits=TestGroupConstants.TEST_ALTER_GROUP_REQUEST_ERROR_TRAITS, + ) + except SecurityRequestError: + pass + error_log = self.ansi_escape.sub("", stdout.getvalue()) + self.assertEqual( + error_log, + TestCommonConstants.TEST_ALTER_GROUP_ADDITIONAL_SECRET_ADDED_ERROR_LOG, + ) + self.assertNotIn( + str(TestGroupConstants.TEST_ALTER_GROUP_REQUEST_ERROR_TRAITS["omvs:gid"]), + error_log, + ) + + # ============================================================================ + # General Resource Profile Administration + # ============================================================================ + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_resource_admin_custom_secret_redacted_on_success( + self, + call_racf_mock: Mock, + ): + resource_admin = ResourceAdmin(additional_secret_traits=["base:owner"]) + call_racf_mock.side_effect = [ + TestResourceConstants.TEST_EXTRACT_RESOURCE_RESULT_BASE_SUCCESS_XML, + TestResourceConstants.TEST_ALTER_RESOURCE_RESULT_SUCCESS_XML, + ] + result = resource_admin.alter( + "TESTING", + "ELIJTEST", + traits=TestResourceConstants.TEST_ALTER_RESOURCE_REQUEST_TRAITS, + ) + self.assertEqual( + result, + TestCommonConstants.TEST_ALTER_RESOURCE_RESULT_SUCCESS_OWNER_SECRET_DICTIONARY, + ) + self.assertNotIn( + TestResourceConstants.TEST_ALTER_RESOURCE_REQUEST_TRAITS["base:owner"], + str(result), + ) + + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_resource_admin_custom_mapped_secret_redacted_on_success( + self, + call_racf_mock: Mock, + ): + resource_admin = ResourceAdmin(additional_secret_traits=["base:audit_update"]) + call_racf_mock.side_effect = [ + TestResourceConstants.TEST_EXTRACT_RESOURCE_RESULT_BASE_SUCCESS_XML, + TestCommonConstants.TEST_ALTER_RESOURCE_OVERWRITE_AUDIT_RESULT_SUCCESS_XML, + ] + result = resource_admin.overwrite_audit_rules_by_access_level( + "TESTING", + "ELIJTEST", + update="ALL", + ) + self.assertEqual( + result, + TestCommonConstants.TEST_ALTER_RESOURCE_RESULT_SUCCESS_AUDIT_SECRET_DICTIONARY, + ) + self.assertNotIn( + "ALL", + str(result), + ) + + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_resource_admin_custom_secret_redacted_on_error( + self, + call_racf_mock: Mock, + ): + secret_trait = "base:universal_access" + resource_admin = ResourceAdmin(additional_secret_traits=[secret_trait]) + call_racf_mock.side_effect = [ + TestResourceConstants.TEST_EXTRACT_RESOURCE_RESULT_BASE_SUCCESS_XML, + TestResourceConstants.TEST_ALTER_RESOURCE_RESULT_ERROR_XML, + ] + with self.assertRaises(SecurityRequestError) as exception: + resource_admin.alter( + "TESTING", + "ELIJTEST", + traits=TestResourceConstants.TEST_ALTER_RESOURCE_REQUEST_ERROR_TRAITS, + ) + self.assertEqual( + exception.exception.result, + TestCommonConstants.TEST_ALTER_RESOURCE_RESULT_ERROR_UACC_SECRET_DICTIONARY, + ) + self.assertNotIn( + str( + TestResourceConstants.TEST_ALTER_RESOURCE_REQUEST_ERROR_TRAITS[ + secret_trait + ] + ), + str(exception.exception.result), + ) + + def test_resource_admin_custom_secret_redacted_request(self): + resource_admin = ResourceAdmin( + additional_secret_traits=["base:owner"], generate_requests_only=True + ) + result = resource_admin.alter( + "TESTING", + "ELIJTEST", + traits=TestResourceConstants.TEST_ALTER_RESOURCE_REQUEST_TRAITS, + ) + self.assertNotIn( + TestResourceConstants.TEST_ALTER_RESOURCE_REQUEST_TRAITS["base:owner"], + str(result), + ) + + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_alter_resource_request_debug_log_additional_secret_added_get_redacted_on_success( + self, + call_racf_mock: Mock, + ): + resource_admin = ResourceAdmin( + debug=True, additional_secret_traits=["base:owner"] + ) + call_racf_mock.side_effect = [ + TestResourceConstants.TEST_EXTRACT_RESOURCE_RESULT_BASE_SUCCESS_XML, + TestResourceConstants.TEST_ALTER_RESOURCE_RESULT_SUCCESS_XML, + ] + stdout = io.StringIO() + with contextlib.redirect_stdout(stdout): + resource_admin.alter( + "TESTING", + "ELIJTEST", + traits=TestResourceConstants.TEST_ALTER_RESOURCE_REQUEST_TRAITS, + ) + success_log = self.ansi_escape.sub("", stdout.getvalue()) + self.assertEqual( + success_log, + TestCommonConstants.TEST_ALTER_RESOURCE_ADDITIONAL_SECRET_ADDED_SUCCESS_LOG, + ) + # No AssertNotInTest because Equal test to log is sufficient and value technically appears + + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_alter_resource_request_debug_log_additional_secret_added_get_redacted_on_error( + self, + call_racf_mock: Mock, + ): + secret_trait = "base:universal_access" + resource_admin = ResourceAdmin( + debug=True, additional_secret_traits=[secret_trait] + ) + call_racf_mock.side_effect = [ + TestResourceConstants.TEST_EXTRACT_RESOURCE_RESULT_BASE_SUCCESS_XML, + TestResourceConstants.TEST_ALTER_RESOURCE_RESULT_ERROR_XML, + ] + stdout = io.StringIO() + with contextlib.redirect_stdout(stdout): + try: + resource_admin.alter( + "TESTING", + "ELIJTEST", + traits=TestResourceConstants.TEST_ALTER_RESOURCE_REQUEST_ERROR_TRAITS, + ) + except SecurityRequestError: + pass + error_log = self.ansi_escape.sub("", stdout.getvalue()) + self.assertEqual( + error_log, + TestCommonConstants.TEST_ALTER_RESOURCE_ADDITIONAL_SECRET_ADDED_ERROR_LOG, + ) + # No AssertNotInTest because Equal test to log is sufficient and value technically appears + + # ============================================================================ + # Data Set Profile Administration + # ============================================================================ + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_data_set_admin_custom_secret_redacted_on_success( + self, + call_racf_mock: Mock, + ): + data_set_admin = DataSetAdmin(additional_secret_traits=["base:owner"]) + call_racf_mock.side_effect = [ + TestDataSetConstants.TEST_EXTRACT_DATA_SET_RESULT_BASE_ONLY_SUCCESS_XML, + TestDataSetConstants.TEST_ALTER_DATA_SET_RESULT_SUCCESS_XML, + ] + result = data_set_admin.alter( + "ESWIFT.TEST.T1136242.P3020470", + traits=TestDataSetConstants.TEST_ALTER_DATA_SET_REQUEST_TRAITS, + ) + self.assertEqual( + result, + TestCommonConstants.TEST_ALTER_DATA_SET_RESULT_SUCCESS_OWNER_SECRET_DICTIONARY, + ) + self.assertNotIn( + TestDataSetConstants.TEST_ALTER_DATA_SET_REQUEST_TRAITS["base:owner"], + str(result), + ) + + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_data_set_admin_custom_secret_redacted_on_error( + self, + call_racf_mock: Mock, + ): + secret_trait = "base:universal_access" + data_set_admin = DataSetAdmin(additional_secret_traits=[secret_trait]) + call_racf_mock.side_effect = [ + TestDataSetConstants.TEST_EXTRACT_DATA_SET_RESULT_BASE_ONLY_SUCCESS_XML, + TestDataSetConstants.TEST_ALTER_DATA_SET_RESULT_ERROR_XML, + ] + with self.assertRaises(SecurityRequestError) as exception: + data_set_admin.alter( + "ESWIFT.TEST.T1136242.P3020470", + traits=TestDataSetConstants.TEST_ALTER_DATA_SET_REQUEST_TRAITS, + ) + self.assertEqual( + exception.exception.result, + TestCommonConstants.TEST_ALTER_DATA_SET_RESULT_ERROR_UACC_SECRET_DICTIONARY, + ) + self.assertNotIn( + TestDataSetConstants.TEST_ALTER_DATA_SET_REQUEST_TRAITS[secret_trait], + str(exception.exception.result), + ) + + def test_data_set_admin_custom_secret_redacted_request(self): + data_set_admin = DataSetAdmin( + additional_secret_traits=["base:owner"], generate_requests_only=True + ) + result = data_set_admin.alter( + "ESWIFT.TEST.T1136242.P3020470", + traits=TestDataSetConstants.TEST_ALTER_DATA_SET_REQUEST_TRAITS, + ) + self.assertNotIn( + TestDataSetConstants.TEST_ALTER_DATA_SET_REQUEST_TRAITS["base:owner"], + str(result), + ) + + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_alter_data_set_request_debug_log_additional_secret_added_get_redacted_on_success( + self, + call_racf_mock: Mock, + ): + data_set_admin = DataSetAdmin( + debug=True, additional_secret_traits=["base:owner"] + ) + call_racf_mock.side_effect = [ + TestDataSetConstants.TEST_EXTRACT_DATA_SET_RESULT_BASE_ONLY_SUCCESS_XML, + TestDataSetConstants.TEST_ALTER_DATA_SET_RESULT_SUCCESS_XML, + ] + stdout = io.StringIO() + with contextlib.redirect_stdout(stdout): + data_set_admin.alter( + "ESWIFT.TEST.T1136242.P3020470", + traits=TestDataSetConstants.TEST_ALTER_DATA_SET_REQUEST_TRAITS, + ) + success_log = self.ansi_escape.sub("", stdout.getvalue()) + self.assertEqual( + success_log, + TestCommonConstants.TEST_ALTER_DATA_SET_ADDITIONAL_SECRET_ADDED_SUCCESS_LOG, + ) + # No AssertNotInTest because Equal test to log is sufficient and value technically appears + + @patch("pyracf.common.irrsmo00.IRRSMO00.call_racf") + def test_alter_data_set_request_debug_log_additional_secret_added_get_redacted_on_error( + self, + call_racf_mock: Mock, + ): + secret_trait = "base:universal_access" + data_set_admin = DataSetAdmin( + debug=True, additional_secret_traits=[secret_trait] + ) + call_racf_mock.side_effect = [ + TestDataSetConstants.TEST_EXTRACT_DATA_SET_RESULT_BASE_ONLY_SUCCESS_XML, + TestDataSetConstants.TEST_ALTER_DATA_SET_RESULT_ERROR_XML, + ] + stdout = io.StringIO() + with contextlib.redirect_stdout(stdout): + try: + data_set_admin.alter( + "ESWIFT.TEST.T1136242.P3020470", + traits=TestDataSetConstants.TEST_ALTER_DATA_SET_REQUEST_ERROR_TRAITS, + ) + except SecurityRequestError: + pass + error_log = self.ansi_escape.sub("", stdout.getvalue()) + self.assertEqual( + error_log, + TestCommonConstants.TEST_ALTER_DATA_SET_ADDITIONAL_SECRET_ADDED_ERROR_LOG, + ) + # No AssertNotInTest because Equal test to log is sufficient and value technically appears + + # ============================================================================ + # Generic Testing for all Admin Types + # ============================================================================ + def test_incompatible_admin_custom_secret_redaction_error(self): + admin_types = [ + (AccessAdmin, "permission"), + (ConnectionAdmin, "groupConnection"), + (SetroptsAdmin, "systemSettings"), + ] + for admin_type, profile_type in admin_types: + with self.assertRaises(ValueError) as exception: + admin_type(additional_secret_traits=["base:name"]) + self.assertEqual( + str(exception.exception), + f"Cannot add specified additional secrets to '{profile_type}' object.\n" + f"'{profile_type}' object does not support additional secrets redaction.", + ) + + def test_compatible_admin_incompatible_traits_custom_secret_redaction_error(self): + admin_types = [ + (UserAdmin, "user"), + (GroupAdmin, "group"), + (ResourceAdmin, "resource"), + (DataSetAdmin, "dataSet"), + ] + incompatible_traits = [ + "nosegment", + "incompatible:trait", + "omvs:name", + ] + incompatible_traits_text = "\n".join( + [ + f"Could not map {trait} to a valid segment trait." + for trait in incompatible_traits + ] + ) + for admin_type, profile_type in admin_types: + with self.assertRaises(ValueError) as exception: + admin_type(additional_secret_traits=incompatible_traits) + self.assertEqual( + str(exception.exception), + f"Cannot add specified additional secrets to '{profile_type}' object.\n" + + incompatible_traits_text, + ) diff --git a/tests/common/test_common_constants.py b/tests/common/test_common_constants.py index 7a0c83ff..5ff149bc 100644 --- a/tests/common/test_common_constants.py +++ b/tests/common/test_common_constants.py @@ -97,6 +97,83 @@ def get_sample(sample_file: str) -> Union[str, bytes]: "extract_user_result_base_omvs_csdata_success.json" ) +# ============================================================================ +# Additional Secrets Redaction +# ============================================================================ + +TEST_ALTER_USER_REQUEST_TRAITS_INST_DATA = { + "base:name": "Squidward", + "base:owner": "leonard", + "base:special": True, + "omvs:uid": "2424", + "omvs:home_directory": "/u/squidwrd", + "omvs:default_shell": "/bin/sh", + "base:installation_data": "Test = Value; Other(stuff goes here)'')", +} +TEST_ALTER_USER_RESULT_SUCCESS_UID_SECRET_DICTIONARY = get_sample( + "alter_user_result_success_uid_secret.json" +) +TEST_ALTER_USER_RESULT_ERROR_UID_SECRET_DICTIONARY = get_sample( + "alter_user_result_error_uid_secret.json" +) +TEST_ALTER_USER_RESULT_INST_DATA_SUCCESS_XML = get_sample( + "alter_user_result_success_inst_data.xml" +) +TEST_ALTER_USER_RESULT_SUCCESS_INST_DATA_SECRET_DICTIONARY = get_sample( + "alter_user_result_success_inst_data_secret.json" +) +TEST_ALTER_USER_ADDITIONAL_SECRET_ADDED_SUCCESS_LOG = get_sample( + "alter_user_additional_secret_added_success.log" +) +TEST_ALTER_USER_ADDITIONAL_SECRET_ADDED_ERROR_LOG = get_sample( + "alter_user_additional_secret_added_error.log" +) + +TEST_ALTER_DATA_SET_RESULT_SUCCESS_OWNER_SECRET_DICTIONARY = get_sample( + "alter_data_set_result_success_owner_secret.json" +) +TEST_ALTER_DATA_SET_RESULT_ERROR_UACC_SECRET_DICTIONARY = get_sample( + "alter_data_set_result_error_uacc_secret.json" +) +TEST_ALTER_DATA_SET_ADDITIONAL_SECRET_ADDED_SUCCESS_LOG = get_sample( + "alter_data_set_additional_secret_added_success.log" +) +TEST_ALTER_DATA_SET_ADDITIONAL_SECRET_ADDED_ERROR_LOG = get_sample( + "alter_data_set_additional_secret_added_error.log" +) + +TEST_ALTER_GROUP_RESULT_SUCCESS_GID_SECRET_DICTIONARY = get_sample( + "alter_group_result_success_gid_secret.json" +) +TEST_ALTER_GROUP_RESULT_ERROR_GID_SECRET_DICTIONARY = get_sample( + "alter_group_result_error_gid_secret.json" +) +TEST_ALTER_GROUP_ADDITIONAL_SECRET_ADDED_SUCCESS_LOG = get_sample( + "alter_group_additional_secret_added_success.log" +) +TEST_ALTER_GROUP_ADDITIONAL_SECRET_ADDED_ERROR_LOG = get_sample( + "alter_group_additional_secret_added_error.log" +) + +TEST_ALTER_RESOURCE_OVERWRITE_AUDIT_RESULT_SUCCESS_XML = get_sample( + "alter_resource_overwrite_audit_result_success.xml" +) +TEST_ALTER_RESOURCE_RESULT_SUCCESS_OWNER_SECRET_DICTIONARY = get_sample( + "alter_resource_result_success_owner_secret.json" +) +TEST_ALTER_RESOURCE_RESULT_SUCCESS_AUDIT_SECRET_DICTIONARY = get_sample( + "alter_resource_result_success_audit_secret.json" +) +TEST_ALTER_RESOURCE_RESULT_ERROR_UACC_SECRET_DICTIONARY = get_sample( + "alter_resource_result_error_uacc_secret.json" +) +TEST_ALTER_RESOURCE_ADDITIONAL_SECRET_ADDED_SUCCESS_LOG = get_sample( + "alter_resource_additional_secret_added_success.log" +) +TEST_ALTER_RESOURCE_ADDITIONAL_SECRET_ADDED_ERROR_LOG = get_sample( + "alter_resource_additional_secret_added_error.log" +) + # ============================================================================ # Run As UserId # ============================================================================ diff --git a/tests/connection/connection_log_samples/connect_connection_error.log b/tests/connection/connection_log_samples/connect_connection_error.log index 1563c4bc..74d05a20 100644 --- a/tests/connection/connection_log_samples/connect_connection_error.log +++ b/tests/connection/connection_log_samples/connect_connection_error.log @@ -24,7 +24,7 @@ - + @@ -38,7 +38,7 @@ - + 8 16 @@ -62,7 +62,7 @@ "securityResult": { "groupConnection": { "name": "ESWIFT", - "group": "TESTGRP0", + "group": "testgrp0", "operation": "set", "requestId": "ConnectionRequest", "commands": [ diff --git a/tests/connection/connection_log_samples/connect_connection_success.log b/tests/connection/connection_log_samples/connect_connection_success.log index c10b7e01..215b104a 100644 --- a/tests/connection/connection_log_samples/connect_connection_success.log +++ b/tests/connection/connection_log_samples/connect_connection_success.log @@ -24,7 +24,7 @@ - + @@ -38,7 +38,7 @@ - + 0 0 @@ -60,7 +60,7 @@ "securityResult": { "groupConnection": { "name": "ESWIFT", - "group": "TESTGRP0", + "group": "testgrp0", "operation": "set", "requestId": "ConnectionRequest", "commands": [ diff --git a/tests/connection/connection_request_samples/connect_connection_request.xml b/tests/connection/connection_request_samples/connect_connection_request.xml index f6c274d1..d7eda207 100644 --- a/tests/connection/connection_request_samples/connect_connection_request.xml +++ b/tests/connection/connection_request_samples/connect_connection_request.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/connection/connection_request_samples/connection_give_group_access_attribute.xml b/tests/connection/connection_request_samples/connection_give_group_access_attribute.xml index e5d15a33..f37d69c9 100644 --- a/tests/connection/connection_request_samples/connection_give_group_access_attribute.xml +++ b/tests/connection/connection_request_samples/connection_give_group_access_attribute.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/tests/connection/connection_request_samples/connection_give_group_auditor_authority.xml b/tests/connection/connection_request_samples/connection_give_group_auditor_authority.xml index 8bb8b7af..9c0a48c0 100644 --- a/tests/connection/connection_request_samples/connection_give_group_auditor_authority.xml +++ b/tests/connection/connection_request_samples/connection_give_group_auditor_authority.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/tests/connection/connection_request_samples/connection_give_group_operations_authority.xml b/tests/connection/connection_request_samples/connection_give_group_operations_authority.xml index cfaf13fa..b2b01bb5 100644 --- a/tests/connection/connection_request_samples/connection_give_group_operations_authority.xml +++ b/tests/connection/connection_request_samples/connection_give_group_operations_authority.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/tests/connection/connection_request_samples/connection_give_group_special_authority.xml b/tests/connection/connection_request_samples/connection_give_group_special_authority.xml index b39b16c9..4b4d05eb 100644 --- a/tests/connection/connection_request_samples/connection_give_group_special_authority.xml +++ b/tests/connection/connection_request_samples/connection_give_group_special_authority.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/tests/connection/connection_request_samples/connection_take_away_group_access_attribute.xml b/tests/connection/connection_request_samples/connection_take_away_group_access_attribute.xml index 622e3808..0af86fe9 100644 --- a/tests/connection/connection_request_samples/connection_take_away_group_access_attribute.xml +++ b/tests/connection/connection_request_samples/connection_take_away_group_access_attribute.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/tests/connection/connection_request_samples/connection_take_away_group_auditor_authority.xml b/tests/connection/connection_request_samples/connection_take_away_group_auditor_authority.xml index a5d35c65..17cee5c5 100644 --- a/tests/connection/connection_request_samples/connection_take_away_group_auditor_authority.xml +++ b/tests/connection/connection_request_samples/connection_take_away_group_auditor_authority.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/tests/connection/connection_request_samples/connection_take_away_group_operations_authority.xml b/tests/connection/connection_request_samples/connection_take_away_group_operations_authority.xml index de82369e..99380b80 100644 --- a/tests/connection/connection_request_samples/connection_take_away_group_operations_authority.xml +++ b/tests/connection/connection_request_samples/connection_take_away_group_operations_authority.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/tests/connection/connection_request_samples/connection_take_away_group_special_authority.xml b/tests/connection/connection_request_samples/connection_take_away_group_special_authority.xml index 330c1e12..c7b3c7d9 100644 --- a/tests/connection/connection_request_samples/connection_take_away_group_special_authority.xml +++ b/tests/connection/connection_request_samples/connection_take_away_group_special_authority.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/tests/connection/connection_request_samples/delete_connection_request.xml b/tests/connection/connection_request_samples/delete_connection_request.xml index 94e897e7..97ccba22 100644 --- a/tests/connection/connection_request_samples/delete_connection_request.xml +++ b/tests/connection/connection_request_samples/delete_connection_request.xml @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/tests/connection/connection_result_samples/connect_connection_result_error.json b/tests/connection/connection_result_samples/connect_connection_result_error.json index fe180153..ada4d6f9 100644 --- a/tests/connection/connection_result_samples/connect_connection_result_error.json +++ b/tests/connection/connection_result_samples/connect_connection_result_error.json @@ -2,7 +2,7 @@ "securityResult": { "groupConnection": { "name": "ESWIFT", - "group": "TESTGRP0", + "group": "testgrp0", "operation": "set", "requestId": "ConnectionRequest", "commands": [ diff --git a/tests/connection/connection_result_samples/connect_connection_result_error.xml b/tests/connection/connection_result_samples/connect_connection_result_error.xml index 4c16be89..30f46941 100644 --- a/tests/connection/connection_result_samples/connect_connection_result_error.xml +++ b/tests/connection/connection_result_samples/connect_connection_result_error.xml @@ -1,6 +1,6 @@ - + 8 16 diff --git a/tests/connection/connection_result_samples/connect_connection_result_success.json b/tests/connection/connection_result_samples/connect_connection_result_success.json index 75d10ecc..62a670fc 100644 --- a/tests/connection/connection_result_samples/connect_connection_result_success.json +++ b/tests/connection/connection_result_samples/connect_connection_result_success.json @@ -2,7 +2,7 @@ "securityResult": { "groupConnection": { "name": "ESWIFT", - "group": "TESTGRP0", + "group": "testgrp0", "operation": "set", "requestId": "ConnectionRequest", "commands": [ diff --git a/tests/connection/connection_result_samples/connect_connection_result_success.xml b/tests/connection/connection_result_samples/connect_connection_result_success.xml index 82e960db..786d994a 100644 --- a/tests/connection/connection_result_samples/connect_connection_result_success.xml +++ b/tests/connection/connection_result_samples/connect_connection_result_success.xml @@ -1,6 +1,6 @@ - + 0 0 diff --git a/tests/connection/connection_result_samples/delete_connection_result_error.json b/tests/connection/connection_result_samples/delete_connection_result_error.json index 193ad0f6..6b938059 100644 --- a/tests/connection/connection_result_samples/delete_connection_result_error.json +++ b/tests/connection/connection_result_samples/delete_connection_result_error.json @@ -2,7 +2,7 @@ "securityResult": { "groupConnection": { "name": "ESWIFT", - "group": "TESTGRP0", + "group": "testgrp0", "operation": "del", "requestId": "ConnectionRequest", "commands": [ diff --git a/tests/connection/connection_result_samples/delete_connection_result_error.xml b/tests/connection/connection_result_samples/delete_connection_result_error.xml index f6ba65ef..fee101db 100644 --- a/tests/connection/connection_result_samples/delete_connection_result_error.xml +++ b/tests/connection/connection_result_samples/delete_connection_result_error.xml @@ -1,6 +1,6 @@ - + 8 16 diff --git a/tests/connection/connection_result_samples/delete_connection_result_success.json b/tests/connection/connection_result_samples/delete_connection_result_success.json index 0b4a3d20..f9f29a19 100644 --- a/tests/connection/connection_result_samples/delete_connection_result_success.json +++ b/tests/connection/connection_result_samples/delete_connection_result_success.json @@ -2,7 +2,7 @@ "securityResult": { "groupConnection": { "name": "ESWIFT", - "group": "TESTGRP0", + "group": "testgrp0", "operation": "del", "requestId": "ConnectionRequest", "commands": [ diff --git a/tests/connection/connection_result_samples/delete_connection_result_success.xml b/tests/connection/connection_result_samples/delete_connection_result_success.xml index 38174748..7b4eb078 100644 --- a/tests/connection/connection_result_samples/delete_connection_result_success.xml +++ b/tests/connection/connection_result_samples/delete_connection_result_success.xml @@ -1,6 +1,6 @@ - + 0 0 diff --git a/tests/connection/test_connection_debug_logging.py b/tests/connection/test_connection_debug_logging.py index ea9b80c1..fbfc0a33 100644 --- a/tests/connection/test_connection_debug_logging.py +++ b/tests/connection/test_connection_debug_logging.py @@ -35,7 +35,7 @@ def test_connect_connection_request_debug_log_works_on_success( with contextlib.redirect_stdout(stdout): self.connection_admin.connect( "ESWIFT", - "TESTGRP0", + "testgrp0", traits=TestConnectionConstants.TEST_CONNECT_CONNECTION_REQUEST_TRAITS, ), success_log = self.ansi_escape.sub("", stdout.getvalue()) @@ -55,7 +55,7 @@ def test_connect_connection_request_debug_log_works_on_error( try: self.connection_admin.connect( "ESWIFT", - "TESTGRP0", + "testgrp0", traits=TestConnectionConstants.TEST_CONNECT_CONNECTION_REQUEST_TRAITS, ), except SecurityRequestError: diff --git a/tests/connection/test_connection_request_builder.py b/tests/connection/test_connection_request_builder.py index 620bf1de..a80e2ba7 100644 --- a/tests/connection/test_connection_request_builder.py +++ b/tests/connection/test_connection_request_builder.py @@ -18,7 +18,7 @@ class TestConnectionRequestBuilder(unittest.TestCase): def test_connection_admin_build_connect_connection_request(self): result = self.connection_admin.connect( "ESWIFT", - "TESTGRP0", + "testgrp0", traits=TestConnectionConstants.TEST_CONNECT_CONNECTION_REQUEST_TRAITS, ) self.assertEqual( @@ -26,7 +26,7 @@ def test_connection_admin_build_connect_connection_request(self): ) def test_connection_admin_build_delete_connection_request(self): - result = self.connection_admin.delete("ESWIFT", "TESTGRP0") + result = self.connection_admin.delete("ESWIFT", "testgrp0") self.assertEqual( result, TestConnectionConstants.TEST_DELETE_CONNECTION_REQUEST_XML ) diff --git a/tests/connection/test_connection_result_parser.py b/tests/connection/test_connection_result_parser.py index 0df0e9f8..dd21d1b1 100644 --- a/tests/connection/test_connection_result_parser.py +++ b/tests/connection/test_connection_result_parser.py @@ -30,7 +30,7 @@ def test_connection_admin_can_parse_connect_connection_success_xml( self.assertEqual( self.connection_admin.connect( "ESWIFT", - "TESTGRP0", + "testgrp0", traits=TestConnectionConstants.TEST_CONNECT_CONNECTION_REQUEST_TRAITS, ), TestConnectionConstants.TEST_CONNECT_CONNECTION_RESULT_SUCCESS_DICTIONARY, @@ -47,7 +47,7 @@ def test_connection_admin_can_parse_connect_connection_error_xml( with self.assertRaises(SecurityRequestError) as exception: self.connection_admin.connect( "ESWIFT", - "TESTGRP0", + "testgrp0", traits=TestConnectionConstants.TEST_CONNECT_CONNECTION_REQUEST_TRAITS, ) self.assertEqual( @@ -66,7 +66,7 @@ def test_connection_admin_can_parse_delete_connection_success_xml( TestConnectionConstants.TEST_DELETE_CONNECTION_RESULT_SUCCESS_XML ) self.assertEqual( - self.connection_admin.delete("ESWIFT", "TESTGRP0"), + self.connection_admin.delete("ESWIFT", "testgrp0"), TestConnectionConstants.TEST_DELETE_CONNECTION_RESULT_SUCCESS_DICTIONARY, ) @@ -79,7 +79,7 @@ def test_connection_admin_can_parse_delete_connection_error_xml( TestConnectionConstants.TEST_DELETE_CONNECTION_RESULT_ERROR_XML ) with self.assertRaises(SecurityRequestError) as exception: - self.connection_admin.delete("ESWIFT", "TESTGRP0") + self.connection_admin.delete("ESWIFT", "testgrp0") self.assertEqual( exception.exception.result, TestConnectionConstants.TEST_DELETE_CONNECTION_RESULT_ERROR_DICTIONARY, diff --git a/tests/connection/test_connection_setters.py b/tests/connection/test_connection_setters.py index 37d91099..20e1327c 100644 --- a/tests/connection/test_connection_setters.py +++ b/tests/connection/test_connection_setters.py @@ -20,7 +20,7 @@ class TestConnectionSetters(unittest.TestCase): # ============================================================================ def test_connection_admin_build_give_group_special_request(self): result = self.connection_admin.give_group_special_authority( - "ESWIFT", "TESTGRP0" + "ESWIFT", "testgrp0" ) self.assertEqual( result, TestConnectionConstants.TEST_CONNECTION_GIVE_GROUP_SPECIAL_AUTHORITY @@ -28,7 +28,7 @@ def test_connection_admin_build_give_group_special_request(self): def test_connection_admin_build_take_away_group_special_authority_request(self): result = self.connection_admin.take_away_group_special_authority( - "ESWIFT", "TESTGRP0" + "ESWIFT", "testgrp0" ) self.assertEqual( result, @@ -40,7 +40,7 @@ def test_connection_admin_build_take_away_group_special_authority_request(self): # ============================================================================ def test_connection_admin_build_give_group_auditor_authority_request(self): result = self.connection_admin.give_group_auditor_authority( - "ESWIFT", "TESTGRP0" + "ESWIFT", "testgrp0" ) self.assertEqual( result, TestConnectionConstants.TEST_CONNECTION_GIVE_GROUP_AUDITOR_AUTHORITY @@ -48,7 +48,7 @@ def test_connection_admin_build_give_group_auditor_authority_request(self): def test_connection_admin_build_take_away_group_auditor_authority_request(self): result = self.connection_admin.take_away_group_auditor_authority( - "ESWIFT", "TESTGRP0" + "ESWIFT", "testgrp0" ) self.assertEqual( result, @@ -60,7 +60,7 @@ def test_connection_admin_build_take_away_group_auditor_authority_request(self): # ============================================================================ def test_connection_admin_build_give_group_operations_authority_request(self): result = self.connection_admin.give_group_operations_authority( - "ESWIFT", "TESTGRP0" + "ESWIFT", "testgrp0" ) self.assertEqual( result, @@ -69,7 +69,7 @@ def test_connection_admin_build_give_group_operations_authority_request(self): def test_connection_admin_build_take_away_group_operations_authority_request(self): result = self.connection_admin.take_away_group_operations_authority( - "ESWIFT", "TESTGRP0" + "ESWIFT", "testgrp0" ) self.assertEqual( result, @@ -80,14 +80,14 @@ def test_connection_admin_build_take_away_group_operations_authority_request(sel # Group Access Attribute # ============================================================================ def test_connection_admin_build_give_group_access_attribute_request(self): - result = self.connection_admin.give_group_access_attribute("ESWIFT", "TESTGRP0") + result = self.connection_admin.give_group_access_attribute("ESWIFT", "testgrp0") self.assertEqual( result, TestConnectionConstants.TEST_CONNECTION_SET_GROUP_ACCESS_ATTRIBUTE ) def test_connection_admin_build_take_away_group_access_attribute(self): result = self.connection_admin.take_away_group_access_attribute( - "ESWIFT", "TESTGRP0" + "ESWIFT", "testgrp0" ) self.assertEqual( result, diff --git a/tests/data_set/data_set_log_samples/alter_data_set_error.log b/tests/data_set/data_set_log_samples/alter_data_set_error.log index 90cd31b1..5371bdf1 100644 --- a/tests/data_set/data_set_log_samples/alter_data_set_error.log +++ b/tests/data_set/data_set_log_samples/alter_data_set_error.log @@ -173,7 +173,7 @@ { "base": { "base:universal_access": { - "value": "Read", + "value": "Alter", "operation": null }, "base:owner": { @@ -192,7 +192,7 @@ - Read + Alter eswift diff --git a/tests/data_set/test_data_set_constants.py b/tests/data_set/test_data_set_constants.py index cf050ab2..d9633d22 100644 --- a/tests/data_set/test_data_set_constants.py +++ b/tests/data_set/test_data_set_constants.py @@ -97,6 +97,10 @@ def get_sample(sample_file: str) -> Union[str, bytes]: "base:universal_access": "Read", "base:owner": "eswift", } +TEST_ALTER_DATA_SET_REQUEST_ERROR_TRAITS = { + "base:universal_access": "Alter", + "base:owner": "eswift", +} # Extract Data Set TEST_EXTRACT_DATA_SET_REQUEST_BASE_XML = get_sample("extract_data_set_request_base.xml") diff --git a/tests/data_set/test_data_set_debug_logging.py b/tests/data_set/test_data_set_debug_logging.py index 8edd78d0..08963ccc 100644 --- a/tests/data_set/test_data_set_debug_logging.py +++ b/tests/data_set/test_data_set_debug_logging.py @@ -56,7 +56,7 @@ def test_alter_data_set_request_debug_log_works_on_error( try: self.data_set_admin.alter( "ESWIFT.TEST.T1136242.P3020470", - traits=TestDataSetConstants.TEST_ALTER_DATA_SET_REQUEST_TRAITS, + traits=TestDataSetConstants.TEST_ALTER_DATA_SET_REQUEST_ERROR_TRAITS, ) except SecurityRequestError: pass diff --git a/tests/group/group_log_samples/alter_group_error.log b/tests/group/group_log_samples/alter_group_error.log index 34205d68..6299214b 100644 --- a/tests/group/group_log_samples/alter_group_error.log +++ b/tests/group/group_log_samples/alter_group_error.log @@ -13,7 +13,7 @@ - + @@ -24,7 +24,7 @@ - + 0 0 @@ -58,7 +58,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "listdata", "requestId": "GroupRequest", "commands": [ @@ -100,7 +100,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "listdata", "requestId": "GroupRequest", "commands": [ @@ -178,7 +178,7 @@ - + 3000000000 @@ -193,7 +193,7 @@ - + Definition exists. Add command skipped due to precheck option 8 @@ -218,7 +218,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "set", "requestId": "GroupRequest", "info": [ diff --git a/tests/group/group_log_samples/alter_group_success.log b/tests/group/group_log_samples/alter_group_success.log index 7bf5e943..79e35607 100644 --- a/tests/group/group_log_samples/alter_group_success.log +++ b/tests/group/group_log_samples/alter_group_success.log @@ -13,7 +13,7 @@ - + @@ -24,7 +24,7 @@ - + 0 0 @@ -58,7 +58,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "listdata", "requestId": "GroupRequest", "commands": [ @@ -100,7 +100,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "listdata", "requestId": "GroupRequest", "commands": [ @@ -178,7 +178,7 @@ - + 1234567 @@ -193,7 +193,7 @@ - + Definition exists. Add command skipped due to precheck option 0 @@ -215,7 +215,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "set", "requestId": "GroupRequest", "info": [ diff --git a/tests/group/group_log_samples/extract_group_base_omvs_error.log b/tests/group/group_log_samples/extract_group_base_omvs_error.log index cb969528..fe0e48ba 100644 --- a/tests/group/group_log_samples/extract_group_base_omvs_error.log +++ b/tests/group/group_log_samples/extract_group_base_omvs_error.log @@ -15,7 +15,7 @@ - + @@ -28,7 +28,7 @@ - + 8 16 @@ -50,7 +50,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "listdata", "requestId": "GroupRequest", "commands": [ diff --git a/tests/group/group_log_samples/extract_group_base_omvs_success.log b/tests/group/group_log_samples/extract_group_base_omvs_success.log index fcf3adde..9ac440b1 100644 --- a/tests/group/group_log_samples/extract_group_base_omvs_success.log +++ b/tests/group/group_log_samples/extract_group_base_omvs_success.log @@ -15,7 +15,7 @@ - + @@ -28,7 +28,7 @@ - + 0 0 @@ -60,7 +60,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "listdata", "requestId": "GroupRequest", "commands": [ @@ -100,7 +100,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "listdata", "requestId": "GroupRequest", "commands": [ diff --git a/tests/group/group_request_samples/add_group_request.xml b/tests/group/group_request_samples/add_group_request.xml index e4967aea..0efb989f 100644 --- a/tests/group/group_request_samples/add_group_request.xml +++ b/tests/group/group_request_samples/add_group_request.xml @@ -1,5 +1,5 @@ - + 6667 diff --git a/tests/group/group_request_samples/alter_group_request.xml b/tests/group/group_request_samples/alter_group_request.xml index ee9ba6d6..d2e10601 100644 --- a/tests/group/group_request_samples/alter_group_request.xml +++ b/tests/group/group_request_samples/alter_group_request.xml @@ -1,5 +1,5 @@ - + 1234567 diff --git a/tests/group/group_request_samples/delete_group_request.xml b/tests/group/group_request_samples/delete_group_request.xml index f68558b0..007f9ddf 100644 --- a/tests/group/group_request_samples/delete_group_request.xml +++ b/tests/group/group_request_samples/delete_group_request.xml @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/tests/group/group_request_samples/extract_group_request_base_omvs.xml b/tests/group/group_request_samples/extract_group_request_base_omvs.xml index 75fb3c6e..4538a757 100644 --- a/tests/group/group_request_samples/extract_group_request_base_omvs.xml +++ b/tests/group/group_request_samples/extract_group_request_base_omvs.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/tests/group/group_request_samples/group_set_omvs_gid.xml b/tests/group/group_request_samples/group_set_omvs_gid.xml index ee9ba6d6..d2e10601 100644 --- a/tests/group/group_request_samples/group_set_omvs_gid.xml +++ b/tests/group/group_request_samples/group_set_omvs_gid.xml @@ -1,5 +1,5 @@ - + 1234567 diff --git a/tests/group/group_request_samples/group_set_ovm_gid.xml b/tests/group/group_request_samples/group_set_ovm_gid.xml index 5c9acb29..93220ef3 100644 --- a/tests/group/group_request_samples/group_set_ovm_gid.xml +++ b/tests/group/group_request_samples/group_set_ovm_gid.xml @@ -1,5 +1,5 @@ - + 1234567 diff --git a/tests/group/group_result_samples/add_group_result_success.json b/tests/group/group_result_samples/add_group_result_success.json index 1ae3e4bb..1a1fc5e3 100644 --- a/tests/group/group_result_samples/add_group_result_success.json +++ b/tests/group/group_result_samples/add_group_result_success.json @@ -1,7 +1,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "set", "requestId": "GroupRequest", "commands": [ diff --git a/tests/group/group_result_samples/add_group_result_success.xml b/tests/group/group_result_samples/add_group_result_success.xml index 98461f6f..6fa8b5c4 100644 --- a/tests/group/group_result_samples/add_group_result_success.xml +++ b/tests/group/group_result_samples/add_group_result_success.xml @@ -1,6 +1,6 @@ - + 0 0 diff --git a/tests/group/group_result_samples/alter_group_result_error.json b/tests/group/group_result_samples/alter_group_result_error.json index 77d89a27..4a1f7860 100644 --- a/tests/group/group_result_samples/alter_group_result_error.json +++ b/tests/group/group_result_samples/alter_group_result_error.json @@ -1,7 +1,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "set", "requestId": "GroupRequest", "info": [ diff --git a/tests/group/group_result_samples/alter_group_result_error.xml b/tests/group/group_result_samples/alter_group_result_error.xml index 4b0617fa..da49c5ef 100644 --- a/tests/group/group_result_samples/alter_group_result_error.xml +++ b/tests/group/group_result_samples/alter_group_result_error.xml @@ -1,6 +1,6 @@ - + Definition exists. Add command skipped due to precheck option 8 diff --git a/tests/group/group_result_samples/alter_group_result_success.json b/tests/group/group_result_samples/alter_group_result_success.json index 19a411f6..8bb226bd 100644 --- a/tests/group/group_result_samples/alter_group_result_success.json +++ b/tests/group/group_result_samples/alter_group_result_success.json @@ -1,7 +1,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "set", "requestId": "GroupRequest", "info": [ diff --git a/tests/group/group_result_samples/alter_group_result_success.xml b/tests/group/group_result_samples/alter_group_result_success.xml index 57a90029..dedb13bc 100644 --- a/tests/group/group_result_samples/alter_group_result_success.xml +++ b/tests/group/group_result_samples/alter_group_result_success.xml @@ -1,6 +1,6 @@ - + Definition exists. Add command skipped due to precheck option 0 diff --git a/tests/group/group_result_samples/delete_group_result_error.json b/tests/group/group_result_samples/delete_group_result_error.json index afefddae..04e2aa62 100644 --- a/tests/group/group_result_samples/delete_group_result_error.json +++ b/tests/group/group_result_samples/delete_group_result_error.json @@ -1,7 +1,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "del", "requestId": "GroupRequest", "commands": [ diff --git a/tests/group/group_result_samples/delete_group_result_error.xml b/tests/group/group_result_samples/delete_group_result_error.xml index 9691be79..5ee1e658 100644 --- a/tests/group/group_result_samples/delete_group_result_error.xml +++ b/tests/group/group_result_samples/delete_group_result_error.xml @@ -1,6 +1,6 @@ - + 8 16 diff --git a/tests/group/group_result_samples/delete_group_result_success.json b/tests/group/group_result_samples/delete_group_result_success.json index 13ff5a4e..757001b5 100644 --- a/tests/group/group_result_samples/delete_group_result_success.json +++ b/tests/group/group_result_samples/delete_group_result_success.json @@ -1,7 +1,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "del", "requestId": "GroupRequest", "commands": [ diff --git a/tests/group/group_result_samples/delete_group_result_success.xml b/tests/group/group_result_samples/delete_group_result_success.xml index d87ac6db..8bc5cd05 100644 --- a/tests/group/group_result_samples/delete_group_result_success.xml +++ b/tests/group/group_result_samples/delete_group_result_success.xml @@ -1,6 +1,6 @@ - + 0 0 diff --git a/tests/group/group_result_samples/extract_group_result_base_omvs_error.json b/tests/group/group_result_samples/extract_group_result_base_omvs_error.json index 745d18f8..336c87fe 100644 --- a/tests/group/group_result_samples/extract_group_result_base_omvs_error.json +++ b/tests/group/group_result_samples/extract_group_result_base_omvs_error.json @@ -1,7 +1,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "listdata", "requestId": "GroupRequest", "commands": [ diff --git a/tests/group/group_result_samples/extract_group_result_base_omvs_error.xml b/tests/group/group_result_samples/extract_group_result_base_omvs_error.xml index 599b7d67..8a66dcfa 100644 --- a/tests/group/group_result_samples/extract_group_result_base_omvs_error.xml +++ b/tests/group/group_result_samples/extract_group_result_base_omvs_error.xml @@ -1,6 +1,6 @@ - + 8 16 diff --git a/tests/group/group_result_samples/extract_group_result_base_omvs_success.json b/tests/group/group_result_samples/extract_group_result_base_omvs_success.json index 2b57fad5..987a9093 100644 --- a/tests/group/group_result_samples/extract_group_result_base_omvs_success.json +++ b/tests/group/group_result_samples/extract_group_result_base_omvs_success.json @@ -1,7 +1,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "listdata", "requestId": "GroupRequest", "commands": [ diff --git a/tests/group/group_result_samples/extract_group_result_base_omvs_success.xml b/tests/group/group_result_samples/extract_group_result_base_omvs_success.xml index 36855b23..081516a6 100644 --- a/tests/group/group_result_samples/extract_group_result_base_omvs_success.xml +++ b/tests/group/group_result_samples/extract_group_result_base_omvs_success.xml @@ -1,6 +1,6 @@ - + 0 0 diff --git a/tests/group/group_result_samples/extract_group_result_base_only_error.json b/tests/group/group_result_samples/extract_group_result_base_only_error.json index 0881b1fb..6826720f 100644 --- a/tests/group/group_result_samples/extract_group_result_base_only_error.json +++ b/tests/group/group_result_samples/extract_group_result_base_only_error.json @@ -1,7 +1,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "listdata", "requestId": "GroupRequest", "commands": [ diff --git a/tests/group/group_result_samples/extract_group_result_base_only_error.xml b/tests/group/group_result_samples/extract_group_result_base_only_error.xml index 9cef8fac..83403145 100644 --- a/tests/group/group_result_samples/extract_group_result_base_only_error.xml +++ b/tests/group/group_result_samples/extract_group_result_base_only_error.xml @@ -1,6 +1,6 @@ - + 8 16 diff --git a/tests/group/group_result_samples/extract_group_result_base_only_success.json b/tests/group/group_result_samples/extract_group_result_base_only_success.json index 8ae9b377..e6476730 100644 --- a/tests/group/group_result_samples/extract_group_result_base_only_success.json +++ b/tests/group/group_result_samples/extract_group_result_base_only_success.json @@ -1,7 +1,7 @@ { "securityResult": { "group": { - "name": "TESTGRP0", + "name": "testgrp0", "operation": "listdata", "requestId": "GroupRequest", "commands": [ diff --git a/tests/group/group_result_samples/extract_group_result_base_only_success.xml b/tests/group/group_result_samples/extract_group_result_base_only_success.xml index 4986153a..904285fe 100644 --- a/tests/group/group_result_samples/extract_group_result_base_only_success.xml +++ b/tests/group/group_result_samples/extract_group_result_base_only_success.xml @@ -1,6 +1,6 @@ - + 0 0 diff --git a/tests/group/test_group_debug_logging.py b/tests/group/test_group_debug_logging.py index 0155cf63..ba54d187 100644 --- a/tests/group/test_group_debug_logging.py +++ b/tests/group/test_group_debug_logging.py @@ -35,7 +35,7 @@ def test_alter_group_request_debug_log_works_on_success( stdout = io.StringIO() with contextlib.redirect_stdout(stdout): self.group_admin.alter( - "TESTGRP0", traits=TestGroupConstants.TEST_ALTER_GROUP_REQUEST_TRAITS + "testgrp0", traits=TestGroupConstants.TEST_ALTER_GROUP_REQUEST_TRAITS ) success_log = self.ansi_escape.sub("", stdout.getvalue()) self.assertEqual(success_log, TestGroupConstants.TEST_ALTER_GROUP_SUCCESS_LOG) @@ -52,7 +52,7 @@ def test_alter_group_request_debug_log_works_on_error( with contextlib.redirect_stdout(stdout): try: self.group_admin.alter( - "TESTGRP0", + "testgrp0", traits=TestGroupConstants.TEST_ALTER_GROUP_REQUEST_ERROR_TRAITS, ) except SecurityRequestError: @@ -72,7 +72,7 @@ def test_extract_group_base_omvs_request_debug_log_works_on_success( ) stdout = io.StringIO() with contextlib.redirect_stdout(stdout): - self.group_admin.extract("TESTGRP0", segments=["omvs"]) + self.group_admin.extract("testgrp0", segments=["omvs"]) success_log = self.ansi_escape.sub("", stdout.getvalue()) self.assertEqual( success_log, TestGroupConstants.TEST_EXTRACT_GROUP_BASE_OMVS_SUCCESS_LOG @@ -88,7 +88,7 @@ def test_extract_group_base_omvs_request_debug_log_works_on_error( stdout = io.StringIO() with contextlib.redirect_stdout(stdout): try: - self.group_admin.extract("TESTGRP0", segments=["omvs"]) + self.group_admin.extract("testgrp0", segments=["omvs"]) except SecurityRequestError: pass error_log = self.ansi_escape.sub("", stdout.getvalue()) diff --git a/tests/group/test_group_getters.py b/tests/group/test_group_getters.py index e532c699..efb0861e 100644 --- a/tests/group/test_group_getters.py +++ b/tests/group/test_group_getters.py @@ -28,7 +28,7 @@ def test_group_admin_has_group_special_authority_returns_true_when_group_special TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_ONLY_SUCCESS_XML ) self.assertTrue( - self.group_admin.has_group_special_authority("TESTGRP0", "ESWIFT") + self.group_admin.has_group_special_authority("testgrp0", "ESWIFT") ) def test_group_admin_has_group_special_authority_returns_false_when_not_group_special( @@ -39,7 +39,7 @@ def test_group_admin_has_group_special_authority_returns_false_when_not_group_sp TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_OMVS_SUCCESS_XML ) self.assertFalse( - self.group_admin.has_group_special_authority("TESTGRP0", "ESWIFT") + self.group_admin.has_group_special_authority("testgrp0", "ESWIFT") ) # Error in environment, TESTGRP0 already deleted/not added @@ -51,7 +51,7 @@ def test_group_admin_has_group_special_authority_raises_an_exception_when_extrac TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_OMVS_ERROR_XML ) with self.assertRaises(SecurityRequestError): - self.group_admin.has_group_special_authority("TESTGRP0", "ESWIFT") + self.group_admin.has_group_special_authority("testgrp0", "ESWIFT") # ============================================================================ # Group Operations Authority @@ -64,7 +64,7 @@ def test_group_admin_has_group_operations_authority_returns_true_when_group_oper TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_ONLY_SUCCESS_XML ) self.assertTrue( - self.group_admin.has_group_operations_authority("TESTGRP0", "LEONARD") + self.group_admin.has_group_operations_authority("testgrp0", "LEONARD") ) def test_group_admin_has_group_operations_authority_returns_false_when_not_group_operations( @@ -75,7 +75,7 @@ def test_group_admin_has_group_operations_authority_returns_false_when_not_group TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_OMVS_SUCCESS_XML ) self.assertFalse( - self.group_admin.has_group_operations_authority("TESTGRP0", "LEONARD") + self.group_admin.has_group_operations_authority("testgrp0", "LEONARD") ) # Error in environment, TESTGRP0 already deleted/not added @@ -87,7 +87,7 @@ def test_group_admin_has_group_operations_authority_raises_an_exception_when_ext TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_OMVS_ERROR_XML ) with self.assertRaises(SecurityRequestError): - self.group_admin.has_group_operations_authority("TESTGRP0", "LEONARD") + self.group_admin.has_group_operations_authority("testgrp0", "LEONARD") # ============================================================================ # Group Auditor Authority @@ -105,7 +105,7 @@ def test_group_admin_has_group_auditor_authority_returns_true_when_group_auditor ) call_racf_mock.return_value = group_extract_auditor self.assertTrue( - self.group_admin.has_group_auditor_authority("TESTGRP0", "ESWIFT") + self.group_admin.has_group_auditor_authority("testgrp0", "ESWIFT") ) def test_group_admin_has_group_auditor_authority_returns_false_when_not_group_auditor( @@ -116,7 +116,7 @@ def test_group_admin_has_group_auditor_authority_returns_false_when_not_group_au TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_ONLY_SUCCESS_XML ) self.assertFalse( - self.group_admin.has_group_auditor_authority("TESTGRP0", "ESWIFT") + self.group_admin.has_group_auditor_authority("testgrp0", "ESWIFT") ) # Error in environment, TESTGRP0 already deleted/not added @@ -128,7 +128,7 @@ def test_group_admin_has_group_auditor_authority_raises_an_exception_when_extrac TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_OMVS_ERROR_XML ) with self.assertRaises(SecurityRequestError): - self.group_admin.has_group_auditor_authority("TESTGRP0", "ESWIFT") + self.group_admin.has_group_auditor_authority("testgrp0", "ESWIFT") # ============================================================================ # Group Access Attribute @@ -146,7 +146,7 @@ def test_group_admin_has_group_access_attribute_returns_true_when_grpacc( ) call_racf_mock.return_value = group_extract_grpacc self.assertTrue( - self.group_admin.has_group_access_attribute("TESTGRP0", "LEONARD") + self.group_admin.has_group_access_attribute("testgrp0", "LEONARD") ) def test_group_admin_has_group_access_attribute_returns_false_when_not_grpacc( @@ -157,7 +157,7 @@ def test_group_admin_has_group_access_attribute_returns_false_when_not_grpacc( TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_ONLY_SUCCESS_XML ) self.assertFalse( - self.group_admin.has_group_access_attribute("TESTGRP0", "LEONARD") + self.group_admin.has_group_access_attribute("testgrp0", "LEONARD") ) # Error in environment, TESTGRP0 already deleted/not added @@ -169,7 +169,7 @@ def test_group_admin_has_group_access_attribute_raises_an_exception_when_extract TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_OMVS_ERROR_XML ) with self.assertRaises(SecurityRequestError): - self.group_admin.has_group_access_attribute("TESTGRP0", "LEONARD") + self.group_admin.has_group_access_attribute("testgrp0", "LEONARD") # ============================================================================ # OMVS GID @@ -181,7 +181,7 @@ def test_group_admin_get_omvs_gid_works( call_racf_mock.return_value = ( TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_OMVS_SUCCESS_XML ) - self.assertEqual(self.group_admin.get_omvs_gid("TESTGRP0"), 1234567) + self.assertEqual(self.group_admin.get_omvs_gid("testgrp0"), 1234567) # Error in environment, SQUIDWRD already deleted/not added def test_group_admin_get_omvs_gid_raises_an_exception_when_extract_fails( @@ -192,7 +192,7 @@ def test_group_admin_get_omvs_gid_raises_an_exception_when_extract_fails( TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_OMVS_ERROR_XML ) with self.assertRaises(SecurityRequestError): - self.group_admin.get_omvs_gid("TESTGRP0"), 1234567 + self.group_admin.get_omvs_gid("testgrp0"), 1234567 def test_group_admin_get_omvs_gid_returns_none_when_no_omvs_segment_exists( self, @@ -201,7 +201,7 @@ def test_group_admin_get_omvs_gid_returns_none_when_no_omvs_segment_exists( call_racf_mock.return_value = ( TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_ONLY_SUCCESS_XML ) - self.assertIsNone(self.group_admin.get_omvs_gid("TESTGRP0")) + self.assertIsNone(self.group_admin.get_omvs_gid("testgrp0")) # ============================================================================ # OVM GID @@ -217,7 +217,7 @@ def test_group_admin_get_ovm_gid_works( "OMVS INFORMATION", "OVM INFORMATION" ) call_racf_mock.return_value = group_extract_ovm_gid - self.assertEqual(self.group_admin.get_ovm_gid("TESTGRP0"), 1234567) + self.assertEqual(self.group_admin.get_ovm_gid("testgrp0"), 1234567) # Error in environment, SQUIDWRD already deleted/not added def test_group_admin_get_ovm_gid_raises_an_exception_when_extract_fails( @@ -228,7 +228,7 @@ def test_group_admin_get_ovm_gid_raises_an_exception_when_extract_fails( TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_OMVS_ERROR_XML ) with self.assertRaises(SecurityRequestError): - self.group_admin.get_ovm_gid("TESTGRP0"), 1234567 + self.group_admin.get_ovm_gid("testgrp0"), 1234567 def test_group_admin_get_ovm_gid_returns_none_when_no_ovm_segment_exists( self, @@ -237,4 +237,4 @@ def test_group_admin_get_ovm_gid_returns_none_when_no_ovm_segment_exists( call_racf_mock.return_value = ( TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_ONLY_SUCCESS_XML ) - self.assertIsNone(self.group_admin.get_ovm_gid("TESTGRP0")) + self.assertIsNone(self.group_admin.get_ovm_gid("testgrp0")) diff --git a/tests/group/test_group_request_builder.py b/tests/group/test_group_request_builder.py index ee9ee4c7..69c997c1 100644 --- a/tests/group/test_group_request_builder.py +++ b/tests/group/test_group_request_builder.py @@ -17,22 +17,22 @@ class TestGroupRequestBuilder(unittest.TestCase): def test_group_admin_build_add_group_request(self): result = self.group_admin.add( - "TESTGRP0", traits=TestGroupConstants.TEST_ADD_GROUP_REQUEST_TRAITS + "testgrp0", traits=TestGroupConstants.TEST_ADD_GROUP_REQUEST_TRAITS ) self.assertEqual(result, TestGroupConstants.TEST_ADD_GROUP_REQUEST_XML) def test_group_admin_build_alter_group_request(self): result = self.group_admin.alter( - "TESTGRP0", traits=TestGroupConstants.TEST_ALTER_GROUP_REQUEST_TRAITS + "testgrp0", traits=TestGroupConstants.TEST_ALTER_GROUP_REQUEST_TRAITS ) self.assertEqual(result, TestGroupConstants.TEST_ALTER_GROUP_REQUEST_XML) def test_group_admin_build_extract_group_request_base_omvs(self): - result = self.group_admin.extract("TESTGRP0", segments=["omvs"]) + result = self.group_admin.extract("testgrp0", segments=["omvs"]) self.assertEqual( result, TestGroupConstants.TEST_EXTRACT_GROUP_REQUEST_BASE_OMVS_XML ) def test_group_admin_build_delete_group_request(self): - result = self.group_admin.delete("TESTGRP0") + result = self.group_admin.delete("testgrp0") self.assertEqual(result, TestGroupConstants.TEST_DELETE_GROUP_REQUEST_XML) diff --git a/tests/group/test_group_result_parser.py b/tests/group/test_group_result_parser.py index 139e549a..d0105201 100644 --- a/tests/group/test_group_result_parser.py +++ b/tests/group/test_group_result_parser.py @@ -37,7 +37,7 @@ def test_group_admin_can_parse_add_group_success_xml( ] self.assertEqual( self.group_admin.add( - "TESTGRP0", traits=TestGroupConstants.TEST_ADD_GROUP_REQUEST_TRAITS + "testgrp0", traits=TestGroupConstants.TEST_ADD_GROUP_REQUEST_TRAITS ), TestGroupConstants.TEST_ADD_GROUP_RESULT_SUCCESS_DICTIONARY, ) @@ -46,7 +46,7 @@ def test_group_admin_throws_error_on_add_existing_group( self, call_racf_mock: Mock, ): - group_name = "TESTGRP0" + group_name = "testgrp0" call_racf_mock.side_effect = [ TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_ONLY_SUCCESS_XML, TestGroupConstants.TEST_ADD_GROUP_RESULT_SUCCESS_XML, @@ -66,7 +66,7 @@ def test_group_admin_add_surfaces_error_from_preliminary_extract( self, call_racf_mock: Mock, ): - group_name = "TESTGRP0" + group_name = "testgrp0" extract_group_error_xml = ( TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_ONLY_ERROR_XML ) @@ -124,7 +124,7 @@ def test_group_admin_can_parse_alter_group_success_xml( ] self.assertEqual( self.group_admin.alter( - "TESTGRP0", traits=TestGroupConstants.TEST_ALTER_GROUP_REQUEST_TRAITS + "testgrp0", traits=TestGroupConstants.TEST_ALTER_GROUP_REQUEST_TRAITS ), TestGroupConstants.TEST_ALTER_GROUP_RESULT_SUCCESS_DICTIONARY, ) @@ -133,7 +133,7 @@ def test_group_admin_throws_error_on_alter_new_group( self, call_racf_mock: Mock, ): - group_name = "TESTGRP0" + group_name = "testgrp0" call_racf_mock.side_effect = [ TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_OMVS_ERROR_XML, TestGroupConstants.TEST_ALTER_GROUP_RESULT_SUCCESS_XML, @@ -160,7 +160,7 @@ def test_group_admin_can_parse_alter_group_error_xml( ] with self.assertRaises(SecurityRequestError) as exception: self.group_admin.alter( - "TESTGRP0", + "testgrp0", traits=TestGroupConstants.TEST_ALTER_GROUP_REQUEST_ERROR_TRAITS, ) self.assertEqual( @@ -179,7 +179,7 @@ def test_group_admin_can_parse_extract_group_base_omvs_success_xml( TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_OMVS_SUCCESS_XML ) self.assertEqual( - self.group_admin.extract("TESTGRP0", segments=["omvs"]), + self.group_admin.extract("testgrp0", segments=["omvs"]), TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_OMVS_SUCCESS_DICTIONARY, ) @@ -191,7 +191,7 @@ def test_group_admin_can_parse_extract_group_base_only_success_xml( TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_ONLY_SUCCESS_XML ) self.assertEqual( - self.group_admin.extract("TESTGRP0"), + self.group_admin.extract("testgrp0"), TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_ONLY_SUCCESS_JSON, ) @@ -204,7 +204,7 @@ def test_group_admin_can_parse_extract_group_base_omvs_error_xml( TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_OMVS_ERROR_XML ) with self.assertRaises(SecurityRequestError) as exception: - self.group_admin.extract("TESTGRP0", segments=["omvs"]) + self.group_admin.extract("testgrp0", segments=["omvs"]) self.assertEqual( exception.exception.result, TestGroupConstants.TEST_EXTRACT_GROUP_RESULT_BASE_OMVS_ERROR_DICTIONARY, @@ -221,7 +221,7 @@ def test_group_admin_can_parse_delete_group_success_xml( TestGroupConstants.TEST_DELETE_GROUP_RESULT_SUCCESS_XML ) self.assertEqual( - self.group_admin.delete("TESTGRP0"), + self.group_admin.delete("testgrp0"), TestGroupConstants.TEST_DELETE_GROUP_RESULT_SUCCESS_DICTIONARY, ) @@ -234,7 +234,7 @@ def test_group_admin_can_parse_delete_group_error_xml( TestGroupConstants.TEST_DELETE_GROUP_RESULT_ERROR_XML ) with self.assertRaises(SecurityRequestError) as exception: - self.group_admin.delete("TESTGRP0") + self.group_admin.delete("testgrp0") self.assertEqual( exception.exception.result, TestGroupConstants.TEST_DELETE_GROUP_RESULT_ERROR_DICTIONARY, diff --git a/tests/group/test_group_setters.py b/tests/group/test_group_setters.py index 209e64e6..db793c39 100644 --- a/tests/group/test_group_setters.py +++ b/tests/group/test_group_setters.py @@ -16,9 +16,9 @@ class TestGroupSetters(unittest.TestCase): group_admin = GroupAdmin(generate_requests_only=True) def test_group_admin_build_set_ovm_gid_request(self): - result = self.group_admin.set_ovm_gid("TESTGRP0", "1234567") + result = self.group_admin.set_ovm_gid("testgrp0", "1234567") self.assertEqual(result, TestGroupConstants.TEST_GROUP_SET_OVM_GID_XML) def test_group_admin_build_set_omvs_gid_request(self): - result = self.group_admin.set_omvs_gid("TESTGRP0", "1234567") + result = self.group_admin.set_omvs_gid("testgrp0", "1234567") self.assertEqual(result, TestGroupConstants.TEST_GROUP_SET_OMVS_GID_XML) diff --git a/tests/test_runner.py b/tests/test_runner.py index 44a4f573..136675f0 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -10,6 +10,9 @@ from tests.access.test_access_debug_logging import TestAccessDebugLogging from tests.access.test_access_request_builder import TestAccessRequestBuilder from tests.access.test_access_result_parser import TestAccessResultParser +from tests.common.test_additional_secrets_redaction import ( + TestAdditionalSecretsResultRedaction, +) from tests.common.test_class_attributes import TestClassAttributes from tests.common.test_customize_segment_traits import TestCustomizeSegmentTraits from tests.common.test_downstream_fatal_error import TestDownstreamFatalError @@ -69,6 +72,7 @@ def __test_suite() -> unittest.TestSuite: TestAccessResultParser, TestAccessRequestBuilder, TestAccessDebugLogging, + TestAdditionalSecretsResultRedaction, TestClassAttributes, TestCustomizeSegmentTraits, TestSetupPrecheck, diff --git a/tests/user/test_user_constants.py b/tests/user/test_user_constants.py index 004e7650..d881e241 100644 --- a/tests/user/test_user_constants.py +++ b/tests/user/test_user_constants.py @@ -65,12 +65,6 @@ def get_sample(sample_file: str) -> Union[str, bytes]: TEST_ALTER_USER_RESULT_EXTENDED_SUCCESS_XML = get_sample( "alter_user_result_extended_success.xml" ) -TEST_ALTER_USER_RESULT_EXTENDED_SUCCESS_DICTIONARY = get_sample( - "alter_user_result_extended_success.json" -) -TEST_ALTER_USER_RESULT_ERROR_UID_SECRET_DICTIONARY = get_sample( - "alter_user_result_error_uid_secret.json" -) # Extract User TEST_EXTRACT_USER_RESULT_BASE_OMVS_SUCCESS_XML = get_sample( @@ -219,6 +213,7 @@ def get_sample(sample_file: str) -> Union[str, bytes]: TEST_ALTER_USER_REQUEST_TRAITS_UID_ERROR = dict(TEST_ALTER_USER_REQUEST_TRAITS_EXTENDED) TEST_ALTER_USER_REQUEST_TRAITS_UID_ERROR["omvs:uid"] = 90000000000 + # Extract User TEST_EXTRACT_USER_REQUEST_BASE_OMVS_XML = get_sample( "extract_user_request_base_omvs.xml" @@ -421,13 +416,6 @@ def get_sample(sample_file: str) -> Union[str, bytes]: TEST_ALTER_USER_SUCCESS_LOG = get_sample("alter_user_success.log") TEST_ALTER_USER_ERROR_LOG = get_sample("alter_user_error.log") -TEST_ALTER_USER_ADDITIONAL_SECRET_ADDED_SUCCESS_LOG = get_sample( - "alter_user_additional_secret_added_success.log" -) -TEST_ALTER_USER_ADDITIONAL_SECRET_ADDED_ERROR_LOG = get_sample( - "alter_user_additional_secret_added_error.log" -) - TEST_ALTER_USER_PASSWORD_SUCCESS_LOG = get_sample("alter_user_password_success.log") TEST_ALTER_USER_PASSWORD_ERROR_LOG = get_sample("alter_user_password_error.log") diff --git a/tests/user/test_user_debug_logging.py b/tests/user/test_user_debug_logging.py index efb6f64e..e7fe6c02 100644 --- a/tests/user/test_user_debug_logging.py +++ b/tests/user/test_user_debug_logging.py @@ -261,64 +261,6 @@ def test_alter_user_request_debug_log_password_xml_tags_not_redacted_on_error( self.assertEqual(error_log.count("********"), 4) self.assertIn(self.simple_password, error_log) - # ============================================================================ - # Add Additional Secrets - # ============================================================================ - def test_alter_user_request_debug_log_additional_secret_added_get_redacted_on_success( - self, - call_racf_mock: Mock, - ): - user_admin = UserAdmin(debug=True, additional_secret_traits=["omvs:uid"]) - call_racf_mock.side_effect = [ - TestUserConstants.TEST_EXTRACT_USER_RESULT_BASE_ONLY_SUCCESS_XML, - TestUserConstants.TEST_ALTER_USER_RESULT_EXTENDED_SUCCESS_XML, - ] - stdout = io.StringIO() - with contextlib.redirect_stdout(stdout): - user_admin.alter( - "squidwrd", - traits=TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_EXTENDED, - ) - success_log = self.ansi_escape.sub("", stdout.getvalue()) - self.assertEqual( - success_log, - TestUserConstants.TEST_ALTER_USER_ADDITIONAL_SECRET_ADDED_SUCCESS_LOG, - ) - self.assertNotIn( - TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_EXTENDED["omvs:uid"], - success_log, - ) - - # Secret redacted from command image but not from resulting error message. - # Marked experimental until resolved - def test_alter_user_request_debug_log_additional_secret_added_get_redacted_on_error( - self, - call_racf_mock: Mock, - ): - user_admin = UserAdmin(debug=True, additional_secret_traits=["omvs:uid"]) - call_racf_mock.side_effect = [ - TestUserConstants.TEST_EXTRACT_USER_RESULT_BASE_ONLY_SUCCESS_XML, - TestUserConstants.TEST_ALTER_USER_RESULT_ERROR_XML, - ] - stdout = io.StringIO() - with contextlib.redirect_stdout(stdout): - try: - user_admin.alter( - "squidwrd", - traits=TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_UID_ERROR, - ) - except SecurityRequestError: - pass - error_log = self.ansi_escape.sub("", stdout.getvalue()) - self.assertEqual( - error_log, - TestUserConstants.TEST_ALTER_USER_ADDITIONAL_SECRET_ADDED_ERROR_LOG, - ) - self.assertNotIn( - f"({TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_UID_ERROR['omvs:uid']})", - error_log, - ) - # ============================================================================ # Extract User # ============================================================================ diff --git a/tests/user/test_user_result_parser.py b/tests/user/test_user_result_parser.py index ad458f23..d4d8d024 100644 --- a/tests/user/test_user_result_parser.py +++ b/tests/user/test_user_result_parser.py @@ -473,53 +473,3 @@ def test_user_admin_can_parse_delete_user_error_xml( exception.exception.result, TestUserConstants.TEST_DELETE_USER_RESULT_ERROR_DICTIONARY, ) - - # ============================================================================ - # Add Additional Secrets - # ============================================================================ - def test_user_admin_custom_secret_redacted_on_success( - self, - call_racf_mock: Mock, - ): - user_admin = UserAdmin(additional_secret_traits=["omvs:uid"]) - call_racf_mock.side_effect = [ - TestUserConstants.TEST_EXTRACT_USER_RESULT_BASE_ONLY_SUCCESS_XML, - TestUserConstants.TEST_ALTER_USER_RESULT_EXTENDED_SUCCESS_XML, - ] - result = user_admin.alter( - "squidwrd", - traits=TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_EXTENDED, - ) - self.assertEqual( - result, - TestUserConstants.TEST_ALTER_USER_RESULT_EXTENDED_SUCCESS_DICTIONARY, - ) - self.assertNotIn( - TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_EXTENDED["omvs:uid"], - result, - ) - - # Secret redacted from command image but not from resulting error message. - # Marked experimental until resolved - def test_user_admin_custom_secret_redacted_on_error( - self, - call_racf_mock: Mock, - ): - user_admin = UserAdmin(debug=True, additional_secret_traits=["omvs:uid"]) - call_racf_mock.side_effect = [ - TestUserConstants.TEST_EXTRACT_USER_RESULT_BASE_ONLY_SUCCESS_XML, - TestUserConstants.TEST_ALTER_USER_RESULT_ERROR_XML, - ] - with self.assertRaises(SecurityRequestError) as exception: - user_admin.alter( - "squidwrd", - traits=TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_UID_ERROR, - ) - self.assertEqual( - exception.exception.result, - TestUserConstants.TEST_ALTER_USER_RESULT_ERROR_UID_SECRET_DICTIONARY, - ) - self.assertNotIn( - f"({TestUserConstants.TEST_ALTER_USER_REQUEST_TRAITS_UID_ERROR['omvs:uid']})", - exception.exception.result, - )