Bug 36676 - SIP2 drops connection when using unknown patron id in fee paid message
Summary: SIP2 drops connection when using unknown patron id in fee paid message
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: SIP2 (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor (vote)
Assignee: Jan Kissig
QA Contact: Testopia
URL:
Keywords:
Depends on: 23051
Blocks:
  Show dependency treegraph
 
Reported: 2024-04-23 12:52 UTC by Jan Kissig
Modified: 2024-05-30 19:05 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.05.00,23.11.06,23.05.12


Attachments
BUG 36676 When sending a fee paid message to SIP2 with an unknown patron id it will respond with an empty response followed by dropping the connection to a client. (1.72 KB, patch)
2024-04-23 18:26 UTC, Jan Kissig
Details | Diff | Splinter Review
BUG 36676: SIP2 drops connection on unknown patron id in fee paid message (1.78 KB, patch)
2024-04-26 12:40 UTC, Jan Kissig
Details | Diff | Splinter Review
BUG 36676: SIP2 drops connection on unknown patron id in fee paid message (1.78 KB, patch)
2024-04-26 12:41 UTC, Jan Kissig
Details | Diff | Splinter Review
Bug 36676: SIP2 drops connection on unknown patron id in fee paid message (1.82 KB, patch)
2024-05-06 07:22 UTC, David Nind
Details | Diff | Splinter Review
Bug 36676: SIP2 drops connection on unknown patron id in fee paid message (1.88 KB, patch)
2024-05-10 11:40 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kissig 2024-04-23 12:52:15 UTC
When sending a fee paid message to SIP2 with an unknown patron id it will respond with an empty response followed by dropping the connection to a client. 

to test on ktd (23.11):
a) perl /usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1   -l CPL --patron 2352900100046 -m fee_paid --fee-type FT --fee-amount 0.01

The reason for this is in C4/SIP/ILS.pm pay_fee as it calls

return $trans; if no patron is found.
Comment 1 Jan Kissig 2024-04-23 18:26:13 UTC
Created attachment 165436 [details] [review]
BUG 36676 When sending a fee paid message to SIP2 with an unknown patron id it will respond with an empty response followed by dropping the connection to a client.

to test on ktd (23.11):
a) perl /usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1   -l CPL --patron 2352900100046 -m fee_paid --fee-type FT --fee-amount 0.01
Output:
Trying 'fee_paid'
SEND: 3720240423    124447FT00USDBV0.01|AO|AA2352900100046|ACterm1|
Use of uninitialized value $data in concatenation (.) or string at /usr/share/koha/bin/sip_cli_emulator.pl line 355, <GEN0> chunk 1.
READ:

b) apply patch
c) perl /usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1   -l CPL --patron 2352900100046 -m fee_paid --fee-type FT --fee-amount 0.01
Output:
Trying 'fee_paid'
SEND: 3720240423    125602FT00USDBV0.01|AO|AA2352900100046|ACterm1|
READ: 38N20240423    125602AO|AA2352900100046|AFInvalid patron barcode.|
Comment 2 David Nind 2024-04-26 11:43:31 UTC
I've tested under 23.11 and the patch works as per the test plan.

However, on main, I can't seem to run the emulator - not quite sure why as it has worked fine in the past when testing other bugs:

perl /usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1   -l CPL --patron 2352900100046 -m fee_paid --fee-type FT --fee-amount 0.01
Attempting socket connection to 127.0.0.1:6001...failed! : Connection refused

The bug title and description need to be changed as per the commit message guidelines https://wiki.koha-community.org/wiki/Commit_messages

- Bug 36676: Short title

  Short description about what the bug fixes.

  Test plan:
  ....

In addition, should this change be made to main (previously master) as well?
Comment 3 Jan Kissig 2024-04-26 12:40:03 UTC
Created attachment 165652 [details] [review]
BUG 36676: SIP2 drops connection on unknown patron id in fee paid message

When sending a fee paid message to SIP2 with an unknown patron id it will respond with an empty response followed by dropping the connection to a client.

