Bugzilla – Attachment 100692 Details for
Bug 24862
Wrong behaviour on anonymous sessions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24862: Regression tests
Bug-24862-Regression-tests.patch (text/plain), 2.24 KB, created by
David Nind
on 2020-03-14 08:47:11 UTC
(
hide
)
Description:
Bug 24862: Regression tests
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-03-14 08:47:11 UTC
Size:
2.24 KB
patch
obsolete
>From c1151f2a3a5f3d551e5c93d106aa471a4c129f30 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 13 Mar 2020 11:44:03 -0300 >Subject: [PATCH] Bug 24862: Regression tests > >This patch introduces tests for the expected behaviour on API routes >that expect a logged in user, but the request is made with an anonymous >session cookie. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/api/v1/auth_authenticate_api_request.t >=> FAIL: Tests fail because the situation is not handled correctly in >the code > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../api/v1/auth_authenticate_api_request.t | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/auth_authenticate_api_request.t b/t/db_dependent/api/v1/auth_authenticate_api_request.t >index fbed3461a8..75348b90f5 100755 >--- a/t/db_dependent/api/v1/auth_authenticate_api_request.t >+++ b/t/db_dependent/api/v1/auth_authenticate_api_request.t >@@ -100,7 +100,7 @@ subtest 'token-based tests' => sub { > > subtest 'cookie-based tests' => sub { > >- plan tests => 5; >+ plan tests => 6; > > $schema->storage->txn_begin; > >@@ -119,6 +119,25 @@ subtest 'cookie-based tests' => sub { > is( ref($user), 'Koha::Patron', 'Stashed koha.user object type is Koha::Patron') and > is( $user->borrowernumber, $borrowernumber, 'The stashed user is the right one' ); > >+ subtest 'logged-out tests' => sub { >+ plan tests => 3; >+ >+ # Generate an anonymous session >+ my $session = C4::Auth::get_session(''); >+ $session->param( 'ip', $remote_address ); >+ $session->param( 'lasttime', time() ); >+ $session->param( 'sessiontype', 'anon' ); >+ $session->flush; >+ >+ my $tx = $t->ua->build_tx( GET => '/api/v1/libraries' ); >+ $tx->req->cookies({ name => 'CGISESSID', value => $session->id }); >+ $tx->req->env({ REMOTE_ADDR => $remote_address }); >+ >+ $t->request_ok($tx) >+ ->status_is( 401, 'Anonymous session on permission protected resource returns 401' ) >+ ->json_is( { error => 'Authentication failure.' } ); >+ }; >+ > $schema->storage->txn_rollback; > }; > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24862
:
100683
|
100684
|
100692
|
100693
|
100734
|
100735