use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class JobInstanceSqlMapDaoIntegrationTest method shouldSaveJobAgentMetadata_WhenClusterProfileIsAssociatedWithElasticAgentProfile.
@Test
public void shouldSaveJobAgentMetadata_WhenClusterProfileIsAssociatedWithElasticAgentProfile() {
JobInstance instance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME));
instance.setIdentifier(new JobIdentifier(savedPipeline, savedStage, instance));
ElasticProfile elasticProfile = new ElasticProfile("foo", "clusterId", Arrays.asList(new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value"))));
ClusterProfile clusterProfile = new ClusterProfile("clusterId", "cd.go.elastic-agent:docker", Arrays.asList(new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value"))));
JobPlan plan = new DefaultJobPlan(new Resources("something"), new ArrayList<>(), instance.getId(), instance.getIdentifier(), null, new EnvironmentVariables(), new EnvironmentVariables(), elasticProfile, clusterProfile);
jobInstanceDao.save(instance.getId(), plan);
JobPlan retrieved = jobInstanceDao.loadPlan(plan.getJobId());
assertThat(retrieved.getElasticProfile(), is(elasticProfile));
assertThat(retrieved.getClusterProfile(), is(clusterProfile));
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class CruiseConfigTestBase method shouldAddPackageDefinitionToGivenRepository.
@Test
public void shouldAddPackageDefinitionToGivenRepository() throws Exception {
String repoId = "repo-id";
PackageRepository packageRepository = PackageRepositoryMother.create(repoId, "repo-name", "plugin-id", "1.0", new Configuration());
PackageDefinition existing = PackageDefinitionMother.create("pkg-1", "pkg1-name", new Configuration(), packageRepository);
packageRepository.setPackages(new Packages(existing));
cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository));
Configuration configuration = new Configuration();
configuration.add(new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value")));
configuration.add(new ConfigurationProperty(new ConfigurationKey("key-with-no-value"), new ConfigurationValue("")));
PackageDefinition packageDefinition = PackageDefinitionMother.create(null, "pkg2-name", configuration, packageRepository);
cruiseConfig.savePackageDefinition(packageDefinition);
assertThat(cruiseConfig.getPackageRepositories().size(), is(1));
assertThat(cruiseConfig.getPackageRepositories().get(0).getId(), is(repoId));
assertThat(cruiseConfig.getPackageRepositories().get(0).getPackages().size(), is(2));
assertThat(cruiseConfig.getPackageRepositories().get(0).getPackages().get(0).getId(), is(existing.getId()));
PackageDefinition createdPkgDef = cruiseConfig.getPackageRepositories().get(0).getPackages().get(1);
assertThat(createdPkgDef.getId(), is(notNullValue()));
assertThat(createdPkgDef.getConfiguration().getProperty("key"), is(Matchers.notNullValue()));
assertThat(createdPkgDef.getConfiguration().getProperty("key-with-no-value"), is(nullValue()));
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class FetchPluggableArtifactTaskTest method shouldSetConfiguration_whenPluginIsProvided.
@Test
void shouldSetConfiguration_whenPluginIsProvided() {
final HashMap<Object, Object> configAttrs = new HashMap<>();
configAttrs.put(FetchPluggableArtifactTask.ARTIFACT_ID, "installers");
configAttrs.put(FetchPluggableArtifactTask.CONFIGURATION, Collections.singletonMap("NAME", "gocd.zip"));
configAttrs.put("pluginId", "cd.go.artifact.s3");
FetchPluggableArtifactTask task = new FetchPluggableArtifactTask(new CaseInsensitiveString("#{pipeline}"), new CaseInsensitiveString("#{stage}"), new CaseInsensitiveString("#{job}"), "#{artifactId}");
task.setFetchTaskAttributes(configAttrs);
Assertions.assertThat(task.getArtifactId()).isEqualTo("installers");
Assertions.assertThat(task.getConfiguration()).hasSize(1).contains(new ConfigurationProperty(new ConfigurationKey("NAME"), new ConfigurationValue("gocd.zip")));
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class FetchPluggableArtifactTaskTest method shouldSetConfiguration_whenPluginIsNotProvided.
@Test
void shouldSetConfiguration_whenPluginIsNotProvided() throws CryptoException {
final HashMap<Object, Object> configAttrs = new HashMap<>();
configAttrs.put(FetchPluggableArtifactTask.ARTIFACT_ID, "installers");
configAttrs.put(FetchPluggableArtifactTask.CONFIGURATION, Collections.singletonMap("NAME", new HashMap<String, String>() {
{
put("value", new GoCipher().encrypt("gocd.zip"));
put("isSecure", "true");
}
}));
FetchPluggableArtifactTask task = new FetchPluggableArtifactTask(new CaseInsensitiveString("#{pipeline}"), new CaseInsensitiveString("#{stage}"), new CaseInsensitiveString("#{job}"), "#{artifactId}");
task.setFetchTaskAttributes(configAttrs);
Assertions.assertThat(task.getArtifactId()).isEqualTo("installers");
Assertions.assertThat(task.getConfiguration()).hasSize(1).contains(new ConfigurationProperty(new ConfigurationKey("NAME"), new EncryptedConfigurationValue(new GoCipher().encrypt("gocd.zip"))));
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class PluginSettingsTest method shouldValidateThatEncryptedVariablesAreEncryptedWithTheCorrectCipher.
@Test
public void shouldValidateThatEncryptedVariablesAreEncryptedWithTheCorrectCipher() {
final PluginInfo pluginInfo = mock(PluginInfo.class);
String secureKey = "supposedly-secure-key";
when(pluginInfo.isSecure(secureKey)).thenReturn(true);
PluginSettings pluginSettings = new PluginSettings(PLUGIN_ID);
pluginSettings.addConfigurations(pluginInfo, Arrays.asList(new ConfigurationProperty(new ConfigurationKey(secureKey), new EncryptedConfigurationValue("value_encrypted_by_a_different_cipher"))));
pluginSettings.validateTree();
assertThat(pluginSettings.hasErrors(), is(true));
assertThat(pluginSettings.getPluginSettingsProperties().get(0).errors().firstError(), is("Encrypted value for property with key 'supposedly-secure-key' is invalid. This usually happens when the cipher text is modified to have an invalid value."));
}
Aggregations