From 9e2a3dea13c41b04c9e89bea453f5ff7f9cefd78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emma=20Skovg=C3=A5rd?= <64806882+EmmasBox@users.noreply.github.com> Date: Mon, 26 Jan 2026 16:06:13 +0100 Subject: [PATCH 1/7] Possibly fixed bug --- sear/irrseq00/profile_extractor.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sear/irrseq00/profile_extractor.cpp b/sear/irrseq00/profile_extractor.cpp index ba3960ec..87600f7a 100644 --- a/sear/irrseq00/profile_extractor.cpp +++ b/sear/irrseq00/profile_extractor.cpp @@ -352,9 +352,10 @@ void ProfileExtractor::buildGenericExtractRequest( if (function_code == USER_EXTRACT_NEXT_FUNCTION_CODE || function_code == GROUP_EXTRACT_NEXT_FUNCTION_CODE || - function_code == DATASET_EXTRACT_NEXT_FUNCTION_CODE || - function_code == RESOURCE_EXTRACT_NEXT_FUNCTION_CODE) { + function_code == DATASET_EXTRACT_NEXT_FUNCTION_CODE) { profile_extract_parms->flags = htonl(0x4000000); + } else if (function_code == function_code == RESOURCE_EXTRACT_NEXT_FUNCTION_CODE) { + profile_extract_parms->flags = htonl(0x10000000); } /***************************************************************************/ From 0861a9055e51b33b3e1fa537b1011f6d052b4abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emma=20Skovg=C3=A5rd?= <64806882+EmmasBox@users.noreply.github.com> Date: Mon, 26 Jan 2026 16:08:05 +0100 Subject: [PATCH 2/7] fixed typo --- sear/irrseq00/profile_extractor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sear/irrseq00/profile_extractor.cpp b/sear/irrseq00/profile_extractor.cpp index 87600f7a..c1293c7c 100644 --- a/sear/irrseq00/profile_extractor.cpp +++ b/sear/irrseq00/profile_extractor.cpp @@ -354,7 +354,7 @@ void ProfileExtractor::buildGenericExtractRequest( function_code == GROUP_EXTRACT_NEXT_FUNCTION_CODE || function_code == DATASET_EXTRACT_NEXT_FUNCTION_CODE) { profile_extract_parms->flags = htonl(0x4000000); - } else if (function_code == function_code == RESOURCE_EXTRACT_NEXT_FUNCTION_CODE) { + } else if (function_code == RESOURCE_EXTRACT_NEXT_FUNCTION_CODE) { profile_extract_parms->flags = htonl(0x10000000); } From c5571bd4c554a79e5d0b874539f0e22c852b4d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emma=20Skovg=C3=A5rd?= <64806882+EmmasBox@users.noreply.github.com> Date: Mon, 26 Jan 2026 16:25:02 +0100 Subject: [PATCH 3/7] Fixed bug --- sear/irrseq00/profile_extractor.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sear/irrseq00/profile_extractor.cpp b/sear/irrseq00/profile_extractor.cpp index c1293c7c..d6326553 100644 --- a/sear/irrseq00/profile_extractor.cpp +++ b/sear/irrseq00/profile_extractor.cpp @@ -175,7 +175,7 @@ void ProfileExtractor::extract(SecurityRequest &request) { generic_extract_parms_results_t *p_save_generic_result; p_arg_area->arg_pointers.p_profile_extract_parms->flags |= - htonl(0x14000000); + htonl(0x04000000); do { p_save_generic_result = @@ -352,10 +352,9 @@ void ProfileExtractor::buildGenericExtractRequest( if (function_code == USER_EXTRACT_NEXT_FUNCTION_CODE || function_code == GROUP_EXTRACT_NEXT_FUNCTION_CODE || - function_code == DATASET_EXTRACT_NEXT_FUNCTION_CODE) { + function_code == DATASET_EXTRACT_NEXT_FUNCTION_CODE || + function_code == RESOURCE_EXTRACT_NEXT_FUNCTION_CODE) { profile_extract_parms->flags = htonl(0x4000000); - } else if (function_code == RESOURCE_EXTRACT_NEXT_FUNCTION_CODE) { - profile_extract_parms->flags = htonl(0x10000000); } /***************************************************************************/ From 06d0f68dd1afeab9b5ed82b8129e74b338b61e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emma=20Skovg=C3=A5rd?= <64806882+EmmasBox@users.noreply.github.com> Date: Mon, 26 Jan 2026 16:29:16 +0100 Subject: [PATCH 4/7] Fixed bug --- sear/irrseq00/profile_extractor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sear/irrseq00/profile_extractor.cpp b/sear/irrseq00/profile_extractor.cpp index d6326553..6b2c2e2f 100644 --- a/sear/irrseq00/profile_extractor.cpp +++ b/sear/irrseq00/profile_extractor.cpp @@ -154,7 +154,7 @@ void ProfileExtractor::extract(SecurityRequest &request) { p_arg_area->args.function_code = function_code; p_arg_area->arg_pointers.p_profile_extract_parms->flags |= - htonl(0x14000000); + htonl(0x04000000); // Call R_Admin Logger::getInstance().debug("Calling IRRSEQ00 ..."); From 2ae65c58441910dd16d13b3f186a26b885d9028f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emma=20Skovg=C3=A5rd?= <64806882+EmmasBox@users.noreply.github.com> Date: Mon, 26 Jan 2026 16:58:30 +0100 Subject: [PATCH 5/7] Fixed re-introduced dataset search bug --- sear/irrseq00/profile_extractor.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sear/irrseq00/profile_extractor.cpp b/sear/irrseq00/profile_extractor.cpp index 6b2c2e2f..23f6be68 100644 --- a/sear/irrseq00/profile_extractor.cpp +++ b/sear/irrseq00/profile_extractor.cpp @@ -153,8 +153,14 @@ void ProfileExtractor::extract(SecurityRequest &request) { function_code = save_function_code; p_arg_area->args.function_code = function_code; - p_arg_area->arg_pointers.p_profile_extract_parms->flags |= + if (function_code == DATASET_EXTRACT_NEXT_FUNCTION_CODE) { + p_arg_area->arg_pointers.p_profile_extract_parms->flags |= + htonl(0x14000000); + } else { + p_arg_area->arg_pointers.p_profile_extract_parms->flags = htonl(0x04000000); + } + // Call R_Admin Logger::getInstance().debug("Calling IRRSEQ00 ..."); @@ -170,12 +176,10 @@ void ProfileExtractor::extract(SecurityRequest &request) { p_arg_area->args.p_result_buffer != nullptr && (function_code == USER_EXTRACT_NEXT_FUNCTION_CODE || function_code == GROUP_EXTRACT_NEXT_FUNCTION_CODE || - function_code == DATASET_EXTRACT_NEXT_FUNCTION_CODE || function_code == RESOURCE_EXTRACT_NEXT_FUNCTION_CODE)) { generic_extract_parms_results_t *p_save_generic_result; - p_arg_area->arg_pointers.p_profile_extract_parms->flags |= - htonl(0x04000000); + p_arg_area->arg_pointers.p_profile_extract_parms->flags = htonl(0x04000000); do { p_save_generic_result = @@ -227,6 +231,9 @@ void ProfileExtractor::extract(SecurityRequest &request) { *p_arg_area->arg_pointers.p_p_result_buffer = reinterpret_cast(p_save_generic_result); + } else if (function_code == DATASET_EXTRACT_NEXT_FUNCTION_CODE) { + p_arg_area->arg_pointers.p_profile_extract_parms->flags |= + htonl(0x14000000); } request.setRawResultPointer(p_arg_area->args.p_result_buffer); From b922c00e892c36389c3cd0f607fc2b9a31efc0ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emma=20Skovg=C3=A5rd?= <64806882+EmmasBox@users.noreply.github.com> Date: Mon, 26 Jan 2026 17:00:03 +0100 Subject: [PATCH 6/7] Fixed bug --- sear/irrseq00/profile_extractor.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sear/irrseq00/profile_extractor.cpp b/sear/irrseq00/profile_extractor.cpp index 23f6be68..c257e3ce 100644 --- a/sear/irrseq00/profile_extractor.cpp +++ b/sear/irrseq00/profile_extractor.cpp @@ -176,10 +176,17 @@ void ProfileExtractor::extract(SecurityRequest &request) { p_arg_area->args.p_result_buffer != nullptr && (function_code == USER_EXTRACT_NEXT_FUNCTION_CODE || function_code == GROUP_EXTRACT_NEXT_FUNCTION_CODE || - function_code == RESOURCE_EXTRACT_NEXT_FUNCTION_CODE)) { + function_code == RESOURCE_EXTRACT_NEXT_FUNCTION_CODE || + function_code == DATASET_EXTRACT_NEXT_FUNCTION_CODE)) { generic_extract_parms_results_t *p_save_generic_result; - p_arg_area->arg_pointers.p_profile_extract_parms->flags = htonl(0x04000000); + if (function_code == DATASET_EXTRACT_NEXT_FUNCTION_CODE) { + p_arg_area->arg_pointers.p_profile_extract_parms->flags |= + htonl(0x14000000); + } else { + p_arg_area->arg_pointers.p_profile_extract_parms->flags = + htonl(0x04000000); + } do { p_save_generic_result = @@ -231,9 +238,6 @@ void ProfileExtractor::extract(SecurityRequest &request) { *p_arg_area->arg_pointers.p_p_result_buffer = reinterpret_cast(p_save_generic_result); - } else if (function_code == DATASET_EXTRACT_NEXT_FUNCTION_CODE) { - p_arg_area->arg_pointers.p_profile_extract_parms->flags |= - htonl(0x14000000); } request.setRawResultPointer(p_arg_area->args.p_result_buffer); From e4941809bdab1104f9d3f3bac1d09d949c23b8f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emma=20Skovg=C3=A5rd?= <64806882+EmmasBox@users.noreply.github.com> Date: Mon, 26 Jan 2026 17:16:46 +0100 Subject: [PATCH 7/7] Added three new search tests for resource profiles --- python_tests/conftest.py | 19 ++++++++++++++++ python_tests/helper.py | 7 ++++++ python_tests/test_search.py | 44 +++++++++++++++++++++++++++++++++++-- 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/python_tests/conftest.py b/python_tests/conftest.py index dd1159ed..1f89efcc 100644 --- a/python_tests/conftest.py +++ b/python_tests/conftest.py @@ -99,6 +99,25 @@ def create_resource(delete_resource): run_tso_command(f"SETROPTS RACLIST({class_name}) REFRESH") yield profile_name, class_name +@pytest.fixture +def delete_resource_in_search_class(): + profile_name=f"SEARTEST.DISCRETE{secrets.token_hex(2)}.**".upper() + class_name = "SEARTEST" + yield profile_name, class_name + try: # noqa: SIM105 + run_tso_command(f"RDELETE {class_name} ({profile_name})") + except: # noqa: E722 + pass + +@pytest.fixture +def create_resource_in_search_class(delete_resource_in_search_class): + """Create a new resource profile for a test""" + profile_name, class_name = delete_resource_in_search_class + run_tso_command(f"RDEFINE {class_name} {profile_name} DATA('RESOURCE PROFILE GENERATED DURING SEAR TESTING, NOT IMPORTANT') OWNER(SYS1) FGENERIC") # noqa: E501 + run_tso_command(f"SETROPTS GENERIC({class_name}) REFRESH") + run_tso_command(f"SETROPTS RACLIST({class_name}) REFRESH") + yield profile_name, class_name + @pytest.fixture def delete_keyring(): ring_name=f"SEARTEST.RING{secrets.token_hex(2)}".upper() diff --git a/python_tests/helper.py b/python_tests/helper.py index 8f2c0018..4fad9165 100644 --- a/python_tests/helper.py +++ b/python_tests/helper.py @@ -38,4 +38,11 @@ "racf_return_code": 4, "saf_return_code": 4, "sear_return_code": 4, + } + +successful_return_codes_search = { + "racf_reason_code": 4, + "racf_return_code": 4, + "saf_return_code": 4, + "sear_return_code": 0, } \ No newline at end of file diff --git a/python_tests/test_search.py b/python_tests/test_search.py index e648e959..d400371d 100644 --- a/python_tests/test_search.py +++ b/python_tests/test_search.py @@ -1,5 +1,5 @@ -from helper import successful_return_codes +from helper import successful_return_codes, successful_return_codes_search # Import SEAR from sear import sear @@ -36,4 +36,44 @@ def test_search_resource_profiles_nonexistent_class(): }, ) assert "errors" in str(search_result.result) - assert search_result.result["return_codes"] != successful_return_codes \ No newline at end of file + assert search_result.result["return_codes"] != successful_return_codes + +def test_search_resource_profiles_all(): + """This test is supposed to succeed""" + search_result = sear( + { + "operation": "search", + "admin_type": "resource", + "class": "seartest", + }, + ) + assert "errors" not in str(search_result.result) + assert search_result.result["return_codes"] == successful_return_codes_search + +def test_search_resource_profiles_filter(): + """This test is supposed to succeed""" + search_result = sear( + { + "operation": "search", + "admin_type": "resource", + "class": "seartest", + "resource_filter": "filter", + }, + ) + assert "errors" not in str(search_result.result) + assert search_result.result["return_codes"] == successful_return_codes + +def test_search_resource_profiles_discrete(create_resource_in_search_class): + """This test is supposed to succeed""" + profile_name, class_name = create_resource_in_search_class + search_result = sear( + { + "operation": "search", + "admin_type": "resource", + "class": class_name, + "resource_filter": f"{profile_name}", + }, + ) + assert "errors" not in str(search_result.result) + assert profile_name in search_result.result["profiles"] + assert search_result.result["return_codes"] == successful_return_codes \ No newline at end of file