use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class PipelineConfigValidationTest method setup.
@Before
public void setup() {
config = GoConfigMother.configWithPipelines("pipeline1", "pipeline2", "pipeline3", "go");
pipeline = config.pipelineConfigByName(new CaseInsensitiveString("go"));
goConfigMother = new GoConfigMother();
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class ConfigMaterialUpdaterIntegrationTest method shouldCheckoutChangedInExistingMaterial.
@Test
public void shouldCheckoutChangedInExistingMaterial() throws Exception {
GoConfigMother mother = new GoConfigMother();
PipelineConfig pipelineConfig = mother.cruiseConfigWithOnePipelineGroup().getAllPipelineConfigs().get(0);
configTestRepo.addPipelineToRepositoryAndPush("pipe1.gocd.xml", pipelineConfig);
materialUpdateService.updateMaterial(material);
// time for messages to pass through all services
waitForMaterialNotInProgress();
configTestRepo.addPipelineToRepositoryAndPush("pipe2.gocd.xml", pipelineConfig);
materialUpdateService.updateMaterial(material);
// time for messages to pass through all services
waitForMaterialNotInProgress();
File flyweightDir = materialRepository.folderFor(material);
Assert.assertThat(flyweightDir.exists(), is(true));
Assert.assertThat(new File(flyweightDir, "pipe1.gocd.xml").exists(), is(true));
Assert.assertThat("shouldContainFilesAddedLater", new File(flyweightDir, "pipe2.gocd.xml").exists(), is(true));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class TemplateConfigServiceTest method shouldReturnASubsetOfTemplatesWithAssociatedPipelinesForGroupAdmin.
@Test
public void shouldReturnASubsetOfTemplatesWithAssociatedPipelinesForGroupAdmin() {
BasicCruiseConfig cruiseConfig = getCruiseConfigWithSecurityEnabled();
CaseInsensitiveString groupAdmin = new CaseInsensitiveString("group-admin");
new GoConfigMother().addPipelineWithTemplate(cruiseConfig, "p1", "t1", "s1", "j1");
// defaultGroup is set in GoConfigMother
PipelineConfigs pipelineConfigs = cruiseConfig.findGroup("defaultGroup");
pipelineConfigs.setAuthorization(new Authorization(new AdminsConfig(new AdminUser(groupAdmin))));
Username groupAdminUser = new Username(groupAdmin);
when(goConfigService.getCurrentConfig()).thenReturn(cruiseConfig);
when(goConfigService.isPipelineEditable(new CaseInsensitiveString("p1"))).thenReturn(true);
when(securityService.isAuthorizedToViewTemplate(new CaseInsensitiveString("t1"), groupAdminUser)).thenReturn(true);
List<TemplateToPipelines> templateToPipelines = new ArrayList<>();
TemplateToPipelines t1 = new TemplateToPipelines(new CaseInsensitiveString("t1"), false, false);
t1.add(new PipelineEditabilityInfo(new CaseInsensitiveString("p1"), true, true));
templateToPipelines.add(t1);
assertThat(service.getTemplatesList(groupAdminUser), is(templateToPipelines));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class TemplateConfigServiceTest method shouldReturnASubsetOfTemplatesToPipelinesMapForTemplateAdmin.
@Test
public void shouldReturnASubsetOfTemplatesToPipelinesMapForTemplateAdmin() {
BasicCruiseConfig cruiseConfig = getCruiseConfigWithSecurityEnabled();
CaseInsensitiveString templateAdmin = new CaseInsensitiveString("template-admin");
new GoConfigMother().addPipelineWithTemplate(cruiseConfig, "p1", "t1", "s1", "j1");
PipelineTemplateConfig template2 = PipelineTemplateConfigMother.createTemplate("t2", new Authorization(new AdminsConfig(new AdminUser(templateAdmin))), StageConfigMother.manualStage("foo"));
cruiseConfig.addTemplate(template2);
Username admin = new Username(templateAdmin);
when(goConfigService.getCurrentConfig()).thenReturn(cruiseConfig);
when(securityService.isAuthorizedToViewTemplate(new CaseInsensitiveString("t2"), admin)).thenReturn(true);
Map<CaseInsensitiveString, List<CaseInsensitiveString>> templatesWithAssociatedPipelinesForUser = new HashMap<>();
templatesWithAssociatedPipelinesForUser.put(new CaseInsensitiveString("t2"), new ArrayList<>());
assertThat(service.templatesWithPipelinesForUser(templateAdmin), is(templatesWithAssociatedPipelinesForUser));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class TemplateConfigServiceTest method shouldReturnASubsetOfTemplatesToPipelinesMapForGroupAdmin.
@Test
public void shouldReturnASubsetOfTemplatesToPipelinesMapForGroupAdmin() {
BasicCruiseConfig cruiseConfig = getCruiseConfigWithSecurityEnabled();
CaseInsensitiveString groupAdmin = new CaseInsensitiveString("group-admin");
new GoConfigMother().addPipelineWithTemplate(cruiseConfig, "p1", "t1", "s1", "j1");
// defaultGroup is set in GoConfigMother
PipelineConfigs pipelineConfigs = cruiseConfig.findGroup("defaultGroup");
pipelineConfigs.setAuthorization(new Authorization(new AdminsConfig(new AdminUser(groupAdmin))));
PipelineTemplateConfig template2 = PipelineTemplateConfigMother.createTemplate("t2", StageConfigMother.manualStage("foo"));
cruiseConfig.addTemplate(template2);
Username groupAdminUser = new Username(groupAdmin);
when(goConfigService.getCurrentConfig()).thenReturn(cruiseConfig);
when(securityService.isAuthorizedToViewTemplate(new CaseInsensitiveString("t1"), groupAdminUser)).thenReturn(true);
when(securityService.isAuthorizedToEditTemplate(new CaseInsensitiveString("t2"), groupAdminUser)).thenReturn(false);
when(securityService.isUserAdmin(groupAdminUser)).thenReturn(false);
Map<CaseInsensitiveString, List<CaseInsensitiveString>> templatesWithAssociatedPipelinesForUser = new HashMap<>();
templatesWithAssociatedPipelinesForUser.put(new CaseInsensitiveString("t1"), new ArrayList<>());
templatesWithAssociatedPipelinesForUser.get(new CaseInsensitiveString("t1")).add(new CaseInsensitiveString("p1"));
assertThat(service.templatesWithPipelinesForUser(groupAdmin), is(templatesWithAssociatedPipelinesForUser));
}
Aggregations