use of com.thoughtworks.go.config.MailHost in project gocd by gocd.
the class EmailNotificationListenerTest method shouldCreateMailSenderIfMailHostIsConfigured.
@Test
public void shouldCreateMailSenderIfMailHostIsConfigured() {
final MailHost mailHost = new MailHost("hostName", 1234, "user", "pass", true, true, "from", "admin@local.com");
final CruiseConfig config = GoConfigMother.cruiseConfigWithMailHost(mailHost);
when(goConfigService.currentCruiseConfig()).thenReturn(config);
when(goMailSenderFactory.createSender()).thenReturn(GoSmtpMailSender.createSender(mailHost));
emailNotificationListener.onMessage(new SendEmailMessage("subject", "body", "to"));
}
use of com.thoughtworks.go.config.MailHost in project gocd by gocd.
the class MailServerControllerV1 method sendTestEmail.
public String sendTestEmail(Request request, Response response) throws IOException {
MailHost mailHost = buildEntityFromRequestBody(request);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
serverConfigService.sendTestMail(mailHost, result);
return renderHTTPOperationResult(result, request, response);
}
use of com.thoughtworks.go.config.MailHost in project gocd by gocd.
the class MailServerRepresenter method fromJSON.
public static MailHost fromJSON(JsonReader jsonReader) {
MailHost mailHost = new MailHost(new GoCipher());
jsonReader.readStringIfPresent("hostname", mailHost::setHostName).readIntIfPresent("port", mailHost::setPort).readStringIfPresent("username", mailHost::setUsername).readBooleanIfPresent("tls", mailHost::setTls).readStringIfPresent("sender_email", mailHost::setFrom).readStringIfPresent("admin_email", mailHost::setAdminMail);
String password = jsonReader.getStringOrDefault("password", null);
String encryptedPassword = jsonReader.getStringOrDefault("encrypted_password", null);
mailHost.setEncryptedPassword(PASSWORD_DESERIALIZER.deserialize(password, encryptedPassword, mailHost));
return mailHost;
}
use of com.thoughtworks.go.config.MailHost in project gocd by gocd.
the class ServerConfigServiceTest method shouldSetMessageAsUpdatedWhenUpdatingServerConfigChanges.
@Test
public void shouldSetMessageAsUpdatedWhenUpdatingServerConfigChanges() {
GoConfigService goConfigService = mock(GoConfigService.class);
UserService userService = mock(UserService.class);
ServerConfigService serverConfigService = new ServerConfigService(goConfigService, userService);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
MailHost mailHost = new MailHost(new GoCipher());
when(goConfigService.updateServerConfig(mailHost, true, "md5", null, null, null, null, "http://site", "https://site", "location")).thenReturn(ConfigSaveState.UPDATED);
serverConfigService.updateServerConfig(mailHost, null, null, null, null, true, "http://site", "https://site", "location", result, "md5");
assertThat(result.localizable(), Is.is(LocalizedMessage.string("SAVED_CONFIGURATION_SUCCESSFULLY")));
}
Aggregations