Skip to content

Commit

Permalink
change handle to fixed-length byte array
Browse files Browse the repository at this point in the history
  • Loading branch information
ElijahSwiftIBM committed Feb 29, 2024
1 parent 811b1b2 commit c8e3f47
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pyracf/common/irrsmo00.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ static PyObject *call_irrsmo00(PyObject *self, PyObject *args, PyObject *kwargs)
// Py_BuildValue() will return a Tuple.

return Py_BuildValue(
"{s:y#,s:[B,B,B],s:y}",
"{s:y#,s:[B,B,B],s:y#}",
"resultBuffer", result_buffer, result_len,
"returnCodes", saf_rc, racf_rc, racf_rsn,
"handle",request_handle);
"handle", request_handle, 64);
}

static char call_irrsmo00_docs[] =
Expand Down
2 changes: 1 addition & 1 deletion pyracf/common/irrsmo00.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def call_racf(
# Preserve raw result XML just in case we need to create a dump.
# If the decoded result XML cannot be parsed with the XML parser,
# a dump may need to be taken to aid in problem determination.
self.__raw_result_xml = b"".join(result["resultBuffers"])
self.__raw_result_xml = result["resultBuffer"]
# Replace any null bytes in the result XML with spaces.
result_xml = self.__null_byte_fix(self.__raw_result_xml)
# 'irrsmo00.c' returns a raw unmodified bytes object containing a copy
Expand Down
18 changes: 9 additions & 9 deletions tests/common/test_irrsmo00_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_irrsmo00_null_byte_fix(
])
# fmt: on
call_irrsmo00_wrapper_mock.return_value = {
"resultBuffers": [xml_containing_null_bytes],
"resultBuffer": xml_containing_null_bytes,
"returnCodes": [0, 0, 0],
}
self.assertEqual(
Expand All @@ -71,7 +71,7 @@ def test_irrsmo00_empty_result(
):
# Simulate failure due to incomplete 'IRR.IRRSMO00.PRECHECK' setup
call_irrsmo00_wrapper_mock.return_value = {
"resultBuffers": [bytes([0 for i in range(256)])],
"resultBuffer": bytes([0 for i in range(256)]),
"returnCodes": [8, 200, 16],
}
self.assertEqual(self.irrsmo00.call_racf(b""), [8, 200, 16])
Expand All @@ -82,7 +82,7 @@ def test_irrsmo00_result_buffer_full_failure(
):
# Simulate scenario where result buffer is too small.
call_irrsmo00_wrapper_mock.return_value = {
"resultBuffers": [self.good_xml[:32]],
"resultBuffer": self.good_xml[:32],
"returnCodes": [8, 4000, 100000000],
}
self.assertEqual(
Expand All @@ -95,7 +95,7 @@ def test_irrsmo00_result_buffer_full_success(
):
# Simulate scenario where result buffer is exactly the right size.
call_irrsmo00_wrapper_mock.return_value = {
"resultBuffers": [self.good_xml[: self.good_xml_null_terminator_index]],
"resultBuffer": self.good_xml[: self.good_xml_null_terminator_index],
"returnCodes": [0, 0, 0],
}
self.assertEqual(
Expand All @@ -105,7 +105,7 @@ def test_irrsmo00_result_buffer_full_success(

def test_irrsmo00_normal_result(self, call_irrsmo00_wrapper_mock: Mock):
call_irrsmo00_wrapper_mock.return_value = {
"resultBuffers": [self.good_xml],
"resultBuffer": self.good_xml,
"returnCodes": [0, 0, 0],
}
self.assertEqual(
Expand All @@ -118,7 +118,7 @@ def test_irrsmo00_normal_result(self, call_irrsmo00_wrapper_mock: Mock):
# ============================================================================
def test_irrsmo00_minimum_arguments(self, call_irrsmo00_wrapper_mock: Mock):
call_irrsmo00_wrapper_mock.return_value = {
"resultBuffers": [self.good_xml],
"resultBuffer": self.good_xml,
"returnCodes": [0, 0, 0],
}
self.irrsmo00.call_racf(b"some bytes")
Expand All @@ -133,7 +133,7 @@ def test_irrsmo00_minimum_arguments(self, call_irrsmo00_wrapper_mock: Mock):

def test_irrsmo00_with_precheck_set_to_true(self, call_irrsmo00_wrapper_mock: Mock):
call_irrsmo00_wrapper_mock.return_value = {
"resultBuffers": [self.good_xml],
"resultBuffer": self.good_xml,
"returnCodes": [0, 0, 0],
}
self.irrsmo00.call_racf(b"some bytes", precheck=True)
Expand All @@ -148,7 +148,7 @@ def test_irrsmo00_with_precheck_set_to_true(self, call_irrsmo00_wrapper_mock: Mo

def test_irrsmo00_with_run_as_userid_set(self, call_irrsmo00_wrapper_mock: Mock):
call_irrsmo00_wrapper_mock.return_value = {
"resultBuffers": [self.good_xml],
"resultBuffer": self.good_xml,
"returnCodes": [0, 0, 0],
}
self.irrsmo00.call_racf(b"some bytes", run_as_userid="KRABS")
Expand All @@ -165,7 +165,7 @@ def test_irrsmo00_with_custom_result_buffer_size(
self, call_irrsmo00_wrapper_mock: Mock
):
call_irrsmo00_wrapper_mock.return_value = {
"resultBuffers": [self.good_xml],
"resultBuffer": self.good_xml,
"returnCodes": [0, 0, 0],
}
irrsmo00 = IRRSMO00(result_buffer_size=32768)
Expand Down

0 comments on commit c8e3f47

Please sign in to comment.