Bug 29353 - Auth API tests can fail
Summary: Auth API tests can fail
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal (vote)
Assignee: Chris Cormack
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-28 14:15 UTC by Jonathan Druart
Modified: 2023-06-24 21:05 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2021-10-28 14:15:22 UTC
I usually run `qa` with --run-tests as root.

Tests are setting SessionStorage=tmp so you end up with root only permissions on the tmp directory:

root@kohadevbox:koha(master)$ ls -l /var/lib/koha/kohadev/tmp/
drwxr-xr-x 2 root root 4096 Oct 28 12:02 cgisess_koha_kohadev

And some REST API auth tests fail:

t/db_dependent/api/v1/auth.t ...........................   
    #   Failed test '403 Forbidden'                        
    #   at t/db_dependent/api/v1/auth.t line 75.           
    #          got: '401'                                  
    #     expected: '403'                                  
                                                           
    #   Failed test 'exact match for JSON Pointer "/error"'
    #   at t/db_dependent/api/v1/auth.t line 75.           
    #          got: 'Session has been expired.'            
    #     expected: 'Authorization failure. Missing required permission(s).'
    # Looks like you failed 2 tests of 20.                 
t/db_dependent/api/v1/auth.t ........................... 1/3 
#   Failed test 'under() tests'                            
#   at t/db_dependent/api/v1/auth.t line 108.              
t/db_dependent/api/v1/auth.t ........................... 3/3 # Looks like you failed 1 test of 3.
t/db_dependent/api/v1/auth.t ........................... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/3 subtests 
t/db_dependent/api/v1/auth_authenticate_api_request.t .. 1/5
    #   Failed test '200 OK'
    #   at t/db_dependent/api/v1/auth_authenticate_api_request.t line 131.          
    #          got: '401'
    #     expected: '200'
                                                                                     
    #   Failed test 'The 'koha.user' object is defined in the stash'
    #   at t/db_dependent/api/v1/auth_authenticate_api_request.t line 134.
                                                                                                   
    #   Failed test 'userenv set correctly'
    #   at t/db_dependent/api/v1/auth_authenticate_api_request.t line 137.
    #          got: undef                                                                            
    #     expected: '141'

        #   Failed test 'exact match for JSON Pointer ""'
        #   at t/db_dependent/api/v1/auth_authenticate_api_request.t line 154.
        #     Structures begin differing at:
        #          $got->{error} = 'Session has been expired.'
        #     $expected->{error} = 'Authentication failure.'
        # Looks like you failed 1 test of 3.

    #   Failed test 'logged-out tests'
    #   at t/db_dependent/api/v1/auth_authenticate_api_request.t line 157.
    # Looks like you planned 8 tests but ran 6.
    # Looks like you failed 4 tests of 6 run.

#   Failed test 'cookie-based tests'
#   at t/db_dependent/api/v1/auth_authenticate_api_request.t line 160.
t/db_dependent/api/v1/auth_authenticate_api_request.t .. 4/5 # Looks like you failed 1 test of 5.
t/db_dependent/api/v1/auth_authenticate_api_request.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/5 subtests
Comment 1 Jonathan Druart 2021-10-28 14:15:56 UTC
The workaround is to remove the tmp directory /var/lib/koha/kohadev/tmp/cgisess_koha_kohadev/
Comment 2 Tomás Cohen Arazi 2021-10-28 22:15:16 UTC
(In reply to Jonathan Druart from comment #1)
> The workaround is to remove the tmp directory
> /var/lib/koha/kohadev/tmp/cgisess_koha_kohadev/

I will add the qa alias to the kshell env and discourage running as root.
Comment 3 Katrin Fischer 2023-06-24 21:05:15 UTC
(In reply to Tomás Cohen Arazi from comment #2)
> (In reply to Jonathan Druart from comment #1)
> > The workaround is to remove the tmp directory
> > /var/lib/koha/kohadev/tmp/cgisess_koha_kohadev/
> 
> I will add the qa alias to the kshell env and discourage running as root.

I believe this has been done in ktd now :) Please reopen if you disagree.