use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class GoFileConfigDataSourceTest method setup.
@Before
public void setup() throws Exception {
systemEnvironment = new SystemEnvironment();
systemEnvironment.setProperty(SystemEnvironment.OPTIMIZE_FULL_CONFIG_SAVE.propertyName(), "false");
configHelper = new GoConfigFileHelper();
configHelper.onSetUp();
configRepository = new ConfigRepository(systemEnvironment);
configRepository.initialize();
timeProvider = mock(TimeProvider.class);
fullConfigSaveMergeFlow = mock(FullConfigSaveMergeFlow.class);
fullConfigSaveNormalFlow = mock(FullConfigSaveNormalFlow.class);
when(timeProvider.currentTime()).thenReturn(new Date());
ServerVersion serverVersion = new ServerVersion();
ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
ServerHealthService serverHealthService = new ServerHealthService();
cachedGoPartials = new CachedGoPartials(serverHealthService);
dataSource = new GoFileConfigDataSource(new GoConfigMigration(new GoConfigMigration.UpgradeFailedHandler() {
public void handle(Exception e) {
throw new RuntimeException(e);
}
}, configRepository, new TimeProvider(), configCache, registry), configRepository, systemEnvironment, timeProvider, configCache, serverVersion, registry, mock(ServerHealthService.class), cachedGoPartials, fullConfigSaveMergeFlow, fullConfigSaveNormalFlow);
dataSource.upgradeIfNecessary();
CachedGoConfig cachedGoConfig = new CachedGoConfig(serverHealthService, dataSource, mock(CachedGoPartials.class), null, null);
cachedGoConfig.loadConfigIfNull();
goConfigDao = new GoConfigDao(cachedGoConfig);
configHelper.load();
configHelper.usingCruiseConfigDao(goConfigDao);
GoConfigWatchList configWatchList = new GoConfigWatchList(cachedGoConfig, mock(GoConfigService.class));
ConfigElementImplementationRegistry configElementImplementationRegistry = new ConfigElementImplementationRegistry(new NoPluginsInstalled());
GoConfigPluginService configPluginService = new GoConfigPluginService(mock(ConfigRepoExtension.class), new ConfigCache(), configElementImplementationRegistry, cachedGoConfig);
repoConfig = new ConfigRepoConfig(new GitMaterialConfig("url"), "plugin");
configHelper.addConfigRepo(repoConfig);
SecurityContext context = SecurityContextHolder.getContext();
context.setAuthentication(new UsernamePasswordAuthenticationToken(new User("loser_boozer", "pass", true, true, true, true, new GrantedAuthority[] {}), null));
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class CreateConfigRepoCommandTest method shouldValidateDuplicateRepoId.
@Test
public void shouldValidateDuplicateRepoId() throws Exception {
ConfigRepoConfig anotherconfigRepo = new ConfigRepoConfig(new GitMaterialConfig("https://foos.git", "master"), "json-plugin", repoId);
cruiseConfig.getConfigRepos().add(anotherconfigRepo);
String error = "You have defined multiple configuration repositories with the same id - repo-1";
HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
expectedResult.unprocessableEntity(actionFailed.addParam(Arrays.asList(error)));
CreateConfigRepoCommand command = new CreateConfigRepoCommand(securityService, configRepo, actionFailed, currentUser, result);
command.update(cruiseConfig);
assertFalse(command.isValid(cruiseConfig));
assertThat(configRepo.errors().firstError(), is(error));
assertThat(result, is(expectedResult));
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class CreateConfigRepoCommandTest method shouldValidateDuplicateMaterial.
@Test
public void shouldValidateDuplicateMaterial() throws Exception {
ConfigRepoConfig anotherConfigRepo = new ConfigRepoConfig(new GitMaterialConfig("https://foo.git", "master"), "json-plugin", "anotherid");
cruiseConfig.getConfigRepos().add(anotherConfigRepo);
String error = "You have defined multiple configuration repositories with the same repository - https://foo.git";
HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
expectedResult.unprocessableEntity(actionFailed.addParam(Arrays.asList(error)));
CreateConfigRepoCommand command = new CreateConfigRepoCommand(securityService, configRepo, actionFailed, currentUser, result);
command.update(cruiseConfig);
assertFalse(command.isValid(cruiseConfig));
assertThat(configRepo.errors().size(), is(1));
assertThat(configRepo.errors().firstError(), is(error));
assertThat(result, is(expectedResult));
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class PipelineConfigTest method shouldReturnFalseWhenConfigRevisionIsNotEqualToQuery.
@Test
public void shouldReturnFalseWhenConfigRevisionIsNotEqualToQuery() {
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("pipeline", "stage", "build");
MaterialConfig material = pipelineConfig.materialConfigs().first();
pipelineConfig.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(material, "plugin"), "1233"));
assertThat(pipelineConfig.isConfigOriginFromRevision("32"), is(false));
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class PipelineConfigTest method shouldReturnTrueWhenConfigRevisionIsEqualToQuery.
@Test
public void shouldReturnTrueWhenConfigRevisionIsEqualToQuery() {
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("pipeline", "stage", "build");
MaterialConfig material = pipelineConfig.materialConfigs().first();
pipelineConfig.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(material, "plugin"), "1233"));
assertThat(pipelineConfig.isConfigOriginFromRevision("1233"), is(true));
}
Aggregations