Bugzilla – Attachment 141121 Details for
Bug 30646
Add option to send WELCOME notice for new patrons added at first login via LDAP/SAML
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30646: Unit tests for Auth_with_ldap
Bug-30646-Unit-tests-for-Authwithldap.patch (text/plain), 4.03 KB, created by
Martin Renvoize (ashimema)
on 2022-09-30 10:47:00 UTC
(
hide
)
Description:
Bug 30646: Unit tests for Auth_with_ldap
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-09-30 10:47:00 UTC
Size:
4.03 KB
patch
obsolete
>From 37e9eda51a783412da82ee3ab592d1c7158ef77c Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 30 Sep 2022 11:44:39 +0100 >Subject: [PATCH] Bug 30646: Unit tests for Auth_with_ldap > >This patch adds a unit test to the Auth_with_ldap.t to confirm welcome >notices are send when replace + welcome are enabled in the >configuration. > >We also add a snippet to hide 'Subroutine redefined' warnings in this >test as it makes the test output rather challenging to read and the way >the test is written these warning are expected. >--- > t/db_dependent/Auth_with_ldap.t | 59 +++++++++++++++++++++++++++++++-- > 1 file changed, 57 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Auth_with_ldap.t b/t/db_dependent/Auth_with_ldap.t >index df385e1569..7c1a514cdc 100755 >--- a/t/db_dependent/Auth_with_ldap.t >+++ b/t/db_dependent/Auth_with_ldap.t >@@ -28,6 +28,15 @@ use C4::Context; > > use Koha::Patrons; > >+# Hide all the subrouteine redefined warnings when running this test.. >+# We reload the ldap module lots in the test and each reload triggers the >+# 'Subroutine X redefined at' warning.. disable that to make the test output >+# readable. >+$SIG{__WARN__} = sub { >+ my $warning = shift; >+ warn $warning unless $warning =~ /Subroutine .* redefined at/; >+}; >+ > # Start transaction > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin(); >@@ -37,6 +46,7 @@ my $builder = t::lib::TestBuilder->new(); > # Variables controlling LDAP server config > my $update = 0; > my $replicate = 0; >+my $welcome = 0; > my $auth_by_bind = 1; > my $anonymous_bind = 1; > my $user = 'cn=Manager,dc=metavore,dc=com'; >@@ -144,7 +154,7 @@ subtest 'checkpw_ldap tests' => sub { > > subtest 'auth_by_bind = 1 tests' => sub { > >- plan tests => 11; >+ plan tests => 14; > > $auth_by_bind = 1; > >@@ -221,7 +231,51 @@ subtest 'checkpw_ldap tests' => sub { > 'checkpw_ldap returns 0 if user lookup returns 0' > ); > >- $desired_bind_result = 'error'; >+ # test replicate functionality and welcome notice >+ $desired_authentication_result = 'success'; >+ $anonymous_bind = 1; >+ $desired_admin_bind_result = 'success'; >+ $desired_search_result = 'success'; >+ $desired_count_result = 1; >+ $desired_bind_result = 'success'; >+ $replicate = 1; >+ $welcome = 1; >+ reload_ldap_module(); >+ >+ $auth->mock( >+ 'ldap_entry_2_hash', >+ sub { >+ return ( >+ userid => 'hola', >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ email => 'me@myemail.com', >+ ); >+ } >+ ); >+ >+ C4::Auth_with_ldap::checkpw_ldap( 'hola', password => 'hey' ); >+ my $patrons = Koha::Patrons->search( { userid => 'hola' } ); >+ is( $patrons->count, 1, 'New patron added with "replicate"' ); >+ >+ $patron = $patrons->next; >+ my $queued_notices = Koha::Notice::Messages->search( >+ { borrowernumber => $patron->borrowernumber } ); >+ is( $queued_notices->count, 1, >+ "One notice queued when `welcome` is set" ); >+ >+ my $THE_notice = $queued_notices->next; >+ is( $THE_notice->status, 'failed', "The notice was sent immediately" ); >+ >+ # clean up >+ $patron->delete; >+ $replicate = 0; >+ $welcome = 0; >+ $auth->unmock('ldap_entry_2_hash'); >+ # end replicate testing >+ >+ $desired_count_result = 0; >+ $desired_bind_result = 'error'; > reload_ldap_module(); > > warning_like { >@@ -376,6 +430,7 @@ sub mockedC4Config { > pass => $pass, > principal_name => '%s@my_domain.com', > replicate => $replicate, >+ welcome => $welcome, > update => $update, > user => $user, > ); >-- >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 30646
:
134272
|
134279
|
136171
|
136172
|
136173
|
138708
|
138709
|
138710
|
141117
|
141118
|
141119
|
141120
| 141121