use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class BasicCruiseConfigTest method setup.
@BeforeEach
public void setup() throws Exception {
pipelines = new BasicPipelineConfigs("existing_group", new Authorization());
cruiseConfig = new BasicCruiseConfig(pipelines);
goConfigMother = new GoConfigMother();
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class BasicCruiseConfigTest method shouldReturnNullForAssociatedPipelineNamesWhenTemplateNameIsBlank.
@Test
public void shouldReturnNullForAssociatedPipelineNamesWhenTemplateNameIsBlank() {
ArrayList<CaseInsensitiveString> pipelinesAssociatedWithATemplate = new ArrayList<>();
pipelinesAssociatedWithATemplate.add(new CaseInsensitiveString("p1"));
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
new GoConfigMother().addPipelineWithTemplate(cruiseConfig, "p1", "t1", "s1", "j1");
assertThat(cruiseConfig.pipelinesAssociatedWithTemplate(new CaseInsensitiveString("")), is(new ArrayList<CaseInsensitiveString>()));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class BasicCruiseConfigTest method shouldEncryptSecurePluggableArtifactConfigPropertiesOfAllTemplatesInConfig.
@Test
public void shouldEncryptSecurePluggableArtifactConfigPropertiesOfAllTemplatesInConfig(ResetCipher resetCipher) throws IOException, CryptoException {
setArtifactPluginInfo();
resetCipher.setupAESCipherFile();
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.getArtifactStores().add(new ArtifactStore("store1", "cd.go.s3"));
PipelineConfig pipelineConfig = new GoConfigMother().addPipelineWithTemplate(cruiseConfig, "p1", "t1", "s1", "j1");
cruiseConfig.addPipeline("first", pipelineConfig);
PipelineTemplateConfig templateConfig = cruiseConfig.getTemplates().first();
JobConfig jobConfig = templateConfig.getStages().get(0).getJobs().get(0);
PluggableArtifactConfig artifactConfig = new PluggableArtifactConfig("foo", "store1");
artifactConfig.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"))));
jobConfig.artifactTypeConfigs().add(artifactConfig);
BasicCruiseConfig preprocessed = GoConfigMother.deepClone(cruiseConfig);
new ConfigParamPreprocessor().process(preprocessed);
cruiseConfig.encryptSecureProperties(preprocessed);
Configuration properties = ((PluggableArtifactConfig) cruiseConfig.getTemplates().get(0).getStages().get(0).getJobs().get(0).artifactTypeConfigs().get(0)).getConfiguration();
GoCipher goCipher = new GoCipher();
assertThat(properties.getProperty("k1").getEncryptedValue(), is(goCipher.encrypt("pub_v1")));
assertThat(properties.getProperty("k1").getConfigValue(), is(nullValue()));
assertThat(properties.getProperty("k1").getValue(), is("pub_v1"));
assertThat(properties.getProperty("k2").getEncryptedValue(), is(nullValue()));
assertThat(properties.getProperty("k2").getConfigValue(), is("pub_v2"));
assertThat(properties.getProperty("k2").getValue(), is("pub_v2"));
assertThat(properties.getProperty("k3").getEncryptedValue(), is(goCipher.encrypt("pub_v3")));
assertThat(properties.getProperty("k3").getConfigValue(), is(nullValue()));
assertThat(properties.getProperty("k3").getValue(), is("pub_v3"));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class BasicCruiseConfigTest method shouldReturnAListOfPipelineNamesAssociatedWithOneTemplate.
@Test
public void shouldReturnAListOfPipelineNamesAssociatedWithOneTemplate() {
ArrayList<CaseInsensitiveString> pipelinesAssociatedWithATemplate = new ArrayList<>();
pipelinesAssociatedWithATemplate.add(new CaseInsensitiveString("p1"));
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
new GoConfigMother().addPipelineWithTemplate(cruiseConfig, "p1", "t1", "s1", "j1");
assertThat(cruiseConfig.pipelinesAssociatedWithTemplate(new CaseInsensitiveString("t1")), is(pipelinesAssociatedWithATemplate));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class BasicCruiseConfigTest method shouldGetSpecificGroupsForAGroupAdminUser.
@Test
public void shouldGetSpecificGroupsForAGroupAdminUser() {
GoConfigMother goConfigMother = new GoConfigMother();
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
GoConfigMother.enableSecurityWithPasswordFilePlugin(cruiseConfig);
GoConfigMother.addUserAsSuperAdmin(cruiseConfig, "superadmin");
goConfigMother.addPipelineWithGroup(cruiseConfig, "group1", "p1", "s1", "j1");
goConfigMother.addPipelineWithGroup(cruiseConfig, "group2", "p2", "s1", "j1");
goConfigMother.addPipelineWithGroup(cruiseConfig, "group3", "p3", "s1", "j1");
goConfigMother.addAdminUserForPipelineGroup(cruiseConfig, "foo", "group1");
goConfigMother.addAdminUserForPipelineGroup(cruiseConfig, "foo", "group2");
List<String> groupsForUser = cruiseConfig.getGroupsForUser(new CaseInsensitiveString("foo"), new ArrayList<>());
assertThat(groupsForUser, not(contains("group3")));
assertThat(groupsForUser, containsInAnyOrder("group2", "group1"));
}
Aggregations