use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.
the class ServerConfigService method sendTestMail.
public void sendTestMail(MailHost mailHost, LocalizedOperationResult result) {
validate(mailHost, result);
if (!result.isSuccessful()) {
return;
}
GoMailSender sender = provider.createSender(mailHost);
ValidationBean validationBean = sender.send(TEST_EMAIL_SUBJECT, GoSmtpMailSender.emailBody(), mailHost.getAdminMail());
if (!validationBean.isValid()) {
result.notAcceptable(LocalizedMessage.string("FAILED_TO_SEND_TEST_MAIL", validationBean.getError()));
}
}
use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.
the class GoSmtpMailSenderTest method shouldSet_MailFrom_Property.
@Test
public void shouldSet_MailFrom_Property() throws Exception {
FakeMailSession mailSession = FakeMailSession.setupFor(username, password, from, to, subject, body);
GoSmtpMailSender sender = new GoSmtpMailSender(hostName, port, username, password, true, from, to);
ValidationBean bean = sender.send(subject, body, to);
assertThat(bean, is(ValidationBean.valid()));
mailSession.verifyMessageWasSent();
mailSession.verifyProperty(MAIL_FROM_PROPERTY, from);
}
use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.
the class GoSmtpMailSenderTest method shouldSetProtocolToSMTPWhenSMTPSIsDisabled.
@Test
public void shouldSetProtocolToSMTPWhenSMTPSIsDisabled() throws Exception {
FakeMailSession mailSession = FakeMailSession.setupFor(username, password, from, to, subject, body);
boolean isSMTPSEnabled = false;
GoSmtpMailSender sender = new GoSmtpMailSender(hostName, port, username, password, isSMTPSEnabled, from, to);
ValidationBean bean = sender.send(subject, body, to);
assertThat(bean, is(ValidationBean.valid()));
mailSession.verifyMessageWasSent();
mailSession.verifyProperty(MAIL_TRANSPORT_PROTOCOL_PROPERTY, "smtp");
}
use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.
the class GoSmtpMailSenderTest method testShouldNotSendOutTestEmailToAdminstrator.
@Test
public void testShouldNotSendOutTestEmailToAdminstrator() {
GoSmtpMailSender sender = new GoSmtpMailSender(hostName, 465, to, password, true, from, to);
ValidationBean bean = sender.send(subject, body, to);
assertThat(bean, is(not(ValidationBean.valid())));
}
use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.
the class GoSmtpMailSenderTest method shouldSetDefaultMailTimeoutPropertiesWhenNoOverridingValuesAreProvided.
@Test
public void shouldSetDefaultMailTimeoutPropertiesWhenNoOverridingValuesAreProvided() throws Exception {
FakeMailSession mailSession = FakeMailSession.setupFor(username, password, from, to, subject, body);
GoSmtpMailSender sender = new GoSmtpMailSender(hostName, port, username, password, true, from, to);
ValidationBean bean = sender.send(subject, body, to);
assertThat(bean, is(ValidationBean.valid()));
mailSession.verifyMessageWasSent();
mailSession.verifyProperty(SMTP_CONNECTIONTIMEOUT_PROPERTY, GoConstants.DEFAULT_TIMEOUT);
mailSession.verifyProperty(SMTP_TIMEOUT_PROPERTY, GoConstants.DEFAULT_TIMEOUT);
}
Aggregations