Search in sources :

Example 6 with MailHost

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"));
}
Also used : MailHost(com.thoughtworks.go.config.MailHost) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.jupiter.api.Test)

Example 7 with MailHost

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);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) MailHost(com.thoughtworks.go.config.MailHost)

Example 8 with MailHost

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;
}
Also used : GoCipher(com.thoughtworks.go.security.GoCipher) MailHost(com.thoughtworks.go.config.MailHost)

Example 9 with 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")));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) GoCipher(com.thoughtworks.go.security.GoCipher) MailHost(com.thoughtworks.go.config.MailHost) Test(org.junit.Test)

Aggregations

MailHost (com.thoughtworks.go.config.MailHost)9 Test (org.junit.jupiter.api.Test)5 GoCipher (com.thoughtworks.go.security.GoCipher)3 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)3 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)2 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)2 Test (org.junit.Test)2 ConfigCache (com.thoughtworks.go.config.ConfigCache)1 MagicalGoConfigXmlLoader (com.thoughtworks.go.config.MagicalGoConfigXmlLoader)1 ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)1