use of hudson.security.LegacyAuthorizationStrategy in project blueocean-plugin by jenkinsci.
the class PipelineApiTest method PipelineSecureWithAnonymousUserPermissionTest.
@Test
public void PipelineSecureWithAnonymousUserPermissionTest() throws IOException {
j.jenkins.setSecurityRealm(new HudsonPrivateSecurityRealm(false));
j.jenkins.setAuthorizationStrategy(new LegacyAuthorizationStrategy());
MockFolder folder = j.createFolder("folder1");
Project p = folder.createProject(FreeStyleProject.class, "test1");
Map response = get("/organizations/jenkins/pipelines/folder1/pipelines/test1");
validatePipeline(p, response);
Map<String, Boolean> permissions = (Map<String, Boolean>) response.get("permissions");
Assert.assertFalse(permissions.get("create"));
Assert.assertFalse(permissions.get("start"));
Assert.assertFalse(permissions.get("stop"));
assertTrue(permissions.get("read"));
response = get("/organizations/jenkins/pipelines/folder1/");
permissions = (Map<String, Boolean>) response.get("permissions");
Assert.assertFalse(permissions.get("create"));
Assert.assertFalse(permissions.get("start"));
Assert.assertFalse(permissions.get("stop"));
assertTrue(permissions.get("read"));
}
use of hudson.security.LegacyAuthorizationStrategy 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"));
}
Aggregations