From 0ecf0349967121b3e711067ebf8d03d8e2ec90bb Mon Sep 17 00:00:00 2001
From: amontenegro
Date: Wed, 1 Nov 2023 15:57:59 -0600
Subject: [PATCH] Coding done, start testing
---
.../orcid/core/utils/VerifyEmailUtils.java | 2 +-
.../how_do_i_verify_my_email_address.ftl | 5 +
.../template/verification_email_html_v2.ftl | 20 +---
.../core/template/verification_email_v2.ftl | 33 ++----
.../core/template/welcome_email_html_v2.ftl | 3 +
.../orcid/core/template/welcome_email_v2.ftl | 10 +-
.../core/manager/TemplateManagerTest.java | 34 ++++--
.../example_verification_email_body.html | 110 ++++++++----------
.../example_verification_email_body.txt | 12 +-
9 files changed, 103 insertions(+), 126 deletions(-)
create mode 100644 orcid-core/src/main/resources/org/orcid/core/template/how_do_i_verify_my_email_address.ftl
diff --git a/orcid-core/src/main/java/org/orcid/core/utils/VerifyEmailUtils.java b/orcid-core/src/main/java/org/orcid/core/utils/VerifyEmailUtils.java
index fa7572d75db..0131c314c97 100644
--- a/orcid-core/src/main/java/org/orcid/core/utils/VerifyEmailUtils.java
+++ b/orcid-core/src/main/java/org/orcid/core/utils/VerifyEmailUtils.java
@@ -34,7 +34,7 @@ public Map createParamsForVerificationEmail(String emailFriendly
templateParams.put("isPrimary", isPrimary);
templateParams.put("userName", emailFriendlyName);
templateParams.put("verificationUrl", createVerificationUrl(email, orcidUrlManager.getBaseUrl()));
- templateParams.put("orcid", orcid);
+ templateParams.put("orcidId", orcid);
templateParams.put("subject", getSubject((isPrimary ? "email.subject.verify_reminder_primary" : "email.subject.verify_reminder"), locale));
templateParams.put("baseUri", orcidUrlManager.getBaseUrl());
addMessageParams(templateParams, locale);
diff --git a/orcid-core/src/main/resources/org/orcid/core/template/how_do_i_verify_my_email_address.ftl b/orcid-core/src/main/resources/org/orcid/core/template/how_do_i_verify_my_email_address.ftl
new file mode 100644
index 00000000000..bc40b7d7a40
--- /dev/null
+++ b/orcid-core/src/main/resources/org/orcid/core/template/how_do_i_verify_my_email_address.ftl
@@ -0,0 +1,5 @@
+<@emailMacros.msg "email.welcome.verify.2" />
+
+<@emailMacros.msg "email.welcome.verify.4" />
+
+${verificationUrl}?lang=${locale}
\ No newline at end of file
diff --git a/orcid-core/src/main/resources/org/orcid/core/template/verification_email_html_v2.ftl b/orcid-core/src/main/resources/org/orcid/core/template/verification_email_html_v2.ftl
index 5bf21902452..b8150dca9b6 100644
--- a/orcid-core/src/main/resources/org/orcid/core/template/verification_email_html_v2.ftl
+++ b/orcid-core/src/main/resources/org/orcid/core/template/verification_email_html_v2.ftl
@@ -1,21 +1,3 @@
-<#--
-
- =============================================================================
-
- ORCID (R) Open Source
- http://orcid.org
-
- Copyright (c) 2012-2014 ORCID, Inc.
- Licensed under an MIT-Style License (MIT)
- http://orcid.org/open-source-license
-
- This copyright and license information (including a link to the full license)
- shall be included in its entirety in all copies or substantial portion of
- the software.
-
- =============================================================================
-
--->
<#import "email_macros.ftl" as emailMacros />
<#escape x as x?html>
@@ -34,7 +16,7 @@
<@emailMacros.msg "email.verify.hi" /><@emailMacros.space />${userName},
- <#if isPrimary?? && isPrimary><@emailMacros.msg "email.verify.primary.reminder" /><#elseif><@emailMacros.msg "email.verify.alternate.reminder" />#if>
+ <#if isPrimary?? && isPrimary><@emailMacros.msg "email.verify.primary.reminder" /><#else><@emailMacros.msg "email.verify.alternate.reminder" />#if>
<#include "how_do_i_verify_my_email_address_html.ftl"/>
diff --git a/orcid-core/src/main/resources/org/orcid/core/template/verification_email_v2.ftl b/orcid-core/src/main/resources/org/orcid/core/template/verification_email_v2.ftl
index 1ef6330fd54..c578d75c1b9 100644
--- a/orcid-core/src/main/resources/org/orcid/core/template/verification_email_v2.ftl
+++ b/orcid-core/src/main/resources/org/orcid/core/template/verification_email_v2.ftl
@@ -1,29 +1,14 @@
-<#--
-
- =============================================================================
-
- ORCID (R) Open Source
- http://orcid.org
+<#import "email_macros.ftl" as emailMacros />
+<@emailMacros.msg "email.welcome.your_id.id" /><@emailMacros.space />${orcidId}
+<@emailMacros.msg "email.welcome.your_id.link" /><@emailMacros.space />${baseUri}/${orcidId}
- Copyright (c) 2012-2014 ORCID, Inc.
- Licensed under an MIT-Style License (MIT)
- http://orcid.org/open-source-license
+<@emailMacros.msg "email.verify.hi" /><@emailMacros.space />${userName},
+ <#if isPrimary?? && isPrimary><@emailMacros.msg "email.verify.primary.reminder" /><#else><@emailMacros.msg "email.verify.alternate.reminder" />#if>
- This copyright and license information (including a link to the full license)
- shall be included in its entirety in all copies or substantial portion of
- the software.
- =============================================================================
+<#include "how_do_i_verify_my_email_address.ftl"/>
--->
-<#import "email_macros.ftl" as emailMacros />
<#if isPrimary?? && isPrimary>
- <@emailMacros.msg "email.verify.primary_reminder_v2" /><@emailMacros.space />
-#if>
-<@emailMacros.msg "email.verify.thank_you" />
-
-${verificationUrl}?lang=${locale}
-
-<@emailMacros.msg "email.verify.1" /><@emailMacros.space />${orcid}<@emailMacros.msg "email.verify.2" /><@emailMacros.space />${baseUri}/${orcid}?lang=${locale}<@emailMacros.space /><@emailMacros.msg "email.verify.primary_email_1" /><@emailMacros.space />${primaryEmail}<@emailMacros.msg "email.verify.primary_email_2" />.
-
-<#include "email_footer.ftl"/>
+<@emailMacros.msg "email.welcome.please_visit_our" /><@emailMacros.space /><@emailMacros.msg "email.welcome.researcher_homepage" /><@emailMacros.space /><@emailMacros.msg "email.welcome.for_more_information" />
+#if>
+<#include "email_footer.ftl"/>
\ No newline at end of file
diff --git a/orcid-core/src/main/resources/org/orcid/core/template/welcome_email_html_v2.ftl b/orcid-core/src/main/resources/org/orcid/core/template/welcome_email_html_v2.ftl
index e3ba3ed8192..8269cf7f204 100644
--- a/orcid-core/src/main/resources/org/orcid/core/template/welcome_email_html_v2.ftl
+++ b/orcid-core/src/main/resources/org/orcid/core/template/welcome_email_html_v2.ftl
@@ -36,6 +36,9 @@
<@emailMacros.msg "email.welcome" /><@emailMacros.space />${userName},
<@emailMacros.msg "email.welcome.congrats" />
+
+ <@emailMacros.msg "email.welcome.verify.1" />
+
<#include "how_do_i_verify_my_email_address_html.ftl"/>
diff --git a/orcid-core/src/main/resources/org/orcid/core/template/welcome_email_v2.ftl b/orcid-core/src/main/resources/org/orcid/core/template/welcome_email_v2.ftl
index 8ee76ac1a85..57deb640511 100644
--- a/orcid-core/src/main/resources/org/orcid/core/template/welcome_email_v2.ftl
+++ b/orcid-core/src/main/resources/org/orcid/core/template/welcome_email_v2.ftl
@@ -26,15 +26,7 @@
<@emailMacros.msg "email.welcome.verify.1" />
-<@emailMacros.msg "email.welcome.verify.2" />
-
-<@emailMacros.msg "email.welcome.verify.3" />
-
-<@emailMacros.msg "email.button" />
-
-<@emailMacros.msg "email.welcome.verify.4" />
-
-${verificationUrl}?lang=${locale}
+<#include "how_do_i_verify_my_email_address.ftl"/>
<@emailMacros.msg "email.welcome.please_visit_our" /><@emailMacros.space /><@emailMacros.msg "email.welcome.researcher_homepage" /><@emailMacros.space /><@emailMacros.msg "email.welcome.for_more_information" />
diff --git a/orcid-core/src/test/java/org/orcid/core/manager/TemplateManagerTest.java b/orcid-core/src/test/java/org/orcid/core/manager/TemplateManagerTest.java
index fbcdba1cbcc..c36cc84473d 100644
--- a/orcid-core/src/test/java/org/orcid/core/manager/TemplateManagerTest.java
+++ b/orcid-core/src/test/java/org/orcid/core/manager/TemplateManagerTest.java
@@ -4,6 +4,7 @@
import static org.junit.Assert.assertNotNull;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
@@ -45,25 +46,40 @@ public void testProcessTemplate() {
}
@Test
- public void testGenerateVerifyEmailBody() throws IOException {
- String expectedText = IOUtils.toString(getClass().getResourceAsStream("example_verification_email_body.txt"));
- String expectedHtml = IOUtils.toString(getClass().getResourceAsStream("example_verification_email_body.html"));
-
+ public void testGenerateVerifyEmailPlainText() throws IOException {
+ String expectedText = IOUtils.toString(getClass().getResourceAsStream("example_verification_email_body.txt"), StandardCharsets.UTF_8);
+
Map templateParams = new HashMap();
templateParams.put("primaryEmail", "josiah_carberry@brown.edu");
- templateParams.put("emailName", "Josiah Carberry");
+ templateParams.put("userName", "Josiah Carberry");
templateParams.put("subject", "[ORCID] Reminder to verify your email address");
templateParams.put("verificationUrl", "http://testserver.orcid.org/verify-email/WnhVWGhYVk9lTng4bWdqaDl0azBXY3BmN1F4dHExOW95SnNxeVJSMy9Scz0");
- templateParams.put("orcid", "4444-4444-4444-4446");
- templateParams.put("baseUri", orcidUrlManager.getBaseUrl());
- templateParams.put("baseUriHttp", orcidUrlManager.getBaseUriHttp());
+ templateParams.put("orcidId", "4444-4444-4444-4446");
+ templateParams.put("baseUri", orcidUrlManager.getBaseUrl());
addStandardParams(templateParams);
// Generate body from template
String body = templateManager.processTemplate("verification_email_v2.ftl", templateParams);
+
+ assertEquals(expectedText, body);
+ }
+
+ @Test
+ public void testGenerateVerifyEmailHtml() throws IOException {
+ String expectedHtml = IOUtils.toString(getClass().getResourceAsStream("example_verification_email_body.html"), StandardCharsets.UTF_8);
+
+ Map templateParams = new HashMap();
+ templateParams.put("primaryEmail", "josiah_carberry@brown.edu");
+ templateParams.put("userName", "Josiah Carberry");
+ templateParams.put("subject", "[ORCID] Reminder to verify your email address");
+ templateParams.put("verificationUrl", "http://testserver.orcid.org/verify-email/WnhVWGhYVk9lTng4bWdqaDl0azBXY3BmN1F4dHExOW95SnNxeVJSMy9Scz0");
+ templateParams.put("orcidId", "4444-4444-4444-4446");
+ templateParams.put("baseUri", orcidUrlManager.getBaseUrl());
+ addStandardParams(templateParams);
+
+ // Generate body from template
String htmlBody = templateManager.processTemplate("verification_email_html_v2.ftl", templateParams);
- assertEquals(expectedText, body);
assertEquals(expectedHtml, htmlBody);
}
diff --git a/orcid-core/src/test/resources/org/orcid/core/manager/example_verification_email_body.html b/orcid-core/src/test/resources/org/orcid/core/manager/example_verification_email_body.html
index c039b148b10..4afe421856c 100644
--- a/orcid-core/src/test/resources/org/orcid/core/manager/example_verification_email_body.html
+++ b/orcid-core/src/test/resources/org/orcid/core/manager/example_verification_email_body.html
@@ -1,63 +1,53 @@
-
- [ORCID] Reminder to verify your email address
-
-
-
-
-
-
-To verify your email address, click the following button and sign into your ORCID record. If you can't click the button, copy and paste the link below into your browser's address bar:
-
-
-
-
-
- Your 16-digit ORCID identifier is 4444-4444-4444-4446, and your full ORCID iD and the link to your public record is https://testserver.orcid.org/4444-4444-4444-4446 (primary email address: josiah_carberry@brown.edu).
-
+
+
[ORCID] Reminder to verify your email address
+
+
+
+
+
+
+ Your ORCID iD: 4444-4444-4444-4446
+ Your ORCID record is https://testserver.orcid.org/4444-4444-4444-4446
+
+
+
+ Hi Josiah Carberry,
+You need to verify your email address.
+
+ Verifying your email address unlocks advanced editing features in your ORCID record. Until then you will only be able to manage your names and email addresses in your ORCID record.
+
+ How do I verify my email address?
+Simply click the button below to sign into your ORCID record and complete verification.
+
+
+Or, copy and paste the link below into your browser's address bar:
+
Warm Regards,
@@ -75,6 +65,6 @@
| ORCID.org
-
-
+
+
diff --git a/orcid-core/src/test/resources/org/orcid/core/manager/example_verification_email_body.txt b/orcid-core/src/test/resources/org/orcid/core/manager/example_verification_email_body.txt
index 8b513334045..c9814c6e584 100644
--- a/orcid-core/src/test/resources/org/orcid/core/manager/example_verification_email_body.txt
+++ b/orcid-core/src/test/resources/org/orcid/core/manager/example_verification_email_body.txt
@@ -1,8 +1,12 @@
-To verify your email address, click the following link and sign into your ORCID record. If you can't click the link, copy and paste it into your browser's address bar:
-http://testserver.orcid.org/verify-email/WnhVWGhYVk9lTng4bWdqaDl0azBXY3BmN1F4dHExOW95SnNxeVJSMy9Scz0?lang=en
+Your ORCID iD: 4444-4444-4444-4446
+Your ORCID record is https://testserver.orcid.org/4444-4444-4444-4446
-Your 16-digit ORCID identifier is 4444-4444-4444-4446, and your full ORCID iD and the link to your public record is https://testserver.orcid.org/4444-4444-4444-4446?lang=en (primary email address: josiah_carberry@brown.edu).
+Hi Josiah Carberry,
+You need to verify your email address.
+How do I verify my email address?
+Or, copy and paste the link below into your browser's address bar:
+http://testserver.orcid.org/verify-email/WnhVWGhYVk9lTng4bWdqaDl0azBXY3BmN1F4dHExOW95SnNxeVJSMy9Scz0?lang=en
Warm Regards,
ORCID Support Team
https://support.orcid.org
@@ -12,4 +16,4 @@ email preferences (https://testserver.orcid.org/account)
privacy policy (https://testserver.orcid.org/privacy-policy)
ORCID, Inc.
10411 Motor City Drive, Suite 750, Bethesda, MD 20817, USA
-https://testserver.orcid.org
+https://testserver.orcid.org
\ No newline at end of file