Skip to content

Commit 6c6a2e8

Browse files
ulischulteSteKoe
andauthored
Fix mail template test (#2715)
* fixed thymeleaf template test * formatting * fix(MailNotifierIntegrationTest): enhanced tests * fix missing mail notification image in docs * removed unused import * fix missing mail notification image in docs * fix formatting --------- Co-authored-by: Stephan Köninger <[email protected]>
1 parent 70caf64 commit 6c6a2e8

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

spring-boot-admin-docs/src/site/asciidoc/server-notifications.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,4 +522,4 @@ To enable https://www.rocket.chat/[Rocket.Chat] notifications you need a persona
522522
| spring.boot.admin.notify.rocketchat.message
523523
| Text to send. SpEL-expressions are supported.
524524
| `+++"*#{instance.registration.name}* (#{instance.id}) is *#{event.statusInfo.status}*"+++`
525-
|===
525+
|===

spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/notify/MailNotifierIntegrationTest.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package de.codecentric.boot.admin.server.notify;
1818

1919
import java.io.FileNotFoundException;
20-
import java.io.IOException;
2120
import java.net.URL;
2221

2322
import org.assertj.core.api.WithAssertions;
@@ -49,19 +48,28 @@ void fileProtocolIsNotAllowed() {
4948
@Test
5049
void httpProtocolIsNotAllowed() {
5150
assertThatThrownBy(() -> {
52-
URL resource = getClass().getClassLoader().getResource(".");
5351
mailNotifier.setTemplate(
5452
"https://raw.githubusercontent.com/codecentric/spring-boot-admin/gh-pages/vulnerable-file.html");
5553
mailNotifier.getBody(new Context());
5654
}).hasCauseInstanceOf(FileNotFoundException.class);
5755
}
5856

5957
@Test
60-
void classpathProtocolIsAllowed() throws IOException {
58+
void classpathProtocolIsAllowed() {
59+
assertThatNoException().isThrownBy(() -> {
60+
mailNotifier.setTemplate("/de/codecentric/boot/admin/server/notify/allowed-file.html");
61+
mailNotifier.getBody(new Context());
62+
});
63+
}
64+
65+
@Test
66+
void callToReflectionUtilsAreNotAllwed() {
6167
assertThatThrownBy(() -> {
6268
mailNotifier.setTemplate("/de/codecentric/boot/admin/server/notify/vulnerable-file.html");
63-
String body = mailNotifier.getBody(new Context());
64-
}).rootCause().hasMessageContaining("error=2, No such file or directory");
69+
mailNotifier.getBody(new Context());
70+
}).rootCause()
71+
.hasMessageContaining(
72+
"Access is forbidden for type 'org.springframework.util.ReflectionUtils' in this expression context.");
6573
}
6674

6775
@EnableAdminServer
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html xmlns:th="http://www.thymeleaf.org">
3+
<head>
4+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
5+
</head>
6+
<body>
7+
8+
I am fine!
9+
10+
</body>
11+
</html>

0 commit comments

Comments
 (0)