Bugzilla – Attachment 167586 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.46 KB, created by
Sam Lau
on 2024-06-07 19:42:49 UTC
(
hide
)
Description:
Bug 33462: Unit Tests
Filename:
MIME Type:
Creator:
Sam Lau
Created:
2024-06-07 19:42:49 UTC
Size:
5.46 KB
patch
obsolete
>From cf611ee0396dcea09f4186918f13ef3bae9a8b83 Mon Sep 17 00:00:00 2001 >From: Sam Lau <samalau@gmail.com> >Date: Fri, 7 Jun 2024 19:01:03 +0000 >Subject: [PATCH] Bug 33462: Unit Tests > >prove t/db_dependent/Koha/Patron/Category.t >prove t/db_dependent/Koha/Patron.t >--- > t/db_dependent/Koha/Patron.t | 39 +++++++++++++++++- > t/db_dependent/Koha/Patron/Category.t | 58 ++++++++++++++++++++++++++- > 2 files changed, 95 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index bad1cc1bfa..f63fcbfc2d 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 => 33; >+use Test::More tests => 34; > use Test::Exception; > use Test::Warn; > use Time::Fake; >@@ -1359,6 +1359,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 => { >@@ -1445,6 +1446,42 @@ 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 => 17; >diff --git a/t/db_dependent/Koha/Patron/Category.t b/t/db_dependent/Koha/Patron/Category.t >index 0300cb4721..4e3670b78a 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,62 @@ 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 => 3; >-- >2.39.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