Bug 30646

Summary: Add option to send WELCOME notice for new patrons added at first login via LDAP/SAML
Product: Koha Reporter: Martin Renvoize <martin.renvoize>
Component: PatronsAssignee: Martin Renvoize <martin.renvoize>
Status: Passed QA --- QA Contact: Tomás Cohen Arazi <tomascohen>
Severity: enhancement    
Priority: P5 - low CC: alexbuckley, gmcharlt, jonathan.field, kyle.m.hall, matthias.meusburger, nick, tomascohen
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 30237    
Bug Blocks:    
Attachments: Bug 30646: Add welcome email support to LDAP
Bug 30646: Add welcome email support to SAML2
Bug 30646: Add welcome email support to LDAP
Bug 30646: Add welcome email support to SAML2
Bug 30646: (follow-up) Set to send immediately
Bug 30646: Add welcome email support to LDAP
Bug 30646: Add welcome email support to SAML2
Bug 30646: (follow-up) Set to send immediately
Bug 30646: Add welcome email support to LDAP
Bug 30646: Add welcome email support to SAML2
Bug 30646: (follow-up) Set to send immediately
Bug 30646: Unit test for Auth_with_shibboleth
Bug 30646: Unit tests for Auth_with_ldap

Description Martin Renvoize 2022-04-28 14:19:46 UTC
It would be helpful to add automatic email to users on patron creation when that creation has been triggered by LDAP or Shibboleth creations.
Comment 1 Martin Renvoize 2022-04-28 15:02:28 UTC
Created attachment 134272 [details] [review]
Bug 30646: Add welcome email support to LDAP

This patch adds the ability to enable the welcome email notice for new
users added via the LDAP replicate option.

Test plan
1) Configure LDAP for authentication
2) Enable the welcome email by adding '<welcome>1</welcome>' to your
   ldap config block
3) Confirm you have replicate enabled for your LDAP config
4) Attempt to login with an entirely new user to Koha using the LDAP
   connection (with a user who has a valid email address mapped to Koha
   borrower fields)
5) Confirm the email is sent by looking at the notices for the new user.
Comment 2 Martin Renvoize 2022-04-28 15:14:50 UTC
Created attachment 134279 [details] [review]
Bug 30646: Add welcome email support to SAML2

This patch adds the ability to enable the welcome email notice for new
users added via the Shibboleth autocreate option.

Test plan
1) Configure Shibboleth for authentication
2) Enable the welcome email by adding '<welcome>1</welcome>' to your
   shibboleth config block
3) Confirm you have autocreate enabled for your Shibboleth config
4) Attempt to login with an entirely new user to Koha using the shibboleth
   connection (with a user who has a valid email address mapped to Koha
   borrower fields)
5) Confirm the email is sent by looking at the notices for the new user.
Comment 3 Martin Renvoize 2022-06-16 14:24:26 UTC
Created attachment 136171 [details] [review]
Bug 30646: Add welcome email support to LDAP

This patch adds the ability to enable the welcome email notice for new
users added via the LDAP replicate option.

Test plan
1) Configure LDAP for authentication
2) Enable the welcome email by adding '<welcome>1</welcome>' to your
   ldap config block
3) Confirm you have replicate enabled for your LDAP config
4) Attempt to login with an entirely new user to Koha using the LDAP
   connection (with a user who has a valid email address mapped to Koha
   borrower fields)
5) Confirm the email is sent by looking at the notices for the new user.
Comment 4 Martin Renvoize 2022-06-16 14:24:30 UTC
Created attachment 136172 [details] [review]
Bug 30646: Add welcome email support to SAML2

This patch adds the ability to enable the welcome email notice for new
users added via the Shibboleth autocreate option.

Test plan
1) Configure Shibboleth for authentication
2) Enable the welcome email by adding '<welcome>1</welcome>' to your
   shibboleth config block
3) Confirm you have autocreate enabled for your Shibboleth config
4) Attempt to login with an entirely new user to Koha using the shibboleth
   connection (with a user who has a valid email address mapped to Koha
   borrower fields)
5) Confirm the email is sent by looking at the notices for the new user.
Comment 5 Martin Renvoize 2022-06-16 14:24:34 UTC
Created attachment 136173 [details] [review]
Bug 30646: (follow-up) Set to send immediately

Other welcome notices send immediately rather than waiting on the queue
to be processed.. these one's should too.
Comment 6 Kyle M Hall 2022-08-05 14:49:40 UTC
Created attachment 138708 [details] [review]
Bug 30646: Add welcome email support to LDAP

