Bugzilla – Attachment 141120 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 test for Auth_with_shibboleth
Bug-30646-Unit-test-for-Authwithshibboleth.patch (text/plain), 5.26 KB, created by
Martin Renvoize (ashimema)
on 2022-09-30 10:46:56 UTC
(
hide
)
Description:
Bug 30646: Unit test for Auth_with_shibboleth
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-09-30 10:46:56 UTC
Size:
5.26 KB
patch
obsolete
>From 4e5ba92ed6017348b4c50e87322f78e5c5e734c8 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 30 Sep 2022 10:35:51 +0100 >Subject: [PATCH] Bug 30646: Unit test for Auth_with_shibboleth > >This patch adds a unit test for the Auth_with_shibboleth welcome notice >addition. >--- > t/Auth_with_shibboleth.t | 94 +++++++++++++++++++++++++++++----------- > 1 file changed, 68 insertions(+), 26 deletions(-) > >diff --git a/t/Auth_with_shibboleth.t b/t/Auth_with_shibboleth.t >index 5ea1f0d5d2..2d8958d3bf 100755 >--- a/t/Auth_with_shibboleth.t >+++ b/t/Auth_with_shibboleth.t >@@ -47,7 +47,8 @@ use Test::DBIx::Class { > # Mock Variables > my $matchpoint = 'userid'; > my $autocreate = 0; >-my $sync = 0; >+my $welcome = 0; >+my $sync = 0; > my %mapping = ( > 'userid' => { 'is' => 'uid' }, > 'surname' => { 'is' => 'sn' }, >@@ -55,13 +56,15 @@ my %mapping = ( > 'categorycode' => { 'is' => 'cat' }, > 'address' => { 'is' => 'add' }, > 'city' => { 'is' => 'city' }, >+ 'emailpro' => { 'is' => 'emailpro' }, > ); >-$ENV{'uid'} = "test1234"; >-$ENV{'sn'} = undef; >-$ENV{'exp'} = undef; >-$ENV{'cat'} = undef; >-$ENV{'add'} = undef; >-$ENV{'city'} = undef; >+$ENV{'uid'} = "test1234"; >+$ENV{'sn'} = undef; >+$ENV{'exp'} = undef; >+$ENV{'cat'} = undef; >+$ENV{'add'} = undef; >+$ENV{'city'} = undef; >+$ENV{'emailpro'} = undef; > > # Setup Mocks > ## Mock Context >@@ -88,6 +91,26 @@ my $database = Test::MockModule->new('Koha::Database'); > ### Mock ->schema > $database->mock( 'schema', \&mockedSchema ); > >+### Mock Letters >+my $mocked_letters = Test::MockModule->new('C4::Letters'); >+# we want to test the params >+$mocked_letters->mock( 'GetPreparedLetter', sub { >+ warn "GetPreparedLetter called"; >+ return 1; >+}); >+# we don't care about EnqueueLetter for now >+$mocked_letters->mock( 'EnqueueLetter', sub { >+ warn "EnqueueLetter called"; >+ # return a 'message_id' >+ return 42; >+}); >+# we don't care about EnqueueLetter for now >+$mocked_letters->mock( 'SendQueuedMessages', sub { >+ my $params = shift; >+ warn "SendQueuedMessages called with message_id: $params->{message_id}"; >+ return 1; >+}); >+ > # Tests > ############################################################## > >@@ -192,7 +215,7 @@ subtest "get_login_shib tests" => sub { > ## checkpw_shib > subtest "checkpw_shib tests" => sub { > >- plan tests => 33; >+ plan tests => 34; > > my $shib_login; > my ( $retval, $retcard, $retuserid ); >@@ -247,17 +270,27 @@ subtest "checkpw_shib tests" => sub { > > reset_config(); > >- # autocreate user >- $autocreate = 1; >- $shib_login = 'test4321'; >- $ENV{'uid'} = 'test4321'; >- $ENV{'sn'} = "pika"; >- $ENV{'exp'} = "2017"; >- $ENV{'cat'} = "S"; >- $ENV{'add'} = 'Address'; >- $ENV{'city'} = 'City'; >- >- ( $retval, $retcard, $retuserid ) = checkpw_shib($shib_login); >+ # autocreate user (welcome) >+ $autocreate = 1; >+ $welcome = 1; >+ $shib_login = 'test4321'; >+ $ENV{'uid'} = 'test4321'; >+ $ENV{'sn'} = "pika"; >+ $ENV{'exp'} = "2017"; >+ $ENV{'cat'} = "S"; >+ $ENV{'add'} = 'Address'; >+ $ENV{'city'} = 'City'; >+ $ENV{'emailpro'} = 'me@myemail.com'; >+ >+ warnings_are { >+ ( $retval, $retcard, $retuserid ) = checkpw_shib($shib_login); >+ } >+ [ >+ 'GetPreparedLetter called', >+ 'EnqueueLetter called', >+ 'SendQueuedMessages called with message_id: 42' >+ ], >+ "WELCOME notice Prepared, Enqueued and Send"; > is( $retval, "1", "user authenticated" ); > is( $retuserid, "test4321", "expected userid returned" ); > $logger->debug_is("koha borrower field to match: userid", "borrower match field debug info") >@@ -270,6 +303,7 @@ subtest "checkpw_shib tests" => sub { > [qw/pika 2017 Address City/], > 'Found $new_users surname'; > $autocreate = 0; >+ $welcome = 0; > > # sync user > $sync = 1; >@@ -364,6 +398,7 @@ sub mockedConfig { > > my %shibboleth = ( > 'autocreate' => $autocreate, >+ 'welcome' => $welcome, > 'sync' => $sync, > 'matchpoint' => $matchpoint, > 'mapping' => \%mapping >@@ -384,6 +419,10 @@ sub mockedPref { > $return = $staffClientBaseURL; > } > >+ if ( $param eq 'AutoEmailPrimaryAddress' ) { >+ $return = 'OFF'; >+ } >+ > return $return; > } > >@@ -399,21 +438,24 @@ sub mockedSchema { > sub reset_config { > $matchpoint = 'userid'; > $autocreate = 0; >+ $welcome = 0; > $sync = 0; >- %mapping = ( >+ %mapping = ( > 'userid' => { 'is' => 'uid' }, > 'surname' => { 'is' => 'sn' }, > 'dateexpiry' => { 'is' => 'exp' }, > 'categorycode' => { 'is' => 'cat' }, > 'address' => { 'is' => 'add' }, > 'city' => { 'is' => 'city' }, >+ 'emailpro' => { 'is' => 'emailpro' }, > ); >- $ENV{'uid'} = "test1234"; >- $ENV{'sn'} = undef; >- $ENV{'exp'} = undef; >- $ENV{'cat'} = undef; >- $ENV{'add'} = undef; >- $ENV{'city'} = undef; >+ $ENV{'uid'} = "test1234"; >+ $ENV{'sn'} = undef; >+ $ENV{'exp'} = undef; >+ $ENV{'cat'} = undef; >+ $ENV{'add'} = undef; >+ $ENV{'city'} = undef; >+ $ENV{'emailpro'} = undef; > > return 1; > } >-- >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