Search in sources :

Example 1 with MailHost

use of com.thoughtworks.go.config.MailHost in project gocd by gocd.

the class ServerConfigServiceTest method shouldSetMessageAsMergedWhenMergingServerConfigChanges.

@Test
public void shouldSetMessageAsMergedWhenMergingServerConfigChanges() {
    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.MERGED);
    serverConfigService.updateServerConfig(mailHost, null, null, null, null, true, "http://site", "https://site", "location", result, "md5");
    assertThat(result.localizable(), Is.is(LocalizedMessage.composite(LocalizedMessage.string("SAVED_CONFIGURATION_SUCCESSFULLY"), LocalizedMessage.string("CONFIG_MERGED"))));
}
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)

Example 2 with MailHost

use of com.thoughtworks.go.config.MailHost in project gocd by gocd.

the class ServerConfigTest method shouldParseServerConfigWithMailhost.

@Test
public void shouldParseServerConfigWithMailhost() throws Exception {
    String xml = "<mailhost hostname=\"smtp.company.com\" port=\"25\" " + "username=\"smtpuser\" password=\"password\" tls=\"true\" " + "from=\"cruise@me.com\" admin=\"jez@me.com\"/>";
    ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
    CruiseConfig config = new MagicalGoConfigXmlLoader(new ConfigCache(), registry).loadConfigHolder(withServerConfig(xml)).config;
    MailHost mailHost = config.server().mailHost();
    assertThat(mailHost, is(new MailHost("smtp.company.com", 25, "smtpuser", "password", true, true, "cruise@me.com", "jez@me.com")));
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) MailHost(com.thoughtworks.go.config.MailHost) MagicalGoConfigXmlLoader(com.thoughtworks.go.config.MagicalGoConfigXmlLoader) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.jupiter.api.Test)

Example 3 with MailHost

use of com.thoughtworks.go.config.MailHost in project gocd by gocd.

the class DeleteMailHostConfigCommandTest method shouldDeleteExistingBackupConfig.

@Test
void shouldDeleteExistingBackupConfig() {
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
    MailHost mailho = new MailHost();
    cruiseConfig.server().setMailHost(mailho);
    DeleteMailHostCommand command = new DeleteMailHostCommand();
    command.update(cruiseConfig);
    assertThat(command.getPreprocessedEntityConfig()).isSameAs(mailho);
}
Also used : MailHost(com.thoughtworks.go.config.MailHost) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.jupiter.api.Test)

Example 4 with MailHost

use of com.thoughtworks.go.config.MailHost in project gocd by gocd.

the class CreateOrUpdateUpdateMailHostCommandTest method shouldAddMailHost.

@Test
void shouldAddMailHost() {
    assertThat(cruiseConfig.server().mailHost()).isNull();
    MailHost newMailHost = new MailHost();
    CreateOrUpdateUpdateMailHostCommand command = new CreateOrUpdateUpdateMailHostCommand(newMailHost);
    command.update(cruiseConfig);
    assertThat(cruiseConfig.server().mailHost()).isSameAs(newMailHost);
}
Also used : MailHost(com.thoughtworks.go.config.MailHost) Test(org.junit.jupiter.api.Test)

Example 5 with MailHost

use of com.thoughtworks.go.config.MailHost in project gocd by gocd.

the class CreateOrUpdateUpdateMailHostCommandTest method shouldValidateMailHost.

@Test
void shouldValidateMailHost() {
    assertThat(cruiseConfig.server().mailHost()).isNull();
    MailHost newMailHost = new MailHost();
    CreateOrUpdateUpdateMailHostCommand command = new CreateOrUpdateUpdateMailHostCommand(newMailHost);
    command.update(cruiseConfig);
    assertThat(command.isValid(cruiseConfig)).isFalse();
    assertThat(newMailHost.errors()).hasSize(4).containsEntry("hostname", Collections.singletonList("Hostname must not be blank.")).containsEntry("port", Collections.singletonList("Port must be a positive number.")).containsEntry("sender_email", Collections.singletonList("Sender email must not be blank.")).containsEntry("admin_email", Collections.singletonList("Admin email must not be blank."));
    assertThat(command.getPreprocessedEntityConfig()).isSameAs(newMailHost);
}
Also used : MailHost(com.thoughtworks.go.config.MailHost) Test(org.junit.jupiter.api.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