Search in sources :

Example 21 with MockFolder

use of org.jvnet.hudson.test.MockFolder in project blueocean-plugin by jenkinsci.

the class PipelineApiTest method findAllPipelineTest.

@Test
public void findAllPipelineTest() throws IOException, ExecutionException, InterruptedException {
    MockFolder folder1 = j.createFolder("folder1");
    j.createFolder("afolder");
    Project p1 = folder1.createProject(FreeStyleProject.class, "test1");
    MockFolder folder2 = folder1.createProject(MockFolder.class, "folder2");
    folder1.createProject(MockFolder.class, "folder3");
    folder2.createProject(FreeStyleProject.class, "test2");
    FreeStyleBuild b1 = (FreeStyleBuild) p1.scheduleBuild2(0).get();
    List<Map> resp = get("/search?q=type:pipeline", List.class);
    assertEquals(6, resp.size());
}
Also used : Project(hudson.model.Project) FreeStyleProject(hudson.model.FreeStyleProject) FreeStyleBuild(hudson.model.FreeStyleBuild) MockFolder(org.jvnet.hudson.test.MockFolder) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 22 with MockFolder

use of org.jvnet.hudson.test.MockFolder in project blueocean-plugin by jenkinsci.

the class PipelineApiTest method PipelineSecureWithLoggedInUserPermissionTest.

@Test
public void PipelineSecureWithLoggedInUserPermissionTest() throws IOException, UnirestException {
    j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
    hudson.model.User user = j.jenkins.getUser("alice");
    user.setFullName("Alice Cooper");
    MockFolder folder = j.createFolder("folder1");
    Project p = folder.createProject(FreeStyleProject.class, "test1");
    String token = getJwtToken(j.jenkins, "alice", "alice");
    assertNotNull(token);
    Map response = new RequestBuilder(baseUrl).get("/organizations/jenkins/pipelines/folder1/pipelines/test1").jwtToken(token).build(Map.class);
    validatePipeline(p, response);
    Map<String, Boolean> permissions = (Map<String, Boolean>) response.get("permissions");
    assertTrue(permissions.get("create"));
    assertTrue(permissions.get("start"));
    assertTrue(permissions.get("stop"));
    assertTrue(permissions.get("read"));
}
Also used : Project(hudson.model.Project) FreeStyleProject(hudson.model.FreeStyleProject) MockFolder(org.jvnet.hudson.test.MockFolder) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)22 MockFolder (org.jvnet.hudson.test.MockFolder)22 FreeStyleProject (hudson.model.FreeStyleProject)18 Project (hudson.model.Project)11 ImmutableMap (com.google.common.collect.ImmutableMap)10 Map (java.util.Map)10 FreeStyleBuild (hudson.model.FreeStyleBuild)4 BranchSource (jenkins.branch.BranchSource)4 DefaultBranchPropertyStrategy (jenkins.branch.DefaultBranchPropertyStrategy)4 GitSCMSource (jenkins.plugins.git.GitSCMSource)4 SCMSource (jenkins.scm.api.SCMSource)4 WorkflowMultiBranchProject (org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject)4 User (hudson.model.User)3 ImmutableList (com.google.common.collect.ImmutableList)2 EnvVars (hudson.EnvVars)2 Action (hudson.model.Action)2 ParameterValue (hudson.model.ParameterValue)2 ManualCondition (hudson.plugins.promoted_builds.conditions.ManualCondition)2 HudsonPrivateSecurityRealm (hudson.security.HudsonPrivateSecurityRealm)2 LegacyAuthorizationStrategy (hudson.security.LegacyAuthorizationStrategy)2