use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class ElasticProfileDTO method toDomainModel.
public ElasticProfile toDomainModel() {
ArrayList<ConfigurationProperty> configurationProperties = new ArrayList<>();
this.properties.forEach((key, value) -> {
configurationProperties.add(new ConfigurationProperty(new ConfigurationKey(key), new ConfigurationValue(value)));
});
ElasticProfile elasticProfile = new ElasticProfile(this.id, this.clusterProfileId);
elasticProfile.addConfigurations(configurationProperties);
return elasticProfile;
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class JobAgentMetadata method clusterProfile.
public ClusterProfile clusterProfile() {
Map map = GSON.fromJson(clusterProfileMetadata, LinkedHashMap.class);
if (map == null || map.isEmpty()) {
return null;
}
String pluginId = (String) map.get("pluginId");
String id = (String) map.get("id");
Map<String, String> properties = (Map<String, String>) map.get("properties");
Collection<ConfigurationProperty> configProperties = properties.entrySet().stream().map(entry -> new ConfigurationProperty(new ConfigurationKey(entry.getKey()), new ConfigurationValue(entry.getValue()))).collect(Collectors.toList());
return new ClusterProfile(id, pluginId, configProperties);
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class JobAgentMetadata method elasticProfile.
public ElasticProfile elasticProfile() {
Map map = GSON.fromJson(elasticAgentProfileMetadata, LinkedHashMap.class);
String clusterProfileId = (String) map.get("clusterProfileId");
String id = (String) map.get("id");
Map<String, String> properties = (Map<String, String>) map.get("properties");
Collection<ConfigurationProperty> configProperties = properties.entrySet().stream().map(entry -> new ConfigurationProperty(new ConfigurationKey(entry.getKey()), new ConfigurationValue(entry.getValue()))).collect(Collectors.toList());
return new ElasticProfile(id, clusterProfileId, configProperties);
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class DeletePackageConfigCommandTest method setup.
@BeforeEach
public void setup() throws Exception {
currentUser = new Username(new CaseInsensitiveString("user"));
cruiseConfig = new GoConfigMother().defaultCruiseConfig();
packageUuid = "random-uuid";
configuration = new Configuration(new ConfigurationProperty(new ConfigurationKey("PACKAGE_ID"), new ConfigurationValue("prettyjson")));
packageDefinition = new PackageDefinition(packageUuid, "prettyjson", configuration);
result = new HttpLocalizedOperationResult();
PackageRepositories repositories = cruiseConfig.getPackageRepositories();
PackageRepository repository = new PackageRepository();
repository.addPackage(packageDefinition);
repositories.add(repository);
cruiseConfig.setPackageRepositories(repositories);
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class RoleConfigCommandTest method shouldEncryptRoleConfig.
@Test
public void shouldEncryptRoleConfig() throws CryptoException {
setAuthorizationPluginInfo();
cruiseConfig.server().security().securityAuthConfigs().add(new SecurityAuthConfig("ldap", "cd.go.github"));
PluginRoleConfig role = new PluginRoleConfig("blackbird", "ldap");
role.addConfigurations(asList(new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("pub_v1")), new ConfigurationProperty(new ConfigurationKey("k2"), new ConfigurationValue("pub_v2")), new ConfigurationProperty(new ConfigurationKey("k3"), new ConfigurationValue("pub_v3"))));
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
RoleConfigCommand command = new StubCommand(goConfigService, role, extension, currentUser, result);
assertThat(role.getProperty("k1").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k1").getConfigValue(), is("pub_v1"));
assertThat(role.getProperty("k1").getValue(), is("pub_v1"));
assertThat(role.getProperty("k2").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k2").getConfigValue(), is("pub_v2"));
assertThat(role.getProperty("k2").getValue(), is("pub_v2"));
assertThat(role.getProperty("k3").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k3").getConfigValue(), is("pub_v3"));
assertThat(role.getProperty("k3").getValue(), is("pub_v3"));
command.encrypt(cruiseConfig);
GoCipher goCipher = new GoCipher();
assertThat(role.getProperty("k1").getEncryptedValue(), is(goCipher.encrypt("pub_v1")));
assertThat(role.getProperty("k1").getConfigValue(), is(nullValue()));
assertThat(role.getProperty("k1").getValue(), is("pub_v1"));
assertThat(role.getProperty("k2").getEncryptedValue(), is(nullValue()));
assertThat(role.getProperty("k2").getConfigValue(), is("pub_v2"));
assertThat(role.getProperty("k2").getValue(), is("pub_v2"));
assertThat(role.getProperty("k3").getEncryptedValue(), is(goCipher.encrypt("pub_v3")));
assertThat(role.getProperty("k3").getConfigValue(), is(nullValue()));
assertThat(role.getProperty("k3").getValue(), is("pub_v3"));
}
Aggregations