We need to provide tests for this code. It will require mocking, or using the Mojo mocking, but should be done before we add more in this area.
Created attachment 186630 [details] [review] Bug 33782: Add unit tests for Koha::Auth::Client::OAuth This patch adds comprehensive unit tests for the OAuth authentication client, specifically covering the _get_data_and_patron method which handles JWT token processing and UserInfo endpoint integration. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Auth/Client/OAuth.t => SUCCESS: Tests pass! 3. Tests cover: - JWT id_token processing and patron matching - UserInfo endpoint calls and data merging - Non-existent user scenarios - Combined JWT + UserInfo data sources 4. Sign off :-D status: Needs Signoff
Created attachment 186631 [details] [review] Bug 33782: (follow-up) Remove code duplication in OAuth client This patch eliminates duplicated patron search logic in the _get_data_and_patron method by extracting it into a dedicated helper method _find_patron_by_matchpoint. Changes: - Extract duplicated patron search logic (8 lines removed) - Add _find_patron_by_matchpoint helper method - Improve code maintainability and readability - No functional changes - behavior preserved Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Auth/Client/OAuth.t => SUCCESS: Tests pass! OAuth client tests work correctly k$ prove t/db_dependent/api/v1/oauth.t => SUCCESS: Tests pass! OAuth API integration works 3. Confirm OAuth authentication still works in browser 4. Sign off :-D