Bugzilla – Attachment 154395 Details for
Bug 33462
Force password change for new patrons entered by staff
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33462: Unit Tests
Bug-33462-Unit-Tests.patch (text/plain), 5.71 KB, created by
Biblibre Sandboxes
on 2023-08-12 23:42:35 UTC
(
hide
)
Description:
Bug 33462: Unit Tests
Filename:
MIME Type:
Creator:
Biblibre Sandboxes
Created:
2023-08-12 23:42:35 UTC
Size:
5.71 KB
patch
obsolete
>From bf7701395408470ff203d20e168a2ec62ebfb74a Mon Sep 17 00:00:00 2001 >From: Sam Lau <samalau@gmail.com> >Date: Mon, 17 Jul 2023 21:30:54 +0000 >Subject: [PATCH] Bug 33462: Unit Tests > >prove t/db_dependent/Koha/Patron/Category.t >prove t/db_dependent/Koha/Patron.t > >Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org> >--- > t/db_dependent/Koha/Patron.t | 41 +++++++++++++++++- > t/db_dependent/Koha/Patron/Category.t | 60 ++++++++++++++++++++++++++- > 2 files changed, 98 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 5d05a16efd..1c6cb4c3cc 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 24; >+use Test::More tests => 25; > use Test::Exception; > use Test::Warn; > >@@ -30,7 +30,6 @@ use Koha::ArticleRequests; > use Koha::Patrons; > use Koha::Patron::Relationships; > use C4::Circulation qw( AddIssue AddReturn ); >- > use t::lib::TestBuilder; > use t::lib::Mocks; > >@@ -975,6 +974,7 @@ subtest 'password expiration tests' => sub { > my $category = $builder->build_object({ class => 'Koha::Patron::Categories', value => { > password_expiry_days => 10, > require_strong_password => 0, >+ force_password_reset_when_set_by_staff => 0, > } > }); > my $patron = $builder->build_object({ class=> 'Koha::Patrons', value => { >@@ -1061,6 +1061,43 @@ subtest 'password expiration tests' => sub { > > }; > >+subtest 'force_password_reset_when_set_by_staff tests' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $category = $builder->build_object({ >+ class => 'Koha::Patron::Categories', >+ value => { >+ force_password_reset_when_set_by_staff => 1, >+ require_strong_password => 0, >+ } >+ }); >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { >+ categorycode => $category->categorycode, >+ password => 'hats' >+ } >+ }); >+ >+ $patron->delete()->store()->discard_changes(); >+ is( $patron->password_expired, 1, "Patron forced into changing password, password expired."); >+ >+ $patron->category->force_password_reset_when_set_by_staff(0)->store(); >+ $patron->delete()->store()->discard_changes(); >+ is( $patron->password_expired, 0, "Patron not forced into changing password, password not expired."); >+ >+ $patron->category->force_password_reset_when_set_by_staff(1)->store(); >+ t::lib::Mocks::mock_preference( 'PatronSelfRegistrationDefaultCategory', $patron->categorycode ); >+ $patron->delete()->store()->discard_changes(); >+ is( $patron->password_expired, 0, "Patron forced into changing password but patron is self registered, password not expired."); >+ >+ >+ $schema->storage->txn_rollback; >+ >+}; >+ > subtest 'safe_to_delete() tests' => sub { > > plan tests => 14; >diff --git a/t/db_dependent/Koha/Patron/Category.t b/t/db_dependent/Koha/Patron/Category.t >index eeed784348..043521b9a3 100755 >--- a/t/db_dependent/Koha/Patron/Category.t >+++ b/t/db_dependent/Koha/Patron/Category.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 7; >+use Test::More tests => 8; > > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -204,6 +204,64 @@ subtest 'effective_require_strong_password' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'effective_force_password_reset_when_set_by_staff() tests' => sub { >+ >+ plan tests => 2; >+ >+ subtest 'specific overrides global' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $category = $builder->build_object({ >+ class => 'Koha::Patron::Categories', >+ value => { >+ force_password_reset_when_set_by_staff => 1 >+ } >+ }); >+ >+ t::lib::Mocks::mock_preference( 'ForcePasswordResetWhenSetByStaff', 0 ); >+ ok( $category->effective_force_password_reset_when_set_by_staff, 'ForcePasswordResetWhenSetByStaff unset, but category has the flag set to 1' ); >+ >+ t::lib::Mocks::mock_preference( 'ForcePasswordResetWhenSetByStaff', 1 ); >+ ok( $category->effective_force_password_reset_when_set_by_staff, 'ForcePasswordResetWhenSetByStaff set and category has the flag set to 1' ); >+ >+ # disable >+ $category->force_password_reset_when_set_by_staff( 0 )->store->discard_changes; >+ >+ t::lib::Mocks::mock_preference( 'ForcePasswordResetWhenSetByStaff', 0 ); >+ ok( !$category->effective_force_password_reset_when_set_by_staff, 'ForcePasswordResetWhenSetByStaff unset, but category has the flag set to 0' ); >+ >+ t::lib::Mocks::mock_preference( 'ForcePasswordResetWhenSetByStaff', 1 ); >+ ok( !$category->effective_force_password_reset_when_set_by_staff, 'ForcePasswordResetWhenSetByStaff set and category has the flag set to 0' ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ >+ subtest 'no specific rule, global applies' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $category = $builder->build_object({ >+ class => 'Koha::Patron::Categories', >+ value => { >+ force_password_reset_when_set_by_staff => undef >+ } >+ }); >+ >+ t::lib::Mocks::mock_preference( 'ForcePasswordResetWhenSetByStaff', 0 ); >+ ok( !$category->effective_force_password_reset_when_set_by_staff, 'ForcePasswordResetWhenSetByStaff set to 0 used' ); >+ >+ t::lib::Mocks::mock_preference( 'ForcePasswordResetWhenSetByStaff', 1 ); >+ ok( $category->effective_force_password_reset_when_set_by_staff, 'ForcePasswordResetWhenSetByStaff set to 1 used' ); >+ >+ $schema->storage->txn_rollback; >+ }; >+}; >+ > subtest 'get_password_expiry_date() tests' => sub { > > plan tests => 2; >-- >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 33462
:
153687
|
153688
|
153689
|
154395
|
154396
|
154397
|
167582
|
167583
|
167584
|
167585
|
167586
|
167587
|
167981
|
167982
|
167983
|
167984
|
167985
|
167986
|
168413
|
168414
|
168415
|
168416
|
168417
|
168418
|
168452
|
168453
|
168454
|
168455
|
168456
|
168457
|
171634
|
171635
|
171636
|
171637
|
171638
|
171639
|
171640
|
172030
|
172031
|
172032
|
172033
|
172034
|
172035
|
172036
|
172064
|
172065
|
172066
|
172067
|
172068
|
172069
|
172070
|
172071
|
173864
|
173865