use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.
the class PipelineConfigsTestBase method shouldNotErrorWhenNoAuthorizationIsDefined_AndInConfigRepo.
@Test
public void shouldNotErrorWhenNoAuthorizationIsDefined_AndInConfigRepo() {
BasicPipelineConfigs group = new BasicPipelineConfigs(new RepoConfigOrigin());
group.setGroup("gr");
group.validate(null);
assertThat(group.errors().isEmpty(), is(true));
}
use of com.thoughtworks.go.config.remote.RepoConfigOrigin 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));
}
use of com.thoughtworks.go.config.remote.RepoConfigOrigin 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));
}
use of com.thoughtworks.go.config.remote.RepoConfigOrigin 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));
}
use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.
the class GoFileConfigDataSourceTest method shouldNotRetryConfigUpdateIfLastKnownAndValidPartialsAreSame_OnWriteFullConfigWithLock.
@Test(expected = RuntimeException.class)
public void shouldNotRetryConfigUpdateIfLastKnownAndValidPartialsAreSame_OnWriteFullConfigWithLock() throws Exception {
PartialConfig partialConfig1 = PartialConfigMother.withPipeline("p1", new RepoConfigOrigin(new ConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig(), "plugin"), "git_r1"));
List<PartialConfig> known = asList(partialConfig1);
List<PartialConfig> valid = asList(partialConfig1);
BasicCruiseConfig configForEdit = new BasicCruiseConfig();
MagicalGoConfigXmlLoader.setMd5(configForEdit, "md5");
FullConfigUpdateCommand updatingCommand = new FullConfigUpdateCommand(new BasicCruiseConfig(), "md5");
GoConfigHolder configHolder = new GoConfigHolder(new BasicCruiseConfig(), configForEdit);
CachedGoPartials cachedGoPartials = mock(CachedGoPartials.class);
GoFileConfigDataSource source = new GoFileConfigDataSource(null, null, systemEnvironment, null, null, null, null, null, cachedGoPartials, fullConfigSaveMergeFlow, fullConfigSaveNormalFlow);
stub(cachedGoPartials.lastKnownPartials()).toReturn(known);
stub(cachedGoPartials.lastValidPartials()).toReturn(valid);
when(fullConfigSaveNormalFlow.execute(updatingCommand, known, "loser_boozer")).thenThrow(new GoConfigInvalidException(configForEdit, "error"));
source.writeFullConfigWithLock(updatingCommand, configHolder);
}
Aggregations