Search in sources :

Example 21 with FileConfigOrigin

use of com.thoughtworks.go.config.remote.FileConfigOrigin in project gocd by gocd.

the class PatchEnvironmentCommandTest method shouldNotAllowRemovingRemotePipeline.

@Test
public void shouldNotAllowRemovingRemotePipeline() throws Exception {
    CaseInsensitiveString pipelineName = new CaseInsensitiveString("remote-pipeline-to-remove");
    BasicEnvironmentConfig local = new BasicEnvironmentConfig(environmentName);
    local.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig remote = new BasicEnvironmentConfig(environmentName);
    remote.addPipeline(pipelineName);
    ConfigRepoConfig configRepo = new ConfigRepoConfig(new GitMaterialConfig("foo/bar.git", "master"), "myPlugin");
    remote.setOrigins(new RepoConfigOrigin(configRepo, "latest"));
    MergeEnvironmentConfig mergedConfig = new MergeEnvironmentConfig(local, remote);
    pipelinesToRemove.add(pipelineName.toString());
    PatchEnvironmentCommand command = new PatchEnvironmentCommand(goConfigService, environmentConfig, pipelinesToAdd, pipelinesToRemove, agentsToAdd, agentsToRemove, envVarsToAdd, envVarsToRemove, currentUser, actionFailed, result);
    assertFalse(cruiseConfig.getEnvironments().find(environmentName).containsPipeline(new CaseInsensitiveString(pipelineName.toString())));
    command.update(cruiseConfig);
    // preprocess
    cruiseConfig.getEnvironments().replace(cruiseConfig.getEnvironments().find(environmentName), mergedConfig);
    boolean isValid = command.isValid(cruiseConfig);
    assertFalse(isValid);
    HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
    String message = "Pipeline 'remote-pipeline-to-remove' cannot be removed from environment 'Dev' as the association has been defined remotely in [foo/bar.git at latest]";
    expectedResult.unprocessableEntity(actionFailed.addParam(message));
    assertThat(result, is(expectedResult));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) MergeEnvironmentConfig(com.thoughtworks.go.config.merge.MergeEnvironmentConfig) Test(org.junit.Test)

Example 22 with FileConfigOrigin

use of com.thoughtworks.go.config.remote.FileConfigOrigin in project gocd by gocd.

the class PatchEnvironmentCommandTest method shouldNotAllowRemovingRemoteEnvironmentVariables.

@Test
public void shouldNotAllowRemovingRemoteEnvironmentVariables() throws Exception {
    String variableName = "remote-env-var-to-remove";
    BasicEnvironmentConfig local = new BasicEnvironmentConfig(environmentName);
    local.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig remote = new BasicEnvironmentConfig(environmentName);
    remote.addEnvironmentVariable(variableName, "bar");
    ConfigRepoConfig configRepo = new ConfigRepoConfig(new GitMaterialConfig("foo/bar.git", "master"), "myPlugin");
    remote.setOrigins(new RepoConfigOrigin(configRepo, "latest"));
    MergeEnvironmentConfig mergedConfig = new MergeEnvironmentConfig(local, remote);
    envVarsToRemove.add(variableName);
    PatchEnvironmentCommand command = new PatchEnvironmentCommand(goConfigService, environmentConfig, pipelinesToAdd, pipelinesToRemove, agentsToAdd, agentsToRemove, envVarsToAdd, envVarsToRemove, currentUser, actionFailed, result);
    assertFalse(cruiseConfig.getEnvironments().find(environmentName).getVariables().hasVariable(variableName));
    command.update(cruiseConfig);
    // preprocess
    cruiseConfig.getEnvironments().replace(cruiseConfig.getEnvironments().find(environmentName), mergedConfig);
    boolean isValid = command.isValid(cruiseConfig);
    assertFalse(isValid);
    HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
    String message = "Environment variable with name 'remote-env-var-to-remove' cannot be removed from environment 'Dev' as the association has been defined remotely in [foo/bar.git at latest]";
    expectedResult.unprocessableEntity(actionFailed.addParam(message));
    assertThat(result, is(expectedResult));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) MergeEnvironmentConfig(com.thoughtworks.go.config.merge.MergeEnvironmentConfig) Test(org.junit.Test)

Example 23 with FileConfigOrigin

use of com.thoughtworks.go.config.remote.FileConfigOrigin in project gocd by gocd.

the class PatchEnvironmentCommandTest method shouldNotAllowRemovingRemoteAgents.

