Search in sources :

Example 76 with GoConfigMother

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();
}
Also used : GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 77 with 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>()));
}
Also used : ArrayList(java.util.ArrayList) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Test(org.junit.jupiter.api.Test)

Example 78 with GoConfigMother

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"));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) GoCipher(com.thoughtworks.go.security.GoCipher) ConfigParamPreprocessor(com.thoughtworks.go.config.preprocessor.ConfigParamPreprocessor) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Test(org.junit.jupiter.api.Test)

Example 79 with GoConfigMother

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));
}
Also used : ArrayList(java.util.ArrayList) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Test(org.junit.jupiter.api.Test)

Example 80 with GoConfigMother

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"));
}
Also used : GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Test(org.junit.jupiter.api.Test)

Aggregations

GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)102 Test (org.junit.jupiter.api.Test)64 Username (com.thoughtworks.go.server.domain.Username)30 BeforeEach (org.junit.jupiter.api.BeforeEach)19 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)15 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)13 GoConfigValidity (com.thoughtworks.go.config.validation.GoConfigValidity)12 File (java.io.File)9 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)8 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 SCM (com.thoughtworks.go.domain.scm.SCM)4 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)3 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)3 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)3 FullConfigUpdateCommand (com.thoughtworks.go.config.update.FullConfigUpdateCommand)3 Configuration (com.thoughtworks.go.domain.config.Configuration)3 PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)3