Bugzilla – Attachment 107163 Details for
Bug 23816
Allow to have different password strength and length settings for different patron categories
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23816: Fix other tests
Bug-23816-Fix-other-tests.patch (text/plain), 13.53 KB, created by
Agustín Moyano
on 2020-07-21 15:53:06 UTC
(
hide
)
Description:
Bug 23816: Fix other tests
Filename:
MIME Type:
Creator:
Agustín Moyano
Created:
2020-07-21 15:53:06 UTC
Size:
13.53 KB
patch
obsolete
>From 731117dd552d66894cc88c4d6c675019be2852b2 Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Wed, 15 Apr 2020 17:13:07 -0300 >Subject: [PATCH] Bug 23816: Fix other tests > >This patch fixes other tests broken by new password length and strength override > >To test: >1. prove t/db_dependent/Auth.t \ > t/db_dependent/Koha/Patron.t \ > t/db_dependent/Koha/Patrons.t \ > t/db_dependent/Koha/Patrons/Import.t \ > t/db_dependent/Koha/Plugins/Patron.t \ > t/db_dependent/Search/History.t \ > t/db_dependent/api/v1/auth_basic.t \ > t/db_dependent/api/v1/checkouts.t \ > t/db_dependent/api/v1/patrons_password.t \ > t/db_dependent/selenium/authentication.t \ > t/db_dependent/selenium/regressions.t >2. Sign off > >Sponsored-by: Northeast Kansas Library - NEKLS > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >--- > t/db_dependent/Auth.t | 6 ++++-- > t/db_dependent/Koha/Patrons.t | 6 ++++-- > t/db_dependent/Koha/Patrons/Import.t | 4 ++-- > t/db_dependent/Koha/Plugins/Patron.t | 2 +- > t/db_dependent/Search/History.t | 3 ++- > t/db_dependent/api/v1/auth_basic.t | 6 ++++-- > t/db_dependent/api/v1/checkouts.t | 6 ++++-- > t/db_dependent/api/v1/patrons_password.t | 3 ++- > t/db_dependent/selenium/authentication.t | 6 ++++-- > t/db_dependent/selenium/regressions.t | 6 ++++-- > 10 files changed, 31 insertions(+), 17 deletions(-) > >diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t >index e149aec867..67ec699c17 100644 >--- a/t/db_dependent/Auth.t >+++ b/t/db_dependent/Auth.t >@@ -127,7 +127,8 @@ subtest 'no_set_userenv parameter tests' => sub { > plan tests => 7; > > my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >- my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {min_password_length => undef, require_strong_password => undef} } ); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $category->categorycode } } ); > my $password = 'password'; > > t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); >@@ -149,7 +150,8 @@ subtest 'checkpw lockout tests' => sub { > plan tests => 5; > > my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >- my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {min_password_length => undef, require_strong_password => undef} } ); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $category->categorycode } } ); > my $password = 'password'; > t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); > t::lib::Mocks::mock_preference( 'FailedLoginAttempts', 1 ); >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 4f434adc3c..0d7baf3680 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -1735,7 +1735,8 @@ subtest '->store' => sub { > my $print_error = $schema->storage->dbh->{PrintError}; > $schema->storage->dbh->{PrintError} = 0; ; # FIXME This does not longer work - because of the transaction in Koha::Patron->store? > >- my $patron_1 = $builder->build_object({class=> 'Koha::Patrons'}); >+ my $category = $builder->build_object({class=> 'Koha::Patron::Categories', value=>{min_password_length => undef, require_strong_password => undef}}); >+ my $patron_1 = $builder->build_object({class=> 'Koha::Patrons', value=> { categorycode => $category->categorycode}}); > my $patron_2 = $builder->build_object({class=> 'Koha::Patrons'}); > > throws_ok >@@ -1788,7 +1789,8 @@ subtest '->set_password' => sub { > > $schema->storage->txn_begin; > >- my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { login_attempts => 3 } } ); >+ my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => { min_password_length => undef, require_strong_password => undef } } ); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { login_attempts => 3, categorycode => $category->categorycode } } ); > > # Disable logging password changes for this tests > t::lib::Mocks::mock_preference( 'BorrowersLog', 0 ); >diff --git a/t/db_dependent/Koha/Patrons/Import.t b/t/db_dependent/Koha/Patrons/Import.t >index a6f09e41ab..a94f0c283e 100644 >--- a/t/db_dependent/Koha/Patrons/Import.t >+++ b/t/db_dependent/Koha/Patrons/Import.t >@@ -443,8 +443,8 @@ subtest 'test_import_with_password_overwrite' => sub { > > #Setup our info > my $branchcode = $builder->build({ source => "Branch"})->{branchcode}; >- my $categorycode = $builder->build({ source => "Category", value => { category_type => 'A' } })->{categorycode}; >- my $staff_categorycode = $builder->build({ source => "Category", value => { category_type => 'S' } })->{categorycode}; >+ my $categorycode = $builder->build({ source => "Category", value => { category_type => 'A', min_password_length => undef, require_strong_password => undef } })->{categorycode}; >+ my $staff_categorycode = $builder->build({ source => "Category", value => { category_type => 'S', min_password_length => undef, require_strong_password => undef } })->{categorycode}; > my $csv_headers = 'surname,userid,branchcode,categorycode,password'; > my $csv_password = "Worrell,ErnestP,$branchcode,$categorycode,Ernest11"; > my $csv_password_change = "Worrell,ErnestP,$branchcode,$categorycode,Vern1234"; >diff --git a/t/db_dependent/Koha/Plugins/Patron.t b/t/db_dependent/Koha/Plugins/Patron.t >index c8b2e86f25..3510b8c9ef 100644 >--- a/t/db_dependent/Koha/Plugins/Patron.t >+++ b/t/db_dependent/Koha/Plugins/Patron.t >@@ -55,7 +55,7 @@ subtest 'check_password hook tests' => sub { > my $plugin = Koha::Plugin::Test->new->enable; > > my $library = $builder->build( { source => 'Branch' } ); >- my $category = $builder->build( { source => 'Category' } ); >+ my $category = $builder->build( { source => 'Category', value => {min_password_length => undef, require_strong_password => undef} } ); > my $patron = Koha::Patron->new( > { > cardnumber => 'test_cn_1', >diff --git a/t/db_dependent/Search/History.t b/t/db_dependent/Search/History.t >index 2e3aa1fd1e..051234d1af 100644 >--- a/t/db_dependent/Search/History.t >+++ b/t/db_dependent/Search/History.t >@@ -368,7 +368,8 @@ my $schema = Koha::Database->schema; > my $builder = t::lib::TestBuilder->new; > > # Borrower Creation >-our $patron = $builder->build( { source => 'Borrower' } ); >+my $category = $builder->build( { source => 'Category', value => {min_password_length => undef, require_strong_password => undef} } ); >+our $patron = $builder->build( { source => 'Borrower', value => { categorycode => $category->{categorycode} } } ); > t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); > Koha::Patrons->find( $patron->{borrowernumber} )->set_password({ password => 'password' }); > >diff --git a/t/db_dependent/api/v1/auth_basic.t b/t/db_dependent/api/v1/auth_basic.t >index 49fdfe93d2..cd09f14da2 100644 >--- a/t/db_dependent/api/v1/auth_basic.t >+++ b/t/db_dependent/api/v1/auth_basic.t >@@ -38,8 +38,9 @@ subtest 'success tests' => sub { > > my $password = 'AbcdEFG123'; > >+ my $category = $builder->build_object({ class => 'Koha::Patron::Categories', value => { min_password_length => undef, require_strong_password => undef }}); > my $patron = $builder->build_object( >- { class => 'Koha::Patrons', value => { userid => 'tomasito', flags => 2**4 } } ); >+ { class => 'Koha::Patrons', value => { userid => 'tomasito', flags => 2**4, categorycode => $category->categorycode } } ); > $patron->set_password({ password => $password }); > my $userid = $patron->userid; > >@@ -86,8 +87,9 @@ subtest 'failure tests' => sub { > > t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); > >+ my $category = $builder->build_object({ class => 'Koha::Patron::Categories', value => { min_password_length => undef, require_strong_password => undef }}); > my $patron = $builder->build_object( >- { class => 'Koha::Patrons', value => { userid => 'tomasito', flags => 2**4 } } ); >+ { class => 'Koha::Patrons', value => { userid => 'tomasito', flags => 2**4, categorycode => $category->categorycode } } ); > $patron->set_password({ password => $password }); > my $userid = $patron->userid; > >diff --git a/t/db_dependent/api/v1/checkouts.t b/t/db_dependent/api/v1/checkouts.t >index 5f7f4ed2fe..a9df1152ae 100644 >--- a/t/db_dependent/api/v1/checkouts.t >+++ b/t/db_dependent/api/v1/checkouts.t >@@ -41,17 +41,19 @@ $schema->storage->txn_begin; > > my $dbh = C4::Context->dbh; > >+my $category = $builder->build_object({class => 'Koha::Patron::Categories', value => { min_password_length => undef, require_strong_password => undef } }); > my $librarian = $builder->build_object({ > class => 'Koha::Patrons', >- value => { flags => 2 } >+ value => { flags => 2, categorycode => $category->categorycode } > }); > my $password = 'thePassword123'; > $librarian->set_password({ password => $password, skip_validation => 1 }); > my $userid = $librarian->userid; > >+$category = $builder->build_object({class => 'Koha::Patron::Categories', value => { min_password_length => undef, require_strong_password => undef } }); > my $patron = $builder->build_object({ > class => 'Koha::Patrons', >- value => { flags => 0 } >+ value => { flags => 0, categorycode => $category->categorycode } > }); > my $unauth_password = 'thePassword000'; > $patron->set_password({ password => $unauth_password, skip_validattion => 1 }); >diff --git a/t/db_dependent/api/v1/patrons_password.t b/t/db_dependent/api/v1/patrons_password.t >index 2a57516319..9199ce4176 100644 >--- a/t/db_dependent/api/v1/patrons_password.t >+++ b/t/db_dependent/api/v1/patrons_password.t >@@ -237,10 +237,11 @@ sub create_user_and_session { > my ( $args ) = @_; > my $flags = ( $args->{authorized} ) ? 16 : 0; > >+ my $category = $builder->build_object({ class => 'Koha::Patron::Categories', value => { min_password_length => undef, require_strong_password => undef}}); > my $user = $builder->build_object( > { > class => 'Koha::Patrons', >- value => { flags => $flags } >+ value => { flags => $flags, categorycode => $category->categorycode } > } > ); > >diff --git a/t/db_dependent/selenium/authentication.t b/t/db_dependent/selenium/authentication.t >index 359cac1cef..fa719f39f7 100644 >--- a/t/db_dependent/selenium/authentication.t >+++ b/t/db_dependent/selenium/authentication.t >@@ -48,7 +48,8 @@ SKIP: { > like( $driver->get_title, qr(Log in to Koha), 'Hitting the main page should redirect to the login form'); > > my $password = Koha::AuthUtils::generate_password(); >- my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => 0 }}); >+ my $category = $builder->build_object({class => 'Koha::Patron::Categories', value => { min_password_length => undef, require_strong_password => undef } }); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => 0, categorycode => $category->categorycode }}); > t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); > $patron->set_password({ password => $password }); > >@@ -82,7 +83,8 @@ SKIP: { > like( $driver->get_title, qr(Koha online catalog), 'Hitting the main page should not redirect to the login form'); > > my $password = Koha::AuthUtils::generate_password(); >- my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => 0 }}); >+ my $category = $builder->build_object({class => 'Koha::Patron::Categories', value => { min_password_length => undef, require_strong_password => undef } }); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => 0, categorycode => $category->categorycode }}); > t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); > $patron->set_password({ password => $password }); > >diff --git a/t/db_dependent/selenium/regressions.t b/t/db_dependent/selenium/regressions.t >index ed2a68cdd4..37c73042c6 100644 >--- a/t/db_dependent/selenium/regressions.t >+++ b/t/db_dependent/selenium/regressions.t >@@ -52,8 +52,9 @@ our @cleanup; > subtest 'OPAC - borrowernumber and branchcode as html attributes' => sub { > plan tests => 2; > >+ my $category = $builder->build_object({class => 'Koha::Patron::Categories', value => { min_password_length => undef, require_strong_password => undef } }); > my $patron = $builder->build_object( >- { class => 'Koha::Patrons', value => { flags => 1 } } ); >+ { class => 'Koha::Patrons', value => { flags => 1, categorycode => $category->categorycode } } ); > my $password = Koha::AuthUtils::generate_password(); > t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); > $patron->set_password({ password => $password }); >@@ -197,7 +198,8 @@ subtest 'Display circulation table correctly' => sub { > subtest 'XSS vulnerabilities in pagination' => sub { > plan tests => 3; > >- my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $category = $builder->build_object({class => 'Koha::Patron::Categories', value => { min_password_length => undef, require_strong_password => undef } }); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $category->categorycode } }); > for ( 1 .. 30 ) { # We want the pagination to be displayed > push @cleanup, $builder->build_object( > { >-- >2.25.0
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 23816
:
103099
|
103100
|
103101
|
103102
|
103103
|
103104
|
103108
|
103109
|
103110
|
103111
|
103112
|
103113
|
103805
|
103806
|
103807
|
103808
|
103809
|
103810
|
107158
|
107159
|
107160
|
107161
|
107162
|
107163
|
108554
|
108555
|
108556
|
108557
|
108558
|
108559
|
108571
|
108572
|
109243
|
109244
|
109245
|
109249
|
109250
|
109251
|
109252
|
109253
|
109254
|
109255
|
109256
|
109257
|
109520
|
109521
|
109522
|
109523
|
109524
|
109525
|
109526
|
109527
|
109528
|
109833
|
109834