@Test
public void shouldNotAllowRemovingRemoteAgents() throws Exception {
    String agentUUID = "remote-agent-to-remove";
    BasicEnvironmentConfig local = new BasicEnvironmentConfig(environmentName);
    local.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig remote = new BasicEnvironmentConfig(environmentName);
    remote.addAgent(agentUUID);
    ConfigRepoConfig configRepo = new ConfigRepoConfig(new GitMaterialConfig("foo/bar.git", "master"), "myPlugin");
    remote.setOrigins(new RepoConfigOrigin(configRepo, "latest"));
    MergeEnvironmentConfig mergedConfig = new MergeEnvironmentConfig(local, remote);
    agentsToRemove.add(agentUUID);
    PatchEnvironmentCommand command = new PatchEnvironmentCommand(goConfigService, environmentConfig, pipelinesToAdd, pipelinesToRemove, agentsToAdd, agentsToRemove, envVarsToAdd, envVarsToRemove, currentUser, actionFailed, result);
    assertFalse(cruiseConfig.getEnvironments().find(environmentName).containsPipeline(new CaseInsensitiveString(agentUUID)));
    command.update(cruiseConfig);
    // preprocess
    cruiseConfig.getEnvironments().replace(cruiseConfig.getEnvironments().find(environmentName), mergedConfig);
    boolean isValid = command.isValid(cruiseConfig);
    assertFalse(isValid);
    HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
    String message = "Agent with uuid 'remote-agent-to-remove' cannot be removed from environment 'Dev' as the association has been defined remotely in [foo/bar.git at latest]";
    expectedResult.unprocessableEntity(actionFailed.addParam(message));
    assertThat(result, is(expectedResult));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) MergeEnvironmentConfig(com.thoughtworks.go.config.merge.MergeEnvironmentConfig) Test(org.junit.Test)

Example 24 with FileConfigOrigin

use of com.thoughtworks.go.config.remote.FileConfigOrigin in project gocd by gocd.

the class FetchPluggableArtifactTaskTest method validate_shouldErrorWhenReferencingConfigRepositoryPipelineFromFilePipeline.

@Test
public void validate_shouldErrorWhenReferencingConfigRepositoryPipelineFromFilePipeline() {
    uppestStream.setOrigin(new RepoConfigOrigin());
    downstream.setOrigin(new FileConfigOrigin());
    FetchPluggableArtifactTask task = new FetchPluggableArtifactTask(new CaseInsensitiveString("uppest_stream/upstream"), new CaseInsensitiveString("uppest-stage2"), new CaseInsensitiveString("uppest-job2"), "s3");
    StageConfig stage = downstream.getStage(new CaseInsensitiveString("stage"));
    task.validate(ConfigSaveValidationContext.forChain(config, new BasicPipelineConfigs(), downstream, stage, stage.getJobs().first()));
    assertThat(task.errors().isEmpty(), is(false));
    assertThat(task.errors().on(FetchTask.ORIGIN), startsWith("\"downstream :: stage :: job\" tries to fetch artifact from job \"uppest_stream :: uppest-stage2 :: uppest-job2\" which is defined in"));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.Test)

Example 25 with FileConfigOrigin

use of com.thoughtworks.go.config.remote.FileConfigOrigin in project gocd by gocd.

the class FetchTaskTest method validate_shouldNotErrorWhenReferencingFilePipelineFromFilePipeline.

@Test
public void validate_shouldNotErrorWhenReferencingFilePipelineFromFilePipeline() {
    uppestStream.setOrigin(new FileConfigOrigin());
    downstream.setOrigin(new FileConfigOrigin());
    FetchTask task = new FetchTask(new CaseInsensitiveString("uppest_stream/upstream"), new CaseInsensitiveString("uppest-stage2"), new CaseInsensitiveString("uppest-job2"), "src", "dest");
    task.validate(ConfigSaveValidationContext.forChain(config, new BasicPipelineConfigs(), downstream, downstream.getStage(new CaseInsensitiveString("stage"))));
    assertThat(task.errors().isEmpty(), is(true));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) Test(org.junit.Test)

Aggregations

FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)59 Test (org.junit.Test)51 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)23 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)5 MergeEnvironmentConfig (com.thoughtworks.go.config.merge.MergeEnvironmentConfig)4 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)4 Permissions (com.thoughtworks.go.config.security.Permissions)4 AllowedUsers (com.thoughtworks.go.config.security.users.AllowedUsers)4 BasicPipelineConfigs (com.thoughtworks.go.config.BasicPipelineConfigs)3 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)3 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)3 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)3 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)3 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)3 MergePipelineConfigs (com.thoughtworks.go.config.merge.MergePipelineConfigs)2 BasicEnvironmentConfig (com.thoughtworks.go.config.BasicEnvironmentConfig)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)1 MergeConfigOrigin (com.thoughtworks.go.config.merge.MergeConfigOrigin)1