fix(platform): sanitize Spring mail test failures
This commit is contained in:
+5
-4
@@ -26,6 +26,7 @@ import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.mail.MailSendException;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
@@ -158,7 +159,7 @@ class SmtpOnboardingWebIntegrationTest {
|
||||
.andReturn().getResponse().getContentAsString();
|
||||
String draftId = html.replaceAll("(?s).*name=\"draftId\" value=\"([0-9]+)\".*", "$1");
|
||||
String rawDiagnostic = "AUTH rejected for smtp-secret-raw-diagnostic";
|
||||
probe.failureMessage = rawDiagnostic;
|
||||
probe.failure = new MailSendException(rawDiagnostic);
|
||||
|
||||
mockMvc.perform(post("/admin/smtp/test")
|
||||
.with(user("admin@example.com").roles("ADMIN"))
|
||||
@@ -185,12 +186,12 @@ class SmtpOnboardingWebIntegrationTest {
|
||||
|
||||
static final class RecordingProbe implements SmtpProbe {
|
||||
private final List<String> recipients = new ArrayList<>();
|
||||
private String failureMessage;
|
||||
private MailSendException failure;
|
||||
|
||||
@Override
|
||||
public void send(SmtpConnection connection, String recipient, String subject, String body) {
|
||||
if (failureMessage != null) {
|
||||
throw new IllegalStateException(failureMessage);
|
||||
if (failure != null) {
|
||||
throw failure;
|
||||
}
|
||||
recipients.add(recipient);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user