Search in sources :

Example 51 with ConfigurationValue

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

the class JobInstanceMother method jobPlanWithAssociatedEntities.

public static JobPlan jobPlanWithAssociatedEntities(String jobName, long id, List<ArtifactPlan> artifactPlans, List<ArtifactPropertiesGenerator> artifactPropertiesGenerators) {
    ConfigurationProperty configurationProperty = new ConfigurationProperty(new ConfigurationKey("image"), new ConfigurationValue("elastic-agent"));
    ElasticProfile elasticProfile = new ElasticProfile("elastic", "plugin", configurationProperty);
    EnvironmentVariables variables = new EnvironmentVariables();
    variables.add("some_var", "blah");
    return new DefaultJobPlan(new Resources(new Resource("foo"), new Resource("bar")), artifactPlans, artifactPropertiesGenerators, id, defaultJobIdentifier(jobName), null, variables, new EnvironmentVariables(), elasticProfile);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile)

Example 52 with ConfigurationValue

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

the class ScheduledPipelineLoaderIntegrationTest method shouldUpdateScmConfigurationOfPluggableScmMaterialsOnPipeline.

@Test
public void shouldUpdateScmConfigurationOfPluggableScmMaterialsOnPipeline() {
    String jobName = "job-one";
    PipelineConfig pipelineConfig = setupPipelineWithScmMaterial("pipeline_with_pluggable_scm_mat", "stage", jobName);
    final Pipeline previousSuccessfulBuildWithOlderScmConfig = simulateSuccessfulPipelineRun(pipelineConfig);
    PipelineConfig updatedPipelineConfig = configHelper.updatePipeline(pipelineConfig.name(), new GoConfigFileHelper.Updater<PipelineConfig>() {

        @Override
        public void update(PipelineConfig config) {
            PluggableSCMMaterialConfig materialConfig = (PluggableSCMMaterialConfig) config.materialConfigs().first();
            materialConfig.getSCMConfig().getConfiguration().getProperty("password").setConfigurationValue(new ConfigurationValue("new_value"));
        }
    });
    final long jobId = rerunJob(jobName, pipelineConfig, previousSuccessfulBuildWithOlderScmConfig);
    Pipeline loadedPipeline = (Pipeline) transactionTemplate.execute(new TransactionCallback() {

        public Object doInTransaction(TransactionStatus status) {
            return loader.pipelineWithPasswordAwareBuildCauseByBuildId(jobId);
        }
    });
    MaterialRevisions revisions = loadedPipeline.getBuildCause().getMaterialRevisions();
    Configuration updatedConfiguration = ((PluggableSCMMaterial) revisions.findRevisionFor(updatedPipelineConfig.materialConfigs().first()).getMaterial()).getScmConfig().getConfiguration();
    assertThat(updatedConfiguration.size(), is(2));
    assertThat(updatedConfiguration.getProperty("password").getConfigurationValue(), is(new ConfigurationValue("new_value")));
}
Also used : SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) TransactionStatus(org.springframework.transaction.TransactionStatus) Matchers.containsString(org.hamcrest.Matchers.containsString) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) TransactionCallback(org.springframework.transaction.support.TransactionCallback) GoConfigFileHelper(com.thoughtworks.go.util.GoConfigFileHelper) Test(org.junit.Test)

Example 53 with ConfigurationValue

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

the class PluggableScmServiceTest method shouldPassValidationIfAllRequiredFieldsHaveValuesForSCM.

@Test
public void shouldPassValidationIfAllRequiredFieldsHaveValuesForSCM() {
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
    configuration.getProperty("KEY1").setConfigurationValue(new ConfigurationValue("junk"));
    SCM modifiedSCM = new SCM("scm-id", new PluginConfiguration(pluginId, "1"), configuration);
    ValidationResult validationResult = new ValidationResult();
    when(scmExtension.isSCMConfigurationValid(eq(modifiedSCM.getPluginConfiguration().getId()), any(SCMPropertyConfiguration.class))).thenReturn(validationResult);
    pluggableScmService.validate(modifiedSCM);
    assertTrue(validationResult.getErrors().isEmpty());
}
Also used : ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCM(com.thoughtworks.go.domain.scm.SCM) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) Test(org.junit.Test)

Example 54 with ConfigurationValue

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

the class PluggableScmServiceTest method shouldHandleIncorrectKeyForValidateSCM.

@Test
public void shouldHandleIncorrectKeyForValidateSCM() {
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
    configuration.getProperty("KEY1").setConfigurationValue(new ConfigurationValue("junk"));
    SCM modifiedSCM = new SCM("scm-id", new PluginConfiguration(pluginId, "1"), configuration);
    ValidationResult validationResult = new ValidationResult();
    validationResult.addError(new ValidationError("NON-EXISTENT-KEY", "error message"));
    when(scmExtension.isSCMConfigurationValid(eq(modifiedSCM.getPluginConfiguration().getId()), any(SCMPropertyConfiguration.class))).thenReturn(validationResult);
    pluggableScmService.validate(modifiedSCM);
    assertTrue(modifiedSCM.errors().isEmpty());
}
Also used : ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) ValidationError(com.thoughtworks.go.plugin.api.response.validation.ValidationError) SCM(com.thoughtworks.go.domain.scm.SCM) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) Test(org.junit.Test)

Example 55 with ConfigurationValue

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

the class RoleConfigurationValidatorTest method shouldAddConfigurationAndMapErrorsInAbsenceOfConfiguration.

@Test
public void shouldAddConfigurationAndMapErrorsInAbsenceOfConfiguration() throws Exception {
    ConfigurationProperty property = new ConfigurationProperty(new ConfigurationKey("username"), new ConfigurationValue("view"));
    PluginRoleConfig roleConfig = new PluginRoleConfig("admin", "auth_id", property);
    ValidationResult result = new ValidationResult();
    result.addError(new ValidationError("password", "password is required"));
    when(extension.validateRoleConfiguration("pluginId", Collections.singletonMap("username", "view"))).thenReturn(result);
    validator.validate(roleConfig, "pluginId");
    assertTrue(roleConfig.hasErrors());
    assertThat(roleConfig.getProperty("password").errors().get("password").get(0), is("password is required"));
    assertNull(roleConfig.getProperty("password").getValue());
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) ValidationError(com.thoughtworks.go.plugin.api.response.validation.ValidationError) PluginRoleConfig(com.thoughtworks.go.config.PluginRoleConfig) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) Test(org.junit.Test)

Aggregations

ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)56 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)50 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)49 Test (org.junit.Test)47 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)28 Configuration (com.thoughtworks.go.domain.config.Configuration)20 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)14 GoCipher (com.thoughtworks.go.security.GoCipher)10 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)9 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)9 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)7 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)7 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)7 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)6 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)5 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)4 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)4 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)4 SecurityAuthConfig (com.thoughtworks.go.config.SecurityAuthConfig)3 SCM (com.thoughtworks.go.domain.scm.SCM)3