use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class JobInstanceSqlMapDaoTest method shouldSaveJobAgentMetadata.
@Test
public void shouldSaveJobAgentMetadata() throws Exception {
JobInstance instance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME));
instance.setIdentifier(new JobIdentifier(savedPipeline, savedStage, instance));
ElasticProfile elasticProfile = new ElasticProfile("foo", "cd.go.elastic-agent:docker", Arrays.asList(new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value"))));
JobPlan plan = new DefaultJobPlan(new Resources("something"), new ArtifactPlans(), new ArtifactPropertiesGenerators(), instance.getId(), instance.getIdentifier(), null, new EnvironmentVariablesConfig(), new EnvironmentVariablesConfig(), elasticProfile);
jobInstanceDao.save(instance.getId(), plan);
JobPlan retrieved = jobInstanceDao.loadPlan(plan.getJobId());
assertThat(retrieved.getElasticProfile(), is(elasticProfile));
}
use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class ScheduledPipelineLoaderIntegrationTest method shouldUpdatePackageMaterialConfigurationOfMaterialsOnPipeline.
@Test
public void shouldUpdatePackageMaterialConfigurationOfMaterialsOnPipeline() throws Exception {
String jobName = "job-one";
PipelineConfig pipelineConfig = setupPipelineWithPackageMaterial("pipeline_with_pluggable_scm_mat", "stage", jobName);
final Pipeline previousSuccessfulBuildWithOlderPackageConfig = simulateSuccessfulPipelineRun(pipelineConfig);
PipelineConfig updatedPipelineConfig = configHelper.updatePipeline(pipelineConfig.name(), new GoConfigFileHelper.Updater<PipelineConfig>() {
@Override
public void update(PipelineConfig config) {
PackageMaterialConfig materialConfig = (PackageMaterialConfig) config.materialConfigs().first();
materialConfig.getPackageDefinition().getConfiguration().getProperty("package-key2").setConfigurationValue(new ConfigurationValue("package-updated-value"));
materialConfig.getPackageDefinition().getRepository().getConfiguration().getProperty("repo-key2").setConfigurationValue(new ConfigurationValue("repo-updated-value"));
}
});
final long jobId = rerunJob(jobName, pipelineConfig, previousSuccessfulBuildWithOlderPackageConfig);
Pipeline loadedPipeline = (Pipeline) transactionTemplate.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus status) {
return loader.pipelineWithPasswordAwareBuildCauseByBuildId(jobId);
}
});
MaterialRevisions revisions = loadedPipeline.getBuildCause().getMaterialRevisions();
PackageMaterial updatedMaterial = (PackageMaterial) revisions.findRevisionFor(updatedPipelineConfig.materialConfigs().first()).getMaterial();
Configuration updatedConfiguration = updatedMaterial.getPackageDefinition().getConfiguration();
assertThat(updatedConfiguration.size(), is(2));
assertThat(updatedConfiguration.getProperty("package-key2").getConfigurationValue(), is(new ConfigurationValue("package-updated-value")));
assertThat(updatedMaterial.getPackageDefinition().getRepository().getConfiguration().size(), is(2));
assertThat(updatedMaterial.getPackageDefinition().getRepository().getConfiguration().getProperty("repo-key2").getConfigurationValue(), is(new ConfigurationValue("repo-updated-value")));
}
use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class PackageDefinitionTest method shouldNotAddFingerprintFieldErrorWhenPackageDefinitionWithSameFingerprintNotFound.
@Test
public void shouldNotAddFingerprintFieldErrorWhenPackageDefinitionWithSameFingerprintNotFound() throws Exception {
PackageRepository repository = PackageRepositoryMother.create("repo1");
PackageDefinition packageDefinition = PackageDefinitionMother.create("1", "pkg1", new Configuration(new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("v1"))), repository);
HashMap<String, Packages> map = new HashMap<>();
map.put(packageDefinition.getFingerprint(AbstractMaterialConfig.FINGERPRINT_DELIMITER), new Packages(packageDefinition));
packageDefinition.validateFingerprintUniqueness(map);
assertThat(packageDefinition.errors().getAllOn(PackageDefinition.ID), is(nullValue()));
}
use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class PackageDefinitionTest method shouldMakeConfigurationSecureBasedOnMetadata.
@Test
public void shouldMakeConfigurationSecureBasedOnMetadata() throws Exception {
/*secure property is set based on metadata*/
ConfigurationProperty secureProperty = new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1"), null, new GoCipher());
ConfigurationProperty nonSecureProperty = new ConfigurationProperty(new ConfigurationKey("key2"), new ConfigurationValue("value2"), null, new GoCipher());
PackageDefinition packageDefinition = new PackageDefinition("go", "name", new Configuration(secureProperty, nonSecureProperty));
PackageRepository packageRepository = new PackageRepository();
packageRepository.setPluginConfiguration(new PluginConfiguration("plugin-id", "1.0"));
packageDefinition.setRepository(packageRepository);
PackageConfigurations packageConfigurations = new PackageConfigurations();
packageConfigurations.addConfiguration(new PackageConfiguration("key1").with(PackageConfiguration.SECURE, true));
packageConfigurations.addConfiguration(new PackageConfiguration("key2").with(PackageConfiguration.SECURE, false));
PackageMetadataStore.getInstance().addMetadataFor("plugin-id", packageConfigurations);
packageDefinition.applyPackagePluginMetadata("plugin-id");
assertThat(secureProperty.isSecure(), is(true));
assertThat(nonSecureProperty.isSecure(), is(false));
}
use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class PackageDefinitionTest method shouldClearConfigurationsWhichAreEmptyAndNoErrors.
@Test
public void shouldClearConfigurationsWhichAreEmptyAndNoErrors() throws Exception {
PackageDefinition packageDefinition = new PackageDefinition();
packageDefinition.getConfiguration().add(new ConfigurationProperty(new ConfigurationKey("name-one"), new ConfigurationValue()));
packageDefinition.getConfiguration().add(new ConfigurationProperty(new ConfigurationKey("name-two"), new EncryptedConfigurationValue()));
packageDefinition.getConfiguration().add(new ConfigurationProperty(new ConfigurationKey("name-three"), null, new EncryptedConfigurationValue(), null));
ConfigurationProperty configurationProperty = new ConfigurationProperty(new ConfigurationKey("name-four"), null, new EncryptedConfigurationValue(), null);
configurationProperty.addErrorAgainstConfigurationValue("error");
packageDefinition.getConfiguration().add(configurationProperty);
packageDefinition.clearEmptyConfigurations();
assertThat(packageDefinition.getConfiguration().size(), is(1));
assertThat(packageDefinition.getConfiguration().get(0).getConfigurationKey().getName(), is("name-four"));
}
Aggregations