Bugzilla – Attachment 96561 Details for
Bug 23011
AuthenticatePatron could alert if password is not safe
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23011: Add new tests (AuthenticatePatron error codes)
Bug-23011-Add-new-tests-AuthenticatePatron-error-c.patch (text/plain), 2.96 KB, created by
Arthur Suzuki
on 2019-12-22 05:21:32 UTC
(
hide
)
Description:
Bug 23011: Add new tests (AuthenticatePatron error codes)
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2019-12-22 05:21:32 UTC
Size:
2.96 KB
patch
obsolete
>From de72db2b594d60e45796aab1090e6b239685a607 Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Fri, 20 Dec 2019 18:01:42 +0100 >Subject: [PATCH] Bug 23011: Add new tests (AuthenticatePatron error codes) > >This bug add new tests to the AuthenticatePatron ILS-DI service. >It tests new error codes patron might get when successfully connecting >but with a password which doesn't match Koha security rules. >--- > t/db_dependent/ILSDI_Services.t | 52 ++++++++++++++++++++++++++++++++- > 1 file changed, 51 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t >index 430d900c77..865cd5f402 100644 >--- a/t/db_dependent/ILSDI_Services.t >+++ b/t/db_dependent/ILSDI_Services.t >@@ -19,7 +19,7 @@ use Modern::Perl; > > use CGI qw ( -utf8 ); > >-use Test::More tests => 9; >+use Test::More tests => 10; > use Test::MockModule; > use t::lib::Mocks; > use t::lib::TestBuilder; >@@ -104,6 +104,56 @@ subtest 'AuthenticatePatron test' => sub { > }; > > >+subtest 'AuthenticatePatron Secure Password test' => sub { >+ >+ plan tests => 10; >+ >+ $schema->storage->txn_begin; >+ >+ my $plain_password = 'tomasito'; >+ >+ $builder->build({ >+ source => 'Borrower', >+ value => { >+ cardnumber => undef, >+ } >+ }); >+ >+ my $borrower = $builder->build({ >+ source => 'Borrower', >+ value => { >+ cardnumber => undef, >+ password => Koha::AuthUtils::hash_password( $plain_password ) >+ } >+ }); >+ >+ my $query = new CGI; >+ $query->param( 'username', $borrower->{userid}); >+ $query->param( 'password', $plain_password); >+ >+ my $reply = C4::ILSDI::Services::AuthenticatePatron( $query ); >+ is( $reply->{id}, $borrower->{borrowernumber}, "userid and password - Patron authenticated" ); >+ is( $reply->{code}, undef, "Error code undef"); >+ >+ t::lib::Mocks::mock_preference( 'minPasswordLength', 10 ); >+ $reply = C4::ILSDI::Services::AuthenticatePatron( $query ); >+ is( $reply->{id}, $borrower->{borrowernumber}, "existing user"); >+ is( $reply->{code}, 'PatronPasswordNotSecure', "PasswordNotSecure" ); >+ is( $reply->{securePasswordLabel}, 'too_short', "PasswordTooShort" ); >+ is( $reply->{securePasswordPattern}, '.{10}', "Password must be at least 10 char" ); >+ >+ t::lib::Mocks::mock_preference( 'RequireStrongPassword', 1 ); >+ t::lib::Mocks::mock_preference( 'minPasswordLength', 5 ); >+ $reply = C4::ILSDI::Services::AuthenticatePatron( $query ); >+ is( $reply->{id}, $borrower->{borrowernumber}, "existing user"); >+ is( $reply->{code}, 'PatronPasswordNotSecure', "PasswordNotSecure" ); >+ is( $reply->{securePasswordLabel}, 'too_weak', "PasswordTooWeak" ); >+ is( $reply->{securePasswordPattern}, '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{5}', "Password must be strong (pattern match)" ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+ > subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes' => sub { > > plan tests => 5; >-- >2.20.1
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 23011
:
93512
|
93517
|
96560
|
96561
|
96562
|
100423
|
100424
|
100425
|
100426
|
106565
|
106566
|
106567