to test on ktd (23.11):
a) perl /usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1   -l CPL --patron 2352900100046 -m fee_paid --fee-type FT --fee-amount 0.01
Output:
Trying 'fee_paid'
SEND: 3720240423    124447FT00USDBV0.01|AO|AA2352900100046|ACterm1|
Use of uninitialized value $data in concatenation (.) or string at /usr/share/koha/bin/sip_cli_emulator.pl line 355, <GEN0> chunk 1.
READ:

b) apply patch
c) perl /usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1   -l CPL --patron 2352900100046 -m fee_paid --fee-type FT --fee-amount 0.01
Output:
Trying 'fee_paid'
SEND: 3720240423    125602FT00USDBV0.01|AO|AA2352900100046|ACterm1|
READ: 38N20240423    125602AO|AA2352900100046|AFInvalid patron barcode.|
Comment 4 Jan Kissig 2024-04-26 12:41:22 UTC
Created attachment 165653 [details] [review]
BUG 36676: SIP2 drops connection on unknown patron id in fee paid message

When sending a fee paid message to SIP2 with an unknown patron id it will respond with an empty response followed by dropping the connection to a client.

to test on ktd (23.11):
a) perl /usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1   -l CPL --patron 2352900100046 -m fee_paid --fee-type FT --fee-amount 0.01
Output:
Trying 'fee_paid'
SEND: 3720240423    124447FT00USDBV0.01|AO|AA2352900100046|ACterm1|
Use of uninitialized value $data in concatenation (.) or string at /usr/share/koha/bin/sip_cli_emulator.pl line 355, <GEN0> chunk 1.
READ:

b) apply patch
c) perl /usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1   -l CPL --patron 2352900100046 -m fee_paid --fee-type FT --fee-amount 0.01
Output:
Trying 'fee_paid'
SEND: 3720240423    125602FT00USDBV0.01|AO|AA2352900100046|ACterm1|
READ: 38N20240423    125602AO|AA2352900100046|AFInvalid patron barcode.|
Comment 5 Jan Kissig 2024-04-26 13:18:03 UTC
(In reply to David Nind from comment #2)
> I've tested under 23.11 and the patch works as per the test plan.
> 
> However, on main, I can't seem to run the emulator - not quite sure why as
> it has worked fine in the past when testing other bugs:
> 
> perl /usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1
> -sp term1   -l CPL --patron 2352900100046 -m fee_paid --fee-type FT
> --fee-amount 0.01
> Attempting socket connection to 127.0.0.1:6001...failed! : Connection refused
> 
> The bug title and description need to be changed as per the commit message
> guidelines https://wiki.koha-community.org/wiki/Commit_messages
> 
> - Bug 36676: Short title
> 
>   Short description about what the bug fixes.
> 
>   Test plan:
>   ....
> 
> In addition, should this change be made to main (previously master) as well?

Hi David,

I was testing in 23.11. but yes, I think it should be made to main as well.

I also changed the patch title. There is still a lack of routine on writing patches from my side ;)
Comment 6 David Nind 2024-04-26 17:36:31 UTC
Thanks Jan!
Comment 7 David Nind 2024-04-29 00:13:26 UTC
I can't currently get the SIP emulator to work in KTD (when on main). I'll come back to this one (and other SIP bugs) once I get it working.
Comment 8 Jan Kissig 2024-05-06 07:10:29 UTC
Hi David,

I have the same problem on getting SIP-Server running on ktd (main). Commenting out the following service in /etc/koha/sites/kohadev/SIPconfig.xml solved the problem for me:

<!-- <service
        port="8023/tcp"
        transport="telnet"
        protocol="SIP/2.00"
        timeout="60" />
  -->
Comment 9 David Nind 2024-05-06 07:22:09 UTC
Created attachment 166182 [details] [review]
Bug 36676: SIP2 drops connection on unknown patron id in fee paid message

When sending a fee paid message to SIP2 with an unknown patron id it will respond with an empty response followed by dropping the connection to a client.

