Search in sources :

Example 6 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class ClusterProfileDTO method toDomainModel.

public ClusterProfile toDomainModel() {
    ArrayList<ConfigurationProperty> configurationProperties = new ArrayList<>();
    this.properties.forEach((key, value) -> {
        configurationProperties.add(new ConfigurationProperty(new ConfigurationKey(key), new ConfigurationValue(value)));
    });
    ClusterProfile clusterProfile = new ClusterProfile(this.id, this.pluginId);
    clusterProfile.addConfigurations(configurationProperties);
    return clusterProfile;
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) ArrayList(java.util.ArrayList) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile)

Example 7 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class ClusterProfilesServiceIntegrationTest method shouldUpdateExistingClusterProfile.

@Test
public void shouldUpdateExistingClusterProfile() {
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    String clusterId = "cluster1";
    String pluginid = "pluginid";
    ClusterProfile clusterProfile = new ClusterProfile(clusterId, pluginid);
    ConfigurationProperty property = new ConfigurationProperty(new ConfigurationKey("username"), new ConfigurationValue("view"));
    ClusterProfile newClusterProfile = new ClusterProfile(clusterId, pluginid, property);
    clusterProfilesService.create(clusterProfile, new Username("Bob"), new HttpLocalizedOperationResult());
    assertThat(clusterProfilesService.getPluginProfiles().size(), is(1));
    assertThat(clusterProfilesService.getPluginProfiles().find(clusterId), is(clusterProfile));
    clusterProfilesService.update(newClusterProfile, new Username("Bob"), result);
    assertThat(result.isSuccessful(), is(true));
    assertThat(clusterProfilesService.getPluginProfiles().size(), is(1));
    assertThat(clusterProfilesService.getPluginProfiles().find(clusterId), is(newClusterProfile));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Username(com.thoughtworks.go.server.domain.Username) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 8 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class ElasticProfileServiceIntegrationTest method shouldUpdateElasticAgentProfile.

@Test
public void shouldUpdateElasticAgentProfile() {
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    assertThat(elasticProfileService.getPluginProfiles()).hasSize(0);
    elasticProfileService.create(username, elasticProfile, result);
    assertThat(elasticProfileService.getPluginProfiles()).hasSize(1);
    ElasticProfile existing = elasticProfileService.getPluginProfiles().get(0);
    assertThat(existing.getConfigWithErrorsAsMap()).isEmpty();
    elasticProfileService.update(username, entityHashingService.hashForEntity(this.elasticProfile), newElasticProfile, result);
    ElasticProfile updated = elasticProfileService.getPluginProfiles().get(0);
    assertThat(updated.getId()).isEqualTo(elasticProfileId);
    assertThat(updated.get(0)).isEqualTo(new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1")));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.jupiter.api.Test)

Example 9 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class ElasticProfileServiceIntegrationTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    pluginId = "aws";
    clusterProfileId = "prod-cluster";
    elasticProfileId = "id";
    username = new Username("Bob");
    configHelper = new GoConfigFileHelper();
    configHelper.onSetUp();
    goConfigService.forceNotifyListeners();
    clusterProfile = new ClusterProfile(clusterProfileId, pluginId);
    elasticProfile = new ElasticProfile(elasticProfileId, clusterProfileId);
    newElasticProfile = new ElasticProfile(elasticProfileId, clusterProfileId, new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1")));
    goConfigService.updateConfig(cruiseConfig -> {
        BasicCruiseConfig basicCruiseConfig = new BasicCruiseConfig();
        basicCruiseConfig.initializeServer();
        ClusterProfiles clusterProfiles = new ClusterProfiles();
        clusterProfiles.add(clusterProfile);
        basicCruiseConfig.getElasticConfig().setClusterProfiles(clusterProfiles);
        return basicCruiseConfig;
    });
    elasticProfileService.setProfileConfigurationValidator(validator);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Username(com.thoughtworks.go.server.domain.Username) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfiles(com.thoughtworks.go.config.elastic.ClusterProfiles) GoConfigFileHelper(com.thoughtworks.go.util.GoConfigFileHelper) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class PluginRoleConfigTest method hasErrors_shouldBeTrueIfConfigurationPropertiesHasErrors.

@Test
public void hasErrors_shouldBeTrueIfConfigurationPropertiesHasErrors() throws Exception {
    ConfigurationProperty property = new ConfigurationProperty(new ConfigurationKey("username"), new ConfigurationValue("view"));
    PluginRoleConfig roleConfig = new PluginRoleConfig("admin", "auth_id", property);
    property.addError("username", "username format is incorrect");
    assertTrue(roleConfig.hasErrors());
    assertTrue(roleConfig.errors().isEmpty());
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)71 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)71 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)65 Test (org.junit.jupiter.api.Test)49 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)29 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)13 GoCipher (com.thoughtworks.go.security.GoCipher)13 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)12 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)12 ClusterProfile (com.thoughtworks.go.config.elastic.ClusterProfile)11 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)10 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)9 ArrayList (java.util.ArrayList)9 Configuration (com.thoughtworks.go.domain.config.Configuration)8 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)8 Test (org.junit.Test)7 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)5 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)5 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)4 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)4