-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ecf034
commit cbae230
Showing
7 changed files
with
135 additions
and
21 deletions.
There are no files selected for viewing
3 changes: 0 additions & 3 deletions
3
...core/src/main/resources/org/orcid/core/template/how_do_i_verify_my_email_address_html.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package org.orcid.core.manager; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
|
@@ -33,29 +32,39 @@ public class TemplateManagerTest { | |
private OrcidUrlManager orcidUrlManager; | ||
|
||
@Resource(name = "messageSource") | ||
private MessageSource messages; | ||
private MessageSource messages; | ||
|
||
@Test | ||
public void testProcessTemplate() { | ||
Map<String, Object> params = new HashMap<String, Object>(); | ||
params.put("name", "Declan"); | ||
params.put("word", "cucumber"); | ||
String result = templateManager.processTemplate("test.ftl", params); | ||
assertNotNull(result); | ||
assertEquals("Hello, Declan. Did you say cucumber?", result); | ||
} | ||
public void testGenerateVerifyEmailNonPrimaryPlain() throws IOException { | ||
String expectedText = IOUtils.toString(getClass().getResourceAsStream("example_verification_email_non_primary.txt"), StandardCharsets.UTF_8); | ||
|
||
Map<String, Object> templateParams = new HashMap<String, Object>(); | ||
templateParams.put("primaryEmail", "[email protected]"); | ||
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 body = templateManager.processTemplate("verification_email_v2.ftl", templateParams); | ||
|
||
assertEquals(expectedText, body); | ||
Check failure on line 53 in orcid-core/src/test/java/org/orcid/core/manager/TemplateManagerTest.java GitHub Actions / orcid-core Unit Testsorg.orcid.core.manager.TemplateManagerTest ► testGenerateVerifyEmailNonPrimaryPlain
Raw output
|
||
} | ||
|
||
@Test | ||
public void testGenerateVerifyEmailPlainText() throws IOException { | ||
String expectedText = IOUtils.toString(getClass().getResourceAsStream("example_verification_email_body.txt"), StandardCharsets.UTF_8); | ||
public void testGenerateVerifyEmailPrimaryPlain() throws IOException { | ||
String expectedText = IOUtils.toString(getClass().getResourceAsStream("example_verification_email_primary.txt"), StandardCharsets.UTF_8); | ||
|
||
Map<String, Object> templateParams = new HashMap<String, Object>(); | ||
templateParams.put("primaryEmail", "[email protected]"); | ||
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()); | ||
templateParams.put("baseUri", orcidUrlManager.getBaseUrl()); | ||
templateParams.put("isPrimary", true); | ||
addStandardParams(templateParams); | ||
|
||
// Generate body from template | ||
|
@@ -65,8 +74,27 @@ public void testGenerateVerifyEmailPlainText() throws IOException { | |
} | ||
|
||
@Test | ||
public void testGenerateVerifyEmailHtml() throws IOException { | ||
String expectedHtml = IOUtils.toString(getClass().getResourceAsStream("example_verification_email_body.html"), StandardCharsets.UTF_8); | ||
public void testGenerateVerifyEmailNonPrimaryHtml() throws IOException { | ||
String expectedHtml = IOUtils.toString(getClass().getResourceAsStream("example_verification_email_non_primary.html"), StandardCharsets.UTF_8); | ||
|
||
Map<String, Object> templateParams = new HashMap<String, Object>(); | ||
templateParams.put("primaryEmail", "[email protected]"); | ||
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(expectedHtml, htmlBody); | ||
} | ||
|
||
@Test | ||
public void testGenerateVerifyEmailPrimaryHtml() throws IOException { | ||
String expectedHtml = IOUtils.toString(getClass().getResourceAsStream("example_verification_email_primary.html"), StandardCharsets.UTF_8); | ||
|
||
Map<String, Object> templateParams = new HashMap<String, Object>(); | ||
templateParams.put("primaryEmail", "[email protected]"); | ||
|
@@ -75,6 +103,7 @@ public void testGenerateVerifyEmailHtml() throws IOException { | |
templateParams.put("verificationUrl", "http://testserver.orcid.org/verify-email/WnhVWGhYVk9lTng4bWdqaDl0azBXY3BmN1F4dHExOW95SnNxeVJSMy9Scz0"); | ||
templateParams.put("orcidId", "4444-4444-4444-4446"); | ||
templateParams.put("baseUri", orcidUrlManager.getBaseUrl()); | ||
templateParams.put("isPrimary", true); | ||
addStandardParams(templateParams); | ||
|
||
// Generate body from template | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
71 changes: 71 additions & 0 deletions
71
orcid-core/src/test/resources/org/orcid/core/manager/example_verification_email_primary.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>[ORCID] Reminder to verify your email address</title> | ||
</head> | ||
<body> | ||
<div style="padding: 20px; padding-top: 10px; margin: auto;"> | ||
<img src="https://orcid.org/sites/all/themes/orcid/img/orcid-logo.png" alt="ORCID.org"/> | ||
<hr /> | ||
<p style="font-family: arial, helvetica, sans-serif; font-size: 16px; color: #494A4C;"> | ||
Your ORCID iD: 4444-4444-4444-4446<br/> | ||
Your ORCID record is <a href="https://testserver.orcid.org/4444-4444-4444-4446" target="orcid.blank">https://testserver.orcid.org/4444-4444-4444-4446</a> | ||
</p> | ||
<hr /> | ||
<p style="font-family: arial, helvetica, sans-serif; font-size: 16px; color: #494A4C;"> | ||
Hi Josiah Carberry,<br/> | ||
This is a friendly reminder to verify your email address in your ORCID record so that you can unlock 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. </p> | ||
<p style="font-family: arial, helvetica, sans-serif; font-size: 16px; color: #494A4C;"> | ||
<b>How do I verify my email address?</b><br /> | ||
Simply click the button below to sign into your ORCID record and complete verification. <table cellpadding="0" cellspacing="0" style="font-family: Helvetica, Arial, sans-serif; border-spacing: 0px; border-collapse: separate !important; border-radius: 4px; margin: 0 auto; margin-top:20px"> | ||
<tbody> | ||
<tr> | ||
<td style="border-spacing: 0px; border-collapse: collapse; line-height: 24px; font-size: 16px; border-radius: 4px; margin: 0;"> | ||
<a id="verificationButton" | ||
href="http://testserver.orcid.org/verify-email/WnhVWGhYVk9lTng4bWdqaDl0azBXY3BmN1F4dHExOW95SnNxeVJSMy9Scz0?lang=en" | ||
style="font-size: 20px; font-family: Helvetica, Arial, sans-serif; text-decoration: none; border-radius: 4.8px; line-height: 25px; display: inline-block; font-weight: normal; white-space: nowrap; background-color: #31789B; color: #ffffff; padding: 8px 16px; border: 1px solid #31789B;" | ||
>Verify your email address</a> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</p> | ||
<p style="font-family: arial, helvetica, sans-serif; font-size: 16px; color: #494A4C;"> | ||
Or, copy and paste the link below into your browser's address bar: <table cellpadding="0" cellspacing="0" style="font-family: arial, helvetica, sans-serif; border-spacing: 0px; border-collapse: separate !important; border-radius: 4px; margin: 0 auto; "> | ||
<tbody> | ||
<tr> | ||
<td> | ||
<p align="center" class="text-center" style="line-height: 24px; font-size: 16px; margin: 0; padding-bottom: 30px; padding-top: 20px; word-break: break-word;"> | ||
<a id="verificationUrl" | ||
href="http://testserver.orcid.org/verify-email/WnhVWGhYVk9lTng4bWdqaDl0azBXY3BmN1F4dHExOW95SnNxeVJSMy9Scz0?lang=en" | ||
target="orcid.blank" | ||
>http://testserver.orcid.org/verify-email/WnhVWGhYVk9lTng4bWdqaDl0azBXY3BmN1F4dHExOW95SnNxeVJSMy9Scz0?lang=en</a> | ||
</p> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</p> <hr /> | ||
<p style="font-family: arial, helvetica, sans-serif; font-size: 16px; color: #494A4C;"> | ||
Please visit our <a href="https://info.orcid.org/researchers/" target="orcid.blank">researcher homepage</a> for more information on how to get the most out of your ORCID record. | ||
</p> | ||
<p> | ||
<pre style="font-family: arial, helvetica, sans-serif;font-size: 15px;color: #494A4C;"> | ||
Warm Regards, | ||
ORCID Support Team | ||
<a href="https://support.orcid.org/hc/en-us" target="_blank" style="color: #2E7F9F;">https://support.orcid.org</a> | ||
</pre> | ||
</p> | ||
<p style="font-family: arial, helvetica, sans-serif;font-size: 15px;color: #494A4C;"> | ||
You have received this email as a service announcement related to your ORCID Account.</p> | ||
<p style="font-family: arial, helvetica, sans-serif;font-size: 15px;color: #494A4C;"> | ||
<small> | ||
<a href="https://testserver.orcid.org/account" target="_blank" style="color: #2E7F9F;">email preferences</a> | ||
| <a href="https://testserver.orcid.org/privacy-policy" target="_blank" style="color: #2E7F9F;">privacy policy</a> | ||
| ORCID, Inc. | 10411 Motor City Drive, Suite 750, Bethesda, MD 20817, USA | ||
| <a href="https://testserver.orcid.org" target="_blank" style="color: #2E7F9F;">ORCID.org</a> | ||
</small> | ||
</p> | ||
</div> | ||
</body> | ||
</html> |
20 changes: 20 additions & 0 deletions
20
orcid-core/src/test/resources/org/orcid/core/manager/example_verification_email_primary.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Your ORCID iD: 4444-4444-4444-4446 | ||
Your ORCID record is https://testserver.orcid.org/4444-4444-4444-4446 | ||
|
||
Hi Josiah Carberry, | ||
This is a friendly reminder to verify your email address in your ORCID record so that you can unlock 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? | ||
Or, copy and paste the link below into your browser's address bar: | ||
http://testserver.orcid.org/verify-email/WnhVWGhYVk9lTng4bWdqaDl0azBXY3BmN1F4dHExOW95SnNxeVJSMy9Scz0?lang=en | ||
Please visit our <a href="https://info.orcid.org/researchers/" target="orcid.blank">researcher homepage</a> for more information on how to get the most out of your ORCID record. | ||
Warm Regards, | ||
ORCID Support Team | ||
https://support.orcid.org | ||
|
||
You have received this email as a service announcement related to your ORCID Account. | ||
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 |
This file was deleted.
Oops, something went wrong.