use of com.thoughtworks.go.config.rules.Allow in project gocd by gocd.
the class PartialConfigServiceIntegrationTest method createConfigRepoWithDefaultRules.
private ConfigRepoConfig createConfigRepoWithDefaultRules(GitMaterialConfig materialConfig, String plugin, String id) {
ConfigRepoConfig config = ConfigRepoConfig.createConfigRepoConfig(materialConfig, plugin, id);
config.getRules().add(new Allow("refer", "*", "*"));
return config;
}
use of com.thoughtworks.go.config.rules.Allow in project gocd by gocd.
the class GoConfigRepoConfigDataSourceIntegrationTest method setUp.
@BeforeEach
public void setUp(@TempDir File templateConfigRepo) throws Exception {
GoConfigFileHelper configHelper = new GoConfigFileHelper(DEFAULT_XML_WITH_2_AGENTS);
configHelper.usingCruiseConfigDao(goConfigDao);
configHelper.onSetUp();
GoConfigRepoConfigDataSource repoConfigDataSource = new GoConfigRepoConfigDataSource(configWatchList, configPluginService, serverHealthService, configRepoService, goConfigService);
repoConfigDataSource.registerListener(new PartialConfigService(repoConfigDataSource, configWatchList, goConfigService, cachedGoPartials, serverHealthService, partials));
configHelper.addTemplate("t1", "param1", "stage");
String latestRevision = setupExternalConfigRepo(templateConfigRepo, "external_git_config_repo_referencing_template_with_params");
ConfigRepoConfig configRepoConfig = ConfigRepoConfig.createConfigRepoConfig(git(templateConfigRepo.getAbsolutePath()), "gocd-xml", "config-id");
configRepoConfig.getRules().add(new Allow("refer", "*", "*"));
configHelper.addConfigRepo(configRepoConfig);
goConfigService.forceNotifyListeners();
Modification modification = new Modification();
modification.setRevision(latestRevision);
repoConfigDataSource.onCheckoutComplete(configRepoConfig.getRepo(), templateConfigRepo, modification);
}
use of com.thoughtworks.go.config.rules.Allow in project gocd by gocd.
the class PartialConfigUpdateCommandTest method update.
@Test
void update() {
configRepoConfig.getRules().add(new Allow("refer", "*", "*"));
BasicPipelineConfigs group = new BasicPipelineConfigs("first", new Authorization());
group.setOrigin(new RepoConfigOrigin());
group.add(PipelineConfigMother.pipelineConfig("up42"));
partial.setPipelines(new PipelineGroups(group));
partial.setOrigins(new RepoConfigOrigin(configRepoConfig, "123"));
partial.validatePermissionsOnSubtree();
assertFalse(partial.hasErrors());
PartialConfigUpdateCommand command = new PartialConfigUpdateCommand(partial, fingerprint, resolver);
CruiseConfig updated = command.update(cruiseConfig);
assertTrue(updated.hasPipelineGroup("first"));
assertEquals(1, updated.getPartials().size());
}
use of com.thoughtworks.go.config.rules.Allow in project gocd by gocd.
the class PartialConfigTest method validatePermissionsOnSubtreeFailsWhenNoRuleMatchesUpstreamDependency.
@Test
void validatePermissionsOnSubtreeFailsWhenNoRuleMatchesUpstreamDependency() {
configRepo.getRules().add(new Allow("refer", "pipeline_group", "*"));
configRepo.getRules().add(new Allow("refer", "pipeline", "build"));
BasicPipelineConfigs group = new BasicPipelineConfigs("first", new Authorization());
group.add(PipelineConfigMother.pipelineConfig("up42", new MaterialConfigs(dependencyMaterialConfig("build", "stage"), dependencyMaterialConfig("deploy", "stage"))));
partial.setPipelines(new PipelineGroups(group));
partial.setOrigins(partial.getOrigin());
partial.validatePermissionsOnSubtree();
assertTrue(partial.hasErrors());
assertEquals(1, partial.errors().size());
assertEquals("Not allowed to refer to pipeline 'deploy'. Check the 'Rules' of this config repository.", partial.errors().on("pipeline"));
}
use of com.thoughtworks.go.config.rules.Allow in project gocd by gocd.
the class PartialConfigTest method shouldAllowToDefineUpstreamDependencyFromTheSameConfigRepositoryRegardlessOfRules.
@Test
void shouldAllowToDefineUpstreamDependencyFromTheSameConfigRepositoryRegardlessOfRules() {
configRepo.getRules().add(new Allow("refer", "pipeline_group", "*"));
configRepo.getRules().add(new Allow("refer", "pipeline", "build"));
BasicPipelineConfigs group = new BasicPipelineConfigs("first", new Authorization());
group.add(PipelineConfigMother.pipelineConfig("upstream", new MaterialConfigs(dependencyMaterialConfig("build", "stage"))));
group.add(PipelineConfigMother.pipelineConfig("downstream", new MaterialConfigs(dependencyMaterialConfig("upstream", "stage"))));
partial.setPipelines(new PipelineGroups(group));
partial.setOrigins(partial.getOrigin());
partial.validatePermissionsOnSubtree();
assertFalse(partial.hasErrors());
}
Aggregations