use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class EnvironmentVariablesConfig method setConfigAttributes.
@Override
public void setConfigAttributes(Object attributes) {
this.clear();
if (attributes != null) {
for (Map attributeMap : (List<Map>) attributes) {
EnvironmentVariableConfig environmentVariableConfig = new EnvironmentVariableConfig(new GoCipher());
try {
environmentVariableConfig.setConfigAttributes(attributeMap);
this.add(environmentVariableConfig);
} catch (IllegalArgumentException e) {
continue;
}
}
}
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class ServerConfigTest method shouldIgnoreErrorsFieldOnEquals.
@Test
public void shouldIgnoreErrorsFieldOnEquals() throws Exception {
ServerConfig one = new ServerConfig(new SecurityConfig(), new MailHost(new GoCipher()), new SiteUrl("siteURL"), new SecureSiteUrl("secureURL"));
one.addError("siteUrl", "I dont like this url");
assertThat(one, is(new ServerConfig(new SecurityConfig(), new MailHost(new GoCipher()), new SiteUrl("siteURL"), new SecureSiteUrl("secureURL"))));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class ServerConfigTest method shouldNotUpdatePasswordForMailHostIfNotChangedOrNull.
@Test
public void shouldNotUpdatePasswordForMailHostIfNotChangedOrNull() throws IOException {
File cipherFile = new SystemEnvironment().getDESCipherFile();
FileUtils.deleteQuietly(cipherFile);
FileUtils.writeStringToFile(cipherFile, "269298bc31c44620", UTF_8);
GoCipher goCipher = new GoCipher();
MailHost mailHost = new MailHost("abc", 12, "admin", "p", null, true, true, "anc@mail.com", "anc@mail.com", goCipher);
ServerConfig serverConfig = new ServerConfig(null, mailHost, null, null);
assertThat(serverConfig.mailHost().getPassword(), is("p"));
String encryptedPassword = serverConfig.mailHost().getEncryptedPassword();
serverConfig.updateMailHost(new MailHost("abc", 12, "admin", "p", encryptedPassword, false, /* Password Not Changed */
true, "anc@mail.com", "anc@mail.com", goCipher));
assertThat(serverConfig.mailHost().getPassword(), is("p"));
assertThat(serverConfig.mailHost().getEncryptedPassword(), is(encryptedPassword));
serverConfig.updateMailHost(new MailHost("abc", 12, "admin", null, "", true, true, "anc@mail.com", "anc@mail.com"));
assertThat(serverConfig.mailHost().getPassword(), is(nullValue()));
assertThat(serverConfig.mailHost().getEncryptedPassword(), is(nullValue()));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class MaterialConfigsTest method shouldSetTfsConfigAttributesForMaterial.
@Test
public void shouldSetTfsConfigAttributesForMaterial() {
MaterialConfigs materialConfigs = new MaterialConfigs();
Map<String, String> tfsAttrMap = new HashMap<>();
tfsAttrMap.put(TfsMaterialConfig.URL, "foo");
tfsAttrMap.put(TfsMaterialConfig.USERNAME, "bar");
tfsAttrMap.put(TfsMaterialConfig.PASSWORD, "baz");
tfsAttrMap.put(TfsMaterialConfig.PROJECT_PATH, "to_hell");
tfsAttrMap.put(TfsMaterialConfig.MATERIAL_NAME, "crapy_material");
tfsAttrMap.put(TfsMaterialConfig.DOMAIN, "CORPORATE");
Map<String, Object> attributeMap = new HashMap<>();
attributeMap.put(AbstractMaterialConfig.MATERIAL_TYPE, TfsMaterialConfig.TYPE);
attributeMap.put(TfsMaterialConfig.TYPE, tfsAttrMap);
materialConfigs.setConfigAttributes(attributeMap);
TfsMaterialConfig tfsMaterialConfig = tfs(new GoCipher(), new UrlArgument("foo"), "bar", "CORPORATE", "baz", "to_hell");
tfsMaterialConfig.setName(new CaseInsensitiveString("crapy_material"));
assertThat(materialConfigs.first(), is(tfsMaterialConfig));
assertThat(tfsMaterialConfig.getPassword(), is("baz"));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class PasswordDeserializerTest method shouldErrorOutWhenBothPasswordAndEncryptedPasswordAreGivenForDeserialization.
@Test
public void shouldErrorOutWhenBothPasswordAndEncryptedPasswordAreGivenForDeserialization() throws CryptoException {
SvnMaterialConfig svnMaterialConfig = svn();
PasswordDeserializer passwordDeserializer = new PasswordDeserializer();
passwordDeserializer.deserialize("password", new GoCipher().encrypt("encryptedPassword"), svnMaterialConfig);
assertThat(svnMaterialConfig.errors().getAllOn("password"), is(Arrays.asList("You may only specify `password` or `encrypted_password`, not both!")));
assertThat(svnMaterialConfig.errors().getAllOn("encryptedPassword"), is(Arrays.asList("You may only specify `password` or `encrypted_password`, not both!")));
}
Aggregations