Bug 27587 - Use Basic auth on API tests
Summary: Use Basic auth on API tests
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Tomás Cohen Arazi (tcohen)
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-01 19:48 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2021-12-13 21:13 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.05.00
Circulation function:


Attachments
Bug 27587: Adapt patrons_accounts.t (8.53 KB, patch)
2021-02-02 13:33 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 27587: Adapt patrons_password.t (12.61 KB, patch)
2021-02-02 13:33 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 27587: Adapt acquisitions_vendors.t (21.37 KB, patch)
2021-02-02 13:33 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 27587: Adapt illrequests.t (8.06 KB, patch)
2021-02-02 13:33 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 27587: Adapt stockrotationstage.t (6.82 KB, patch)
2021-02-02 13:33 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 27587: Adapt patrons_accounts.t (8.59 KB, patch)
2021-02-04 13:15 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27587: Adapt patrons_password.t (12.67 KB, patch)
2021-02-04 13:15 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27587: Adapt acquisitions_vendors.t (21.43 KB, patch)
2021-02-04 13:15 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27587: Adapt illrequests.t (8.12 KB, patch)
2021-02-04 13:15 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27587: Adapt stockrotationstage.t (6.88 KB, patch)
2021-02-04 13:15 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27587: Use Basic auth on API tests - patrons_accounts.t (8.61 KB, patch)
2021-02-08 14:30 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27587: Use Basic auth on API tests - patrons_password.t (12.69 KB, patch)
2021-02-08 14:30 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27587: Use Basic auth on API tests - acquisitions_vendors.t (21.45 KB, patch)
2021-02-08 14:30 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27587: Use Basic auth on API tests - illrequests.t (8.15 KB, patch)
2021-02-08 14:30 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27587: Use Basic auth on API tests - stockrotationstage.t (6.91 KB, patch)
2021-02-08 14:30 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27857: Get the right column (2.89 KB, patch)
2021-03-19 11:03 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi (tcohen) 2021-02-01 19:48:06 UTC
Even if it is correct to use either authentication method, we are trying to clean our tests so consistency is key for users using existing tests as examples for the new ones they want/need to introduce.

There are specific tests for the cookie (and OAuth2) authentication, so we can use the built-in Basic authentication mechanism from Test::Mojo and have simpler tests written.

This bug should include patches to fix existing tests.
Comment 1 Tomás Cohen Arazi (tcohen) 2021-02-02 13:33:06 UTC
Test plan:
1. Apply this patches
2. Run:
   $ kshell
  k$ git diff origin/master --name-only | xargs prove 
=> SUCCESS: Tests pass!
3. Sign off :-D
Comment 2 Tomás Cohen Arazi (tcohen) 2021-02-02 13:33:41 UTC
Created attachment 116211 [details] [review]
Bug 27587: Adapt patrons_accounts.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 3 Tomás Cohen Arazi (tcohen) 2021-02-02 13:33:45 UTC
Created attachment 116212 [details] [review]
Bug 27587: Adapt patrons_password.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 4 Tomás Cohen Arazi (tcohen) 2021-02-02 13:33:50 UTC
Created attachment 116213 [details] [review]
Bug 27587: Adapt acquisitions_vendors.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 5 Tomás Cohen Arazi (tcohen) 2021-02-02 13:33:55 UTC
Created attachment 116214 [details] [review]
Bug 27587: Adapt illrequests.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 6 Tomás Cohen Arazi (tcohen) 2021-02-02 13:33:59 UTC
Created attachment 116215 [details] [review]
Bug 27587: Adapt stockrotationstage.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 7 Tomás Cohen Arazi (tcohen) 2021-02-02 13:35:42 UTC
I forgot to mention on the test plan:

- Run:
 $ git grep "( 'SessionStorage', 'tmp' )"
=> SUCCESS: no API tests are old-style (besides auth ones, in which we explicitly want to test cookie auth).
Comment 8 Martin Renvoize (ashimema) 2021-02-04 13:15:23 UTC
Created attachment 116319 [details] [review]
Bug 27587: Adapt patrons_accounts.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 9 Martin Renvoize (ashimema) 2021-02-04 13:15:26 UTC
Created attachment 116320 [details] [review]
Bug 27587: Adapt patrons_password.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 10 Martin Renvoize (ashimema) 2021-02-04 13:15:30 UTC
Created attachment 116321 [details] [review]
Bug 27587: Adapt acquisitions_vendors.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 11 Martin Renvoize (ashimema) 2021-02-04 13:15:33 UTC
Created attachment 116322 [details] [review]
Bug 27587: Adapt illrequests.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 12 Martin Renvoize (ashimema) 2021-02-04 13:15:36 UTC
Created attachment 116323 [details] [review]
Bug 27587: Adapt stockrotationstage.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 13 Martin Renvoize (ashimema) 2021-02-04 13:16:22 UTC
Nice bit of tidy up.. passes qa scripts, unit tests still pass.. grep returns expected results.


Going straight for QA here.. :)
Comment 14 Jonathan Druart 2021-02-08 14:30:23 UTC
Created attachment 116505 [details] [review]
Bug 27587: Use Basic auth on API tests - patrons_accounts.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 15 Jonathan Druart 2021-02-08 14:30:26 UTC
Created attachment 116506 [details] [review]
Bug 27587: Use Basic auth on API tests - patrons_password.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 16 Jonathan Druart 2021-02-08 14:30:29 UTC
Created attachment 116507 [details] [review]
Bug 27587: Use Basic auth on API tests - acquisitions_vendors.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 17 Jonathan Druart 2021-02-08 14:30:33 UTC
Created attachment 116508 [details] [review]
Bug 27587: Use Basic auth on API tests - illrequests.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 18 Jonathan Druart 2021-02-08 14:30:36 UTC
Created attachment 116509 [details] [review]
Bug 27587: Use Basic auth on API tests - stockrotationstage.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 19 Jonathan Druart 2021-02-08 16:05:13 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 20 Fridolin Somers 2021-02-12 14:30:24 UTC
Enhancement not pushed to 20.11.x
Comment 21 Tomás Cohen Arazi (tcohen) 2021-03-19 11:03:26 UTC
Created attachment 118506 [details] [review]
Bug 27857: Get the right column

This patch makes the search for mandatory attribute types actually use
'code' instead of 'class' for comparisson.

Tests are added to cover this behavior.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Patron.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 22 Tomás Cohen Arazi (tcohen) 2021-03-31 11:18:17 UTC
Comment on attachment 118506 [details] [review]
Bug 27857: Get the right column

Typo, wrong bug. Obsoletingi the last patch.