keycloak-aplcache
Changes
testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/MailUtils.java 51(+35 -16)
testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/UserTest.java 12(+11 -1)
Details
diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/MailUtils.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/MailUtils.java
index 415cfd1..7fa362d 100644
--- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/MailUtils.java
+++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/MailUtils.java
@@ -42,30 +42,49 @@ public class MailUtils {
}
public static String getPasswordResetEmailLink(MimeMessage message) throws IOException, MessagingException {
- Multipart multipart = (Multipart) message.getContent();
+ return getPasswordResetEmailLink(new EmailBody(message));
+ }
- final String textContentType = multipart.getBodyPart(0).getContentType();
+ public static String getPasswordResetEmailLink(EmailBody body) throws IOException, MessagingException {
+ final String textChangePwdUrl = getLink(body.getText());
+ final String htmlChangePwdUrl = getLink(body.getHtml());
+ assertEquals(htmlChangePwdUrl, textChangePwdUrl);
- assertEquals("text/plain; charset=UTF-8", textContentType);
+ return htmlChangePwdUrl;
+ }
- final String textBody = (String) multipart.getBodyPart(0).getContent();
- final String textChangePwdUrl = getLink(textBody);
+ public static EmailBody getBody(MimeMessage message) throws IOException, MessagingException {
+ return new EmailBody(message);
+ }
- final String htmlContentType = multipart.getBodyPart(1).getContentType();
+ public static class EmailBody {
- assertEquals("text/html; charset=UTF-8", htmlContentType);
+ private String text;
+ private String html;
- final String htmlBody = (String) multipart.getBodyPart(1).getContent();
- final String htmlChangePwdUrl = MailUtils.getLink(htmlBody);
- // .replace() accounts for escaping the ampersand
- // It's not escaped in the html version because html retrieved from a
- // message bundle is considered safe and it must be unescaped to display
- // properly.
- final String htmlChangePwdUrlToCompare = htmlChangePwdUrl.replace("&", "&");
+ private EmailBody(MimeMessage message) throws IOException, MessagingException {
+ Multipart multipart = (Multipart) message.getContent();
- assertEquals(htmlChangePwdUrlToCompare, textChangePwdUrl);
+ String textContentType = multipart.getBodyPart(0).getContentType();
- return htmlChangePwdUrl;
+ assertEquals("text/plain; charset=UTF-8", textContentType);
+
+ text = (String) multipart.getBodyPart(0).getContent();
+
+ String htmlContentType = multipart.getBodyPart(1).getContentType();
+
+ assertEquals("text/html; charset=UTF-8", htmlContentType);
+
+ html = (String) multipart.getBodyPart(1).getContent();
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public String getHtml() {
+ return html;
+ }
}
}
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/UserTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/UserTest.java
index 20de89f..fafc4ad 100755
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/UserTest.java
+++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/UserTest.java
@@ -681,7 +681,17 @@ public class UserTest extends AbstractAdminTest {
MimeMessage message = greenMail.getReceivedMessages()[0];
- String link = MailUtils.getPasswordResetEmailLink(message);
+ MailUtils.EmailBody body = MailUtils.getBody(message);
+
+ assertTrue(body.getText().contains("Update Password"));
+ assertTrue(body.getText().contains("your Admin-client-test account"));
+ assertTrue(body.getText().contains("This link will expire within 720 minutes"));
+
+ assertTrue(body.getHtml().contains("Update Password"));
+ assertTrue(body.getHtml().contains("your Admin-client-test account"));
+ assertTrue(body.getHtml().contains("This link will expire within 720 minutes"));
+
+ String link = MailUtils.getPasswordResetEmailLink(body);
driver.navigate().to(link);
diff --git a/testsuite/integration-deprecated/src/test/java/org/keycloak/testsuite/broker/AbstractIdentityProviderTest.java b/testsuite/integration-deprecated/src/test/java/org/keycloak/testsuite/broker/AbstractIdentityProviderTest.java
index 49b037b..a6bda73 100755
--- a/testsuite/integration-deprecated/src/test/java/org/keycloak/testsuite/broker/AbstractIdentityProviderTest.java
+++ b/testsuite/integration-deprecated/src/test/java/org/keycloak/testsuite/broker/AbstractIdentityProviderTest.java
@@ -358,13 +358,7 @@ public abstract class AbstractIdentityProviderTest {
final String htmlBody = (String) multipart.getBodyPart(1).getContent();
final String htmlChangePwdUrl = MailUtil.getLink(htmlBody);
- // .replace() accounts for escaping the ampersand
- // It's not escaped in the html version because html retrieved from a
- // message bundle is considered safe and it must be unescaped to display
- // properly.
- final String htmlChangePwdUrlToCompare = htmlChangePwdUrl.replace("&", "&");
-
- assertEquals(htmlChangePwdUrlToCompare, textVerificationUrl);
+ assertEquals(htmlChangePwdUrl, textVerificationUrl);
return htmlChangePwdUrl;
}
diff --git a/themes/src/main/resources/theme/base/email/html/executeActions.ftl b/themes/src/main/resources/theme/base/email/html/executeActions.ftl
index 509f617..5999feb 100755
--- a/themes/src/main/resources/theme/base/email/html/executeActions.ftl
+++ b/themes/src/main/resources/theme/base/email/html/executeActions.ftl
@@ -1,6 +1,7 @@
-<#assign requiredActionsText>
-<#if requiredActions??><#list requiredActions><b><#items as reqActionItem>${msg("requiredAction.${reqActionItem}")}<#sep>, </#items></b></#list><#else></#if>
-</#assign>
+<#outputformat "plainText">
+<#assign requiredActionsText><#if requiredActions??><#list requiredActions><#items as reqActionItem>${msg("requiredAction.${reqActionItem}")}<#sep>, </#sep></#items></#list></#if></#assign>
+</#outputformat>
+
<html>
<body>
${msg("executeActionsBodyHtml",link, linkExpiration, realmName, requiredActionsText)?no_esc}
diff --git a/themes/src/main/resources/theme/base/email/text/email-test.ftl b/themes/src/main/resources/theme/base/email/text/email-test.ftl
index 19942c7..f1becdd 100644
--- a/themes/src/main/resources/theme/base/email/text/email-test.ftl
+++ b/themes/src/main/resources/theme/base/email/text/email-test.ftl
@@ -1 +1,2 @@
+<#ftl output_format="plainText">
${msg("emailTestBody", realmName)}
\ No newline at end of file
diff --git a/themes/src/main/resources/theme/base/email/text/email-verification.ftl b/themes/src/main/resources/theme/base/email/text/email-verification.ftl
index 0ae601f..152de22 100644
--- a/themes/src/main/resources/theme/base/email/text/email-verification.ftl
+++ b/themes/src/main/resources/theme/base/email/text/email-verification.ftl
@@ -1 +1,2 @@
+<#ftl output_format="plainText">
${msg("emailVerificationBody",link, linkExpiration, realmName)}
\ No newline at end of file
diff --git a/themes/src/main/resources/theme/base/email/text/event-login_error.ftl b/themes/src/main/resources/theme/base/email/text/event-login_error.ftl
index 7835c91..bfb4036 100644
--- a/themes/src/main/resources/theme/base/email/text/event-login_error.ftl
+++ b/themes/src/main/resources/theme/base/email/text/event-login_error.ftl
@@ -1 +1,2 @@
+<#ftl output_format="plainText">
${msg("eventLoginErrorBody",event.date,event.ipAddress)}
\ No newline at end of file
diff --git a/themes/src/main/resources/theme/base/email/text/event-remove_totp.ftl b/themes/src/main/resources/theme/base/email/text/event-remove_totp.ftl
index 8930b64..a7e3b68 100644
--- a/themes/src/main/resources/theme/base/email/text/event-remove_totp.ftl
+++ b/themes/src/main/resources/theme/base/email/text/event-remove_totp.ftl
@@ -1 +1,2 @@
+<#ftl output_format="plainText">
${msg("eventRemoveTotpBody",event.date, event.ipAddress)}
\ No newline at end of file
diff --git a/themes/src/main/resources/theme/base/email/text/event-update_password.ftl b/themes/src/main/resources/theme/base/email/text/event-update_password.ftl
index 754daac..2ec7ea0 100644
--- a/themes/src/main/resources/theme/base/email/text/event-update_password.ftl
+++ b/themes/src/main/resources/theme/base/email/text/event-update_password.ftl
@@ -1 +1,2 @@
+<#ftl output_format="plainText">
${msg("eventUpdatePasswordBody",event.date, event.ipAddress)}
\ No newline at end of file
diff --git a/themes/src/main/resources/theme/base/email/text/event-update_totp.ftl b/themes/src/main/resources/theme/base/email/text/event-update_totp.ftl
index 3a7b0f7..14778b5 100644
--- a/themes/src/main/resources/theme/base/email/text/event-update_totp.ftl
+++ b/themes/src/main/resources/theme/base/email/text/event-update_totp.ftl
@@ -1 +1,2 @@
+<#ftl output_format="plainText">
${msg("eventUpdateTotpBody",event.date, event.ipAddress)}
\ No newline at end of file
diff --git a/themes/src/main/resources/theme/base/email/text/executeActions.ftl b/themes/src/main/resources/theme/base/email/text/executeActions.ftl
index 39ce047..af9d5c4 100755
--- a/themes/src/main/resources/theme/base/email/text/executeActions.ftl
+++ b/themes/src/main/resources/theme/base/email/text/executeActions.ftl
@@ -1,4 +1,4 @@
-<#assign requiredActionsText>
-<#if requiredActions??><#list requiredActions><#items as reqActionItem>${msg("requiredAction.${reqActionItem}")}<#sep>, </#items></#list><#else></#if>
-</#assign>
+<#ftl output_format="plainText">
+<#assign requiredActionsText><#if requiredActions??><#list requiredActions><#items as reqActionItem>${msg("requiredAction.${reqActionItem}")}<#sep>, </#items></#list><#else></#if></#assign>
+
${msg("executeActionsBody",link, linkExpiration, realmName, requiredActionsText)}
\ No newline at end of file
diff --git a/themes/src/main/resources/theme/base/email/text/identity-provider-link.ftl b/themes/src/main/resources/theme/base/email/text/identity-provider-link.ftl
index a8c0d54..0232e12 100644
--- a/themes/src/main/resources/theme/base/email/text/identity-provider-link.ftl
+++ b/themes/src/main/resources/theme/base/email/text/identity-provider-link.ftl
@@ -1 +1,2 @@
+<#ftl output_format="plainText">
${msg("identityProviderLinkBody", identityProviderAlias, realmName, identityProviderContext.username, link, linkExpiration)}
\ No newline at end of file
diff --git a/themes/src/main/resources/theme/base/email/text/password-reset.ftl b/themes/src/main/resources/theme/base/email/text/password-reset.ftl
index aba4fd1..e22649d 100755
--- a/themes/src/main/resources/theme/base/email/text/password-reset.ftl
+++ b/themes/src/main/resources/theme/base/email/text/password-reset.ftl
@@ -1 +1,2 @@
+<#ftl output_format="plainText">
${msg("passwordResetBody",link, linkExpiration, realmName)}
\ No newline at end of file