From 03d9c1e8522d39c4e061d5b137b4701d0133d97d Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 13 Dec 2022 22:25:14 +0000 Subject: [PATCH] Bug 30624: Unit tests To test: 1. Apply patch, updatedatabase, restart_all 2. Have a user with superlibrarian privileges ( User1 ) 3. Have a user who has staff access and circulate privileges but is not a super librarian. ( User2 ) Make note of this users home library 4. Turn on the system preference 'CircSidebar'. -MAIN log in ( auth.tt ) 5. As User1, go to the main login screen and try logging in. You should be able to log in AND you should be able to properly chnage your branch BEFORE logging in. 6. As User2, to to the main login screnn amd try logging in. You should be able to but if you try and switch your libraray to anything beside the user's home branch it will not work. You will be logged in at your home branch. 7. For User2, set the new top level permission 'Allow staff to change logged in library (loggedinlibrary). 8. Now you should be able to successfully switch libraries before log in. 9. Turn the 'loggedinlibrary' permission back off for User2. -AFTER log in- 10. With User1, click on your name/branch in the top right, you should see the the link 'Set library' at the top. If you turn on 'UseCirculationDesks' the link will be 'Set library and desk'. 11. With User2, click on your name/branch in the top right. If you have 'UseCirculationDesks' on, you should see 'Set desk', otherwise you should see nothing. 12. Repeat step 7. 13. NOw if you click on your name/branch in the top right, you should see the the link 'Set library' at the top. If you turn on 'UseCirculationDesks' the link will be 'Set library and desk'. 14. Repeat Step 9. -CircSideBar- 15. With 'CircSideBar' turned on, go to any ciculation page (Holds queue, Holds to pull, Holds awaiting pickup) with User1. You will see the 'Set library' link. If 'UseCirculationDesks' is on you will see a 'Set library and desk'. 16. Try with User2 and you will not see a 'Set library' link. If 'UseCirculationDesks' is on you will see a 'Set desk' link. 17. Repeat step 7. 18. For with User2 you go to any ciculation page (Holds queue, Holds to pull, Holds awaiting pickup). You will see the 'Set library' link. If 'UseCirculationDesks' is on you will see a 'Set library and desk'. 19. Repeat step 9. -Set library page- 20. Go to the set library page (http://localhost:8081/cgi-bin/koha/circ/set-library.pl) with User1. You will see a dropdown for 'Set library'. Make sure you can change your library successfully. 21. Go to the set library page (http://localhost:8081/cgi-bin/koha/circ/set-library.pl) with User2. You should NOT see see a dropdown for 'Set library'. 22. Repeat step 7. 23. Go to the set library page (http://localhost:8081/cgi-bin/koha/circ/set-library.pl) with User2. Now you should see a dropdown for 'Set library'. --- t/db_dependent/Auth.t | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t index ee690f79ae6..a126862af53 100755 --- a/t/db_dependent/Auth.t +++ b/t/db_dependent/Auth.t @@ -10,7 +10,7 @@ use CGI qw ( -utf8 ); use Test::MockObject; use Test::MockModule; use List::MoreUtils qw/all any none/; -use Test::More tests => 17; +use Test::More tests => 18; use Test::Warn; use t::lib::Mocks; use t::lib::TestBuilder; @@ -857,4 +857,42 @@ subtest 'create_basic_session tests' => sub { is( $session->param('interface'), 'intranet', 'Staff interface gets converted to intranet' ); }; +subtest 'can change loggedinlibrary tests' => sub { + plan tests => 3; + + my $superlibrarian = $builder->build( + { + source => 'Borrower', + value => { + surname => 'Superlib', + flags => 1, + }, + } + ); + my $staff1 = $builder->build( + { + source => 'Borrower', + value => { + surname => 'Gass', + flags => 2**29, + }, + } + ); + my $staff2 = $builder->build( + { + source => 'Borrower', + value => { + surname => 'Lucas', + flags => 4, + }, + } + ); + my $r = haspermission( $superlibrarian->{userid} ); + my $r2 = haspermission( $staff1->{userid} ); + my $r3 = haspermission( $staff2->{userid} ); + is( $r->{superlibrarian}, 1, 'Superlibrarian can change branch' ); + is( $r2->{loggedinlibrary}, 1, 'Staff with loggedinlibrary permission can change branch' ); + is( $r3->{loggedinlibrary}, 0, 'Staff without loggedinlibrary permmision or superlibrarian cannot change branch' ); + +}; $schema->storage->txn_rollback; -- 2.30.2