use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldWriteMultipleSearchBases.
@Test
public void shouldWriteMultipleSearchBases() throws Exception {
BaseConfig base1 = new BaseConfig("base1");
BaseConfig base2 = new BaseConfig("base2");
BasesConfig basesConfig = new BasesConfig(base1, base2);
LdapConfig ldapConfig = new LdapConfig("url", "managerDn", "managerPassword", "managerPassword", false, basesConfig, "filter");
SecurityConfig securityConfig = new SecurityConfig(ldapConfig, new PasswordFileConfig("some_path"), false);
ServerConfig serverConfig = new ServerConfig(securityConfig, new MailHost(new GoCipher()));
CruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setServerConfig(serverConfig);
xmlWriter.write(cruiseConfig, output, false);
GoConfigHolder holder = xmlLoader.loadConfigHolder(output.toString());
BasesConfig actualBasesConfig = holder.config.server().security().ldapConfig().getBasesConfig();
assertThat(actualBasesConfig.size(), is(2));
assertThat(actualBasesConfig, hasItems(base1, base2));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class PipelineConfigServiceIntegrationTest method setup.
@Before
public void setup() throws Exception {
cachedGoPartials.clear();
configHelper = new GoConfigFileHelper();
dbHelper.onSetUp();
configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
configHelper.onSetUp();
goConfigService.forceNotifyListeners();
user = new Username(new CaseInsensitiveString("current"));
pipelineConfig = GoConfigMother.createPipelineConfigWithMaterialConfig(UUID.randomUUID().toString(), new GitMaterialConfig("FOO"));
goConfigService.addPipeline(pipelineConfig, groupName);
repoConfig1 = new ConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig("url"), XmlPartialConfigProvider.providerName);
repoConfig2 = new ConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig("url2"), XmlPartialConfigProvider.providerName);
goConfigService.updateConfig(new UpdateConfigCommand() {
@Override
public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
cruiseConfig.getConfigRepos().add(repoConfig1);
cruiseConfig.getConfigRepos().add(repoConfig2);
return cruiseConfig;
}
});
GoCipher goCipher = new GoCipher();
goConfigService.updateServerConfig(new MailHost(goCipher), new LdapConfig(goCipher), new PasswordFileConfig("path"), false, goConfigService.configFileMd5(), "artifacts", null, null, "0", null, null, "foo");
UpdateConfigCommand command = goConfigService.modifyAdminPrivilegesCommand(asList(user.getUsername().toString()), new TriStateSelection(Admin.GO_SYSTEM_ADMIN, TriStateSelection.Action.add));
goConfigService.updateConfig(command);
remoteDownstreamPipelineName = "remote-downstream";
partialConfig = PartialConfigMother.pipelineWithDependencyMaterial(remoteDownstreamPipelineName, pipelineConfig, new RepoConfigOrigin(repoConfig1, "repo1_r1"));
goPartialConfig.onSuccessPartialConfig(repoConfig1, partialConfig);
PartialConfig partialConfigFromRepo2 = PartialConfigMother.withPipeline("independent-pipeline", new RepoConfigOrigin(repoConfig2, "repo2_r1"));
goPartialConfig.onSuccessPartialConfig(repoConfig2, partialConfigFromRepo2);
result = new HttpLocalizedOperationResult();
headCommitBeforeUpdate = configRepository.getCurrentRevCommit().name();
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class GoSmtpMailSenderTest method shouldUseTheEncryptedPasswordIfThePasswordIsNotChanged.
@Test
public void shouldUseTheEncryptedPasswordIfThePasswordIsNotChanged() throws InvalidCipherTextException {
String encryptedPassword = new GoCipher().encrypt("encrypted_password");
MailHost mailHost = new MailHost(hostName, 25, "smtpuser", "password", encryptedPassword, false, true, "cruise@me.com", "jez@me.com");
GoMailSender sender = GoSmtpMailSender.createSender(mailHost);
assertThat(sender, is(new BackgroundMailSender(new GoSmtpMailSender(hostName, 25, "smtpuser", "encrypted_password", true, "cruise@me.com", "jez@me.com"))));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class PipelineConfigTest method shouldGetOnlySecureVariables.
@Test
public void shouldGetOnlySecureVariables() throws InvalidCipherTextException {
PipelineConfig pipelineConfig = new PipelineConfig();
EnvironmentVariableConfig username = new EnvironmentVariableConfig("username", "ram");
pipelineConfig.addEnvironmentVariable(username);
GoCipher goCipher = mock(GoCipher.class);
when(goCipher.encrypt("=%HG*^&*&^")).thenReturn("encrypted");
EnvironmentVariableConfig password = new EnvironmentVariableConfig(goCipher, "password", "=%HG*^&*&^", true);
pipelineConfig.addEnvironmentVariable(password);
List<EnvironmentVariableConfig> plainTextVariables = pipelineConfig.getSecureVariables();
assertThat(plainTextVariables, hasItem(password));
assertThat(plainTextVariables, not(hasItem(username)));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class PipelineConfigTest method shouldGetOnlyPlainTextVariables.
@Test
public void shouldGetOnlyPlainTextVariables() throws InvalidCipherTextException {
PipelineConfig pipelineConfig = new PipelineConfig();
EnvironmentVariableConfig username = new EnvironmentVariableConfig("username", "ram");
pipelineConfig.addEnvironmentVariable(username);
GoCipher goCipher = mock(GoCipher.class);
when(goCipher.encrypt("=%HG*^&*&^")).thenReturn("encrypted");
EnvironmentVariableConfig password = new EnvironmentVariableConfig(goCipher, "password", "=%HG*^&*&^", true);
pipelineConfig.addEnvironmentVariable(password);
EnvironmentVariablesConfig plainTextVariables = pipelineConfig.getPlainTextVariables();
assertThat(plainTextVariables, not(hasItem(password)));
assertThat(plainTextVariables, hasItem(username));
}
Aggregations