use of jenkins.branch.BranchSource in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method testMultiBranchPipelineBranchSecurePermissions.
@Test
public void testMultiBranchPipelineBranchSecurePermissions() throws IOException, ExecutionException, InterruptedException {
j.jenkins.setSecurityRealm(new HudsonPrivateSecurityRealm(false));
j.jenkins.setAuthorizationStrategy(new LegacyAuthorizationStrategy());
MockFolder folder1 = j.createFolder("folder1");
WorkflowMultiBranchProject mp = folder1.createProject(WorkflowMultiBranchProject.class, "p");
mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false), new DefaultBranchPropertyStrategy(new BranchProperty[0])));
for (SCMSource source : mp.getSCMSources()) {
assertEquals(mp, source.getOwner());
}
mp.scheduleBuild2(0).getFuture().get();
Map r = get("/organizations/jenkins/pipelines/folder1/pipelines/p/");
Map<String, Boolean> permissions = (Map<String, Boolean>) r.get("permissions");
Assert.assertFalse(permissions.get("create"));
Assert.assertTrue(permissions.get("read"));
Assert.assertFalse(permissions.get("start"));
Assert.assertFalse(permissions.get("stop"));
r = get("/organizations/jenkins/pipelines/folder1/pipelines/p/branches/master/");
permissions = (Map<String, Boolean>) r.get("permissions");
Assert.assertFalse(permissions.get("create"));
Assert.assertFalse(permissions.get("start"));
Assert.assertFalse(permissions.get("stop"));
Assert.assertTrue(permissions.get("read"));
}
use of jenkins.branch.BranchSource in project blueocean-plugin by jenkinsci.
the class BlueOceanWebURLBuilderTest method getMultiBranchPipelineInsideFolder.
@Test
public void getMultiBranchPipelineInsideFolder() throws Exception {
MockFolder folder1 = jenkinsRule.createFolder("folder1");
MockFolder folder2 = folder1.createProject(MockFolder.class, "folder two with spaces");
WorkflowMultiBranchProject mp = folder2.createProject(WorkflowMultiBranchProject.class, "p");
String blueOceanURL;
blueOceanURL = urlMapper.getUrl(mp);
assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/branches/", blueOceanURL);
mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false), new DefaultBranchPropertyStrategy(new BranchProperty[0])));
for (SCMSource source : mp.getSCMSources()) {
assertEquals(mp, source.getOwner());
}
mp.scheduleBuild2(0).getFuture().get();
jenkinsRule.waitUntilNoActivity();
// All branch jobs should just resolve back to the same top level branches
// page for the multibranch job in Blue Ocean.
WorkflowJob masterJob = findBranchProject(mp, "master");
blueOceanURL = urlMapper.getUrl(masterJob);
assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/branches/", blueOceanURL);
WorkflowJob featureUx1Job = findBranchProject(mp, "feature/ux-1");
blueOceanURL = urlMapper.getUrl(featureUx1Job);
assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/branches/", blueOceanURL);
WorkflowJob feature2Job = findBranchProject(mp, "feature2");
blueOceanURL = urlMapper.getUrl(feature2Job);
assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/branches/", blueOceanURL);
// Runs on the jobs
blueOceanURL = urlMapper.getUrl(masterJob.getFirstBuild());
assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/detail/master/1/", blueOceanURL);
blueOceanURL = urlMapper.getUrl(featureUx1Job.getFirstBuild());
assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/detail/feature%2Fux-1/1/", blueOceanURL);
}
Aggregations