Bug 27587

Summary: Use Basic auth on API tests
Product: Koha Reporter: Tomás Cohen Arazi (tcohen) <tomascohen>
Component: REST APIAssignee: Tomás Cohen Arazi (tcohen) <tomascohen>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P5 - low CC: caroline.cyr-la-rose, fridolin.somers, jonathan.druart, martin.renvoize, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27330
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
Bug 27587: Adapt patrons_password.t
Bug 27587: Adapt acquisitions_vendors.t
Bug 27587: Adapt illrequests.t
Bug 27587: Adapt stockrotationstage.t
Bug 27587: Adapt patrons_accounts.t
Bug 27587: Adapt patrons_password.t
Bug 27587: Adapt acquisitions_vendors.t
Bug 27587: Adapt illrequests.t
Bug 27587: Adapt stockrotationstage.t
Bug 27587: Use Basic auth on API tests - patrons_accounts.t
Bug 27587: Use Basic auth on API tests - patrons_password.t
Bug 27587: Use Basic auth on API tests - acquisitions_vendors.t
Bug 27587: Use Basic auth on API tests - illrequests.t
Bug 27587: Use Basic auth on API tests - stockrotationstage.t
Bug 27857: Get the right column

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.