Bugzilla – Attachment 145049 Details for
Bug 30624
Add a permission to control the ability to change the logged in library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30624: Unit tests
Bug-30624-Unit-tests.patch (text/plain), 3.03 KB, created by
Lucas Gass (lukeg)
on 2023-01-04 22:21:13 UTC
(
hide
)
Description:
Bug 30624: Unit tests
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2023-01-04 22:21:13 UTC
Size:
3.03 KB
patch
obsolete
>From 225f7b3a7b3596ea637a603c2101fa6e2365f40e Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Wed, 14 Dec 2022 21:53:18 +0000 >Subject: [PATCH] Bug 30624: Unit tests > >Signed-off by: Bob Bennhoff/AspenCat Team >--- > t/db_dependent/Auth.t | 43 +++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 41 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t >index ee690f79ae6..63c6418809c 100755 >--- a/t/db_dependent/Auth.t >+++ b/t/db_dependent/Auth.t >@@ -41,7 +41,7 @@ $schema->storage->txn_begin; > > subtest 'checkauth() tests' => sub { > >- plan tests => 6; >+ plan tests => 7; > > my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => undef } }); > >@@ -260,8 +260,47 @@ subtest 'checkauth() tests' => sub { > is( $auth_status, 'ok', 'User waiting for 2FA setup, pref was disabled, access OK' ); > }; > >- C4::Context->_new_userenv; # For next tests >+ subtest 'loggedinlibrary permission tests' => sub { >+ >+ plan tests => 3; >+ my $staff_user = $builder->build_object( >+ { class => 'Koha::Patrons', value => { flags => 536870916 } } ); > >+ my $branch = $builder->build_object({ class => 'Koha::Libraries' }); >+ >+ my $password = 'password'; >+ t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); >+ $staff_user->set_password( { password => $password } ); >+ my $cgi = Test::MockObject->new(); >+ $cgi->mock( 'cookie', sub { return; } ); >+ $cgi->mock( >+ 'param', >+ sub { >+ my ( $self, $param ) = @_; >+ if ( $param eq 'userid' ) { return $staff_user->userid; } >+ elsif ( $param eq 'password' ) { return $password; } >+ elsif ( $param eq 'branch' ) { return $branch->branchcode; } >+ else { return; } >+ } >+ ); >+ >+ $cgi->mock( 'request_method', sub { return 'POST' } ); >+ my ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired' ); >+ my $sesh = C4::Auth::get_session($sessionID); >+ is( $sesh->param('branch'), $branch->branchcode, "If user has permission, they should be able to choose a branch" ); >+ >+ $staff_user->flags(4)->store->discard_changes; >+ ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired' ); >+ $sesh = C4::Auth::get_session($sessionID); >+ is( $sesh->param('branch'), $staff_user->branchcode, "If user has not permission, they should not be able to choose a branch" ); >+ >+ $staff_user->flags(1)->store->discard_changes; >+ ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 'authrequired' ); >+ $sesh = C4::Auth::get_session($sessionID); >+ is( $sesh->param('branch'), $branch->branchcode, "If user is superlibrarian, they should be able to choose a branch" ); >+ >+ }; >+ C4::Context->_new_userenv; # For next tests > }; > > subtest 'track_login_daily tests' => sub { >-- >2.30.2
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 30624
:
136055
|
136076
|
137733
|
138377
|
138378
|
139961
|
139962
|
139963
|
141069
|
141070
|
141071
|
142269
|
142270
|
142271
|
144557
|
144559
|
144584
|
144594
|
144595
|
144596
|
145048
|
145049
|
145631
|
147509
|
147753
|
147754
|
147755
|
147756
|
148116