Skip to content

Commit

Permalink
Revert "Revert "Remove length-determined bytes objects""
Browse files Browse the repository at this point in the history
This reverts commit 53c03eb.
  • Loading branch information
ElijahSwiftIBM committed Feb 19, 2024
1 parent 402f3f8 commit 632d055
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pyracf/common/irrsmo00.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ static PyObject *call_irrsmo00(PyObject *self, PyObject *args, PyObject *kwargs)

static char *kwlist[] = {
"request_xml",
"request_xml_length",
"result_buffer_size",
"irrsmo00_options",
"running_userid",
"running_userid_length",
NULL};

if (
!PyArg_ParseTupleAndKeywords(
args,
kwargs,
"y#|IIy#",
"y|IIIyb",
kwlist,
&request_xml,
&request_xml_length,
Expand Down Expand Up @@ -143,8 +145,10 @@ static char call_irrsmo00_docs[] =
"call_irrsmo00(\n"
" request_xml: bytes,\n"
" request_xml_length: uint,\n"
" result_buffer_size: uint,\n"
" irrsmo00_options: uint,\n"
" running_userid: bytes,\n"
" running_userid_length: uint,\n"
") -> Dict{ resultBuffers: List[bytes], returnCodes: List[int,int,int] }:\n"
"# Returns an XML result string and return and reason "
"codes from the IRRSMO00 RACF Callable Service.\n";
Expand Down
2 changes: 2 additions & 0 deletions pyracf/common/irrsmo00.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ def call_racf(
running_userid = run_as_userid.encode("cp1047")
result = call_irrsmo00(
request_xml=request_xml,
request_xml_length=len(request_xml),
result_buffer_size=self.__result_buffer_size,
irrsmo00_options=irrsmo00_options,
running_userid=running_userid,
running_userid_len=len(running_userid),
)
# 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,
Expand Down
8 changes: 8 additions & 0 deletions tests/common/test_irrsmo00_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,11 @@ def test_irrsmo00_minimum_arguments(self, call_irrsmo00_wrapper_mock: Mock):
self.irrsmo00.call_racf(b"some bytes")
call_irrsmo00_wrapper_mock.assert_called_with(
request_xml=b"some bytes",
request_xml_length=10,
result_buffer_size=16384,
irrsmo00_options=13,
running_userid=b"",
running_userid_len=0,
)

def test_irrsmo00_with_precheck_set_to_true(self, call_irrsmo00_wrapper_mock: Mock):
Expand All @@ -137,9 +139,11 @@ def test_irrsmo00_with_precheck_set_to_true(self, call_irrsmo00_wrapper_mock: Mo
self.irrsmo00.call_racf(b"some bytes", precheck=True)
call_irrsmo00_wrapper_mock.assert_called_with(
request_xml=b"some bytes",
request_xml_length=10,
result_buffer_size=16384,
irrsmo00_options=15,
running_userid=b"",
running_userid_len=0,
)

def test_irrsmo00_with_run_as_userid_set(self, call_irrsmo00_wrapper_mock: Mock):
Expand All @@ -150,9 +154,11 @@ def test_irrsmo00_with_run_as_userid_set(self, call_irrsmo00_wrapper_mock: Mock)
self.irrsmo00.call_racf(b"some bytes", run_as_userid="KRABS")
call_irrsmo00_wrapper_mock.assert_called_with(
request_xml=b"some bytes",
request_xml_length=10,
result_buffer_size=16384,
irrsmo00_options=13,
running_userid=b"\xd2\xd9\xc1\xc2\xe2",
running_userid_len=5,
)

def test_irrsmo00_with_custom_result_buffer_size(
Expand All @@ -166,7 +172,9 @@ def test_irrsmo00_with_custom_result_buffer_size(
irrsmo00.call_racf(b"some bytes")
call_irrsmo00_wrapper_mock.assert_called_with(
request_xml=b"some bytes",
request_xml_length=10,
result_buffer_size=32768,
irrsmo00_options=13,
running_userid=b"",
running_userid_len=0,
)

0 comments on commit 632d055

Please sign in to comment.