From 8990bc682019b6dd8718c1dd7669df00e6a6ac87 Mon Sep 17 00:00:00 2001 From: Guillaume Alviset <44084050+galviset@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:03:05 +0000 Subject: [PATCH 1/2] added mail options test to catch auth type case --- test/util/test_notifications.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/util/test_notifications.rb b/test/util/test_notifications.rb index 8508dc1e..7d3ad5db 100644 --- a/test/util/test_notifications.rb +++ b/test/util/test_notifications.rb @@ -129,4 +129,30 @@ def test_remote_ontology_pull_notification end end end + + def test_mail_options + options = LinkedData::Utils::Notifier.mail_options + expected_options = { + address: LinkedData.settings.smtp_host, + port: LinkedData.settings.smtp_port, + domain: LinkedData.settings.smtp_domain + } + assert_equal options, expected_options + + # testing SMTP authentification-based login + current_auth_type = LinkedData.settings.smtp_auth_type + LinkedData.settings.smtp_auth_type = :plain + options = LinkedData::Utils::Notifier.mail_options + expected_options = { + address: LinkedData.settings.smtp_host, + port: LinkedData.settings.smtp_port, + domain: LinkedData.settings.smtp_domain, + user_name: LinkedData.settings.smtp_user, + password: LinkedData.settings.smtp_password, + authentication: LinkedData.settings.smtp_auth_type + } + assert_equal options, expected_options + + LinkedData.settings.smtp_auth_type = current_auth_type + end end From d024917aedde0026b9708e943d8ee64233d549b0 Mon Sep 17 00:00:00 2001 From: Guillaume Alviset <44084050+galviset@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:03:48 +0000 Subject: [PATCH 2/2] fixed auth type mail options not being saved --- lib/ontologies_linked_data/utils/notifications.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ontologies_linked_data/utils/notifications.rb b/lib/ontologies_linked_data/utils/notifications.rb index 340c0d5d..61f8d756 100644 --- a/lib/ontologies_linked_data/utils/notifications.rb +++ b/lib/ontologies_linked_data/utils/notifications.rb @@ -190,7 +190,7 @@ def self.mail_options } if LinkedData.settings.smtp_auth_type && LinkedData.settings.smtp_auth_type != :none - options.merge({ + options.merge!({ user_name: LinkedData.settings.smtp_user, password: LinkedData.settings.smtp_password, authentication: LinkedData.settings.smtp_auth_type