https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43848 Bug ID: 43848 Summary: Share SIP request parsing and building between server, emulator and tester Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: SIP2 Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org Depends on: 42769 Target Milestone: --- Bug 42769 adds a tool to the staff interface that runs a SIP2 message through the real SIP handlers (Koha::SIP2::MessageTester). To do that it has to parse a request and build a server context the way the SIP server does, and build requests the way a terminal does. All of this is currently buried in code that also does something else, so each caller ends up with its own copy: - C4::SIP::Sip::MsgType::handle both parses a request and answers it. - C4::SIP::Sip::MsgType::login_core both authenticates a terminal and builds the account, institution, policy and ILS connection it works with. - misc/sip_cli_emulator.pl builds every request a terminal sends, but as subs inside a script, so nothing else can use them. This bug pulls the shared parts out, so the SIP server, the SIP command line emulator and the SIP2 message tester use the same code: - MsgType::parse_message: the part of handle() that sets the field delimiter, checks and removes the error detection suffix and splits a message into fixed and variable length fields. handle() calls it, a caller that only wants the parsed message can get it without anything being printed. - MsgType::build_session: what login_core does once a terminal has authenticated. login_core calls it. - Koha::SIP2::RequestBuilder: the request builders of the emulator, now shared by the emulator and the message tester. - The message tester then reads a request exactly as the handler does (error detection suffix, checksum) and builds requests with the shared builders. There is no change in behaviour for the SIP server. Two small fixes to the emulator come with the move: the item information request carried a language field that the server's template for that message does not have (so the institution field was lost), and a field value of 0 was sent as an empty value. The new tests build each request and have the SIP server's own parser read it back. Test plan: 1. Apply the patches of bug 42769 and then the patches of this bug 2. Run prove t/db_dependent/SIP/ t/SIP/ t/Koha/SIP2/ t/db_dependent/Koha/SIP2/ t/db_dependent/api/v1/sip2_account_test_message.t 3. Confirm that all tests pass 4. Optionally run misc/sip_cli_emulator.pl against a SIP server (-a host -p port -su user -sp password -l institution --patron X --item Y -m patron_status_request -m patron_information -m item_information -m checkout -m checkin) and confirm login and every message still gets a response, and that the item information response names the institution 5. Sign off :-D Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42769 [Bug 42769] Add a SIP testing tool to the staff web interface -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.