Test plan:
a) perl /usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1   -l CPL --patron 2352900100046 -m fee_paid --fee-type FT --fee-amount 0.01
Output:
Trying 'fee_paid'
SEND: 3720240423    124447FT00USDBV0.01|AO|AA2352900100046|ACterm1|
Use of uninitialized value $data in concatenation (.) or string at /usr/share/koha/bin/sip_cli_emulator.pl line 355, <GEN0> chunk 1.
READ:

b) apply patch
c) perl /usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1   -l CPL --patron 2352900100046 -m fee_paid --fee-type FT --fee-amount 0.01
Output:
Trying 'fee_paid'
SEND: 3720240423    125602FT00USDBV0.01|AO|AA2352900100046|ACterm1|
READ: 38N20240423    125602AO|AA2352900100046|AFInvalid patron barcode.|

Signed-off-by: David Nind <david@davidnind.com>
Comment 10 David Nind 2024-05-06 07:25:44 UTC
Comment on attachment 165653 [details] [review]
BUG 36676: SIP2 drops connection on unknown patron id in fee paid message

Thanks Jan!

That worked for me as well. Thank you for figuring it out!

I've signed off. (I also updated the commit message slightly.)

David

Note: backport required to at least 23.11

Response before applying the patch on main
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1   -l CPL --patron 2352900100046 -m fee_paid --fee-type FT --fee-amount 0.01
Attempting socket connection to 127.0.0.1:6001...connected!
Use of uninitialized value $hold_mode in string eq at misc/sip_cli_emulator.pl line 123.
SEND: 9300CNterm1|COterm1|CPCPL|
READ: 941

Trying 'fee_paid'
SEND: 3720240506    071820FT00USDBV0.01|AO|AA2352900100046|ACterm1|
Use of uninitialized value $data in concatenation (.) or string at misc/sip_cli_emulator.pl line 355, <GEN0> chunk 1.
READ: 

Response after applying the patch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

./misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1   -l CPL --patron 2352900100046 -m fee_paid --fee-type FT --fee-amount 0.01
Attempting socket connection to 127.0.0.1:6001...connected!
Use of uninitialized value $hold_mode in string eq at ./misc/sip_cli_emulator.pl line 123.
SEND: 9300CNterm1|COterm1|CPCPL|
READ: 941

Trying 'fee_paid'
SEND: 3720240506    072000FT00USDBV0.01|AO|AA2352900100046|ACterm1|
READ: 38N20240506    072000AO|AA2352900100046|AFInvalid patron barcode.|
Comment 11 Nick Clemens (kidclamp) 2024-05-10 11:40:28 UTC
Created attachment 166530 [details] [review]
Bug 36676: SIP2 drops connection on unknown patron id in fee paid message

When sending a fee paid message to SIP2 with an unknown patron id it will respond with an empty response followed by dropping the connection to a client.

Test plan:
a) perl /usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1   -l CPL --patron 2352900100046 -m fee_paid --fee-type FT --fee-amount 0.01
Output:
Trying 'fee_paid'
SEND: 3720240423    124447FT00USDBV0.01|AO|AA2352900100046|ACterm1|
Use of uninitialized value $data in concatenation (.) or string at /usr/share/koha/bin/sip_cli_emulator.pl line 355, <GEN0> chunk 1.
READ:

b) apply patch
c) perl /usr/share/koha/bin/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su term1 -sp term1   -l CPL --patron 2352900100046 -m fee_paid --fee-type FT --fee-amount 0.01
Output:
Trying 'fee_paid'
SEND: 3720240423    125602FT00USDBV0.01|AO|AA2352900100046|ACterm1|
READ: 38N20240423    125602AO|AA2352900100046|AFInvalid patron barcode.|

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 12 Katrin Fischer 2024-05-10 13:20:21 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 13 Fridolin Somers 2024-05-29 08:37:36 UTC
Looks like this is since Bug 23051 that changed return
Comment 14 Fridolin Somers 2024-05-29 08:40:38 UTC
Pushed to 23.11.x for 23.11.06
Comment 15 Lucas Gass 2024-05-30 19:05:38 UTC
Backported to 23.05.x for upcoming 23.05.12