This patch adds the ability to enable the welcome email notice for new
users added via the LDAP replicate option.

Test plan
1) Configure LDAP for authentication
2) Enable the welcome email by adding '<welcome>1</welcome>' to your
   ldap config block
3) Confirm you have replicate enabled for your LDAP config
4) Attempt to login with an entirely new user to Koha using the LDAP
   connection (with a user who has a valid email address mapped to Koha
   borrower fields)
5) Confirm the email is sent by looking at the notices for the new user.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 7 Kyle M Hall 2022-08-05 14:50:17 UTC
Created attachment 138709 [details] [review]
Bug 30646: Add welcome email support to SAML2

This patch adds the ability to enable the welcome email notice for new
users added via the Shibboleth autocreate option.

Test plan
1) Configure Shibboleth for authentication
2) Enable the welcome email by adding '<welcome>1</welcome>' to your
   shibboleth config block
3) Confirm you have autocreate enabled for your Shibboleth config
4) Attempt to login with an entirely new user to Koha using the shibboleth
   connection (with a user who has a valid email address mapped to Koha
   borrower fields)
5) Confirm the email is sent by looking at the notices for the new user.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 8 Kyle M Hall 2022-08-05 14:50:21 UTC
Created attachment 138710 [details] [review]
Bug 30646: (follow-up) Set to send immediately

Other welcome notices send immediately rather than waiting on the queue
to be processed.. these one's should too.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 9 Martin Renvoize 2022-09-23 13:54:27 UTC
Hmm.. we now have this running in production.. May I convert your SO to a QA and add our customers name as an SO Kyle?
Comment 10 Tomás Cohen Arazi 2022-09-23 14:16:24 UTC
This all looks good, but we need tests:

- Mocked test on GetPreparedLetter being called and then EnqueueLetter as well
- Mocked test on SendQueuedMessages being called with the right parameter
- Not super picky about it, but $patron->notice_email_address should also be tested.

Can try helping, but not today.
Comment 11 Martin Renvoize 2022-09-30 10:46:43 UTC
Created attachment 141117 [details] [review]
Bug 30646: Add welcome email support to LDAP

This patch adds the ability to enable the welcome email notice for new
users added via the LDAP replicate option.

Test plan
1) Configure LDAP for authentication
2) Enable the welcome email by adding '<welcome>1</welcome>' to your
   ldap config block
3) Confirm you have replicate enabled for your LDAP config
4) Attempt to login with an entirely new user to Koha using the LDAP
   connection (with a user who has a valid email address mapped to Koha
   borrower fields)
5) Confirm the email is sent by looking at the notices for the new user.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 12 Martin Renvoize 2022-09-30 10:46:48 UTC
Created attachment 141118 [details] [review]
Bug 30646: Add welcome email support to SAML2

This patch adds the ability to enable the welcome email notice for new
users added via the Shibboleth autocreate option.

Test plan
1) Configure Shibboleth for authentication
2) Enable the welcome email by adding '<welcome>1</welcome>' to your
   shibboleth config block
3) Confirm you have autocreate enabled for your Shibboleth config
4) Attempt to login with an entirely new user to Koha using the shibboleth
   connection (with a user who has a valid email address mapped to Koha
   borrower fields)
5) Confirm the email is sent by looking at the notices for the new user.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 13 Martin Renvoize 2022-09-30 10:46:52 UTC
Created attachment 141119 [details] [review]
Bug 30646: (follow-up) Set to send immediately

Other welcome notices send immediately rather than waiting on the queue
to be processed.. these one's should too.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 14 Martin Renvoize 2022-09-30 10:46:56 UTC
Created attachment 141120 [details] [review]
Bug 30646: Unit test for Auth_with_shibboleth

This patch adds a unit test for the Auth_with_shibboleth welcome notice
addition.
Comment 15 Martin Renvoize 2022-09-30 10:47:00 UTC
Created attachment 141121 [details] [review]
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.
Comment 16 Martin Renvoize 2022-09-30 10:48:51 UTC
One day I'll get around to re-writing/re-factoring those tests.. they're a nightmare to work on.

Anywho, tests now submitted, apologies for being bad and not submitting earlier :(.

Note.. I snuck in a snippet to quiten the plethora of warning that the Auth_with_ldap.t test was throwing.. it's well documented in the top of the test now and makes the test output sooooo much more readable.