Bugzilla – Attachment 171637 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.38 KB, created by
Lucas Gass (lukeg)
on 2024-09-17 17:38:22 UTC
(
hide
)
Description:
Bug 33462: Unit Tests
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2024-09-17 17:38:22 UTC
Size:
5.38 KB
patch
obsolete
>From 9e9aa50ceece3781b074911ccaeb8718735f30b5 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 > >Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com> >--- > t/db_dependent/Koha/Patron.t | 37 +++++++++++++++++ > t/db_dependent/Koha/Patron/Category.t | 58 ++++++++++++++++++++++++++- > 2 files changed, 94 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 970235ecc55..dd51c39e6e5 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -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 0300cb4721c..4e3670b78a3 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