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"))));
}
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")));
}
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);
}
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);
}
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);
}
Aggregations