Search in sources :

Example 16 with Project

use of hudson.model.Project in project blueocean-plugin by jenkinsci.

the class PipelineApiTest method getFolderPipelineTest.

@Test
public void getFolderPipelineTest() throws IOException {
    MockFolder folder = j.createFolder("folder1");
    Project p = folder.createProject(FreeStyleProject.class, "test1");
    Map response = get("/organizations/jenkins/pipelines/folder1/pipelines/test1");
    validatePipeline(p, response);
}
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)

Example 17 with Project

use of hudson.model.Project 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 18 with Project

use of hudson.model.Project in project blueocean-plugin by jenkinsci.

the class PipelineApiTest method getPipelineTest.

@Test
public void getPipelineTest() throws IOException {
    Project p = j.createFreeStyleProject("pipeline1");
    Map<String, Object> response = get("/organizations/jenkins/pipelines/pipeline1");
    validatePipeline(p, response);
    String clazz = (String) response.get("_class");
    response = get("/classes/" + clazz + "/");
    assertNotNull(response);
    List<String> classes = (List<String>) response.get("classes");
    assertTrue(classes.contains("hudson.model.Job") && !classes.contains("org.jenkinsci.plugins.workflow.job.WorkflowJob") && !classes.contains("io.jenkins.blueocean.rest.model.BlueBranch"));
}
Also used : Project(hudson.model.Project) FreeStyleProject(hudson.model.FreeStyleProject) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Test(org.junit.Test)

Example 19 with Project

use of hudson.model.Project 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 = User.get("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) User(hudson.model.User) MockFolder(org.jvnet.hudson.test.MockFolder) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 20 with Project

use of hudson.model.Project in project blueocean-plugin by jenkinsci.

the class PipelineApiTest method deletePipelineTest.

/**
 * TODO: latest stapler change broke delete, disabled for now
 */
@Test
@Ignore
public void deletePipelineTest() throws IOException {
    Project p = j.createFreeStyleProject("pipeline1");
    delete("/organizations/jenkins/pipelines/pipeline1/");
    assertNull(j.jenkins.getItem(p.getName()));
}
Also used : Project(hudson.model.Project) FreeStyleProject(hudson.model.FreeStyleProject) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Project (hudson.model.Project)25 Test (org.junit.Test)23 FreeStyleProject (hudson.model.FreeStyleProject)22 ImmutableMap (com.google.common.collect.ImmutableMap)14 Map (java.util.Map)14 MockFolder (org.jvnet.hudson.test.MockFolder)13 List (java.util.List)7 ImmutableList (com.google.common.collect.ImmutableList)5 User (hudson.model.User)4 FreeStyleBuild (hudson.model.FreeStyleBuild)3 Shell (hudson.tasks.Shell)2 BaseTest (io.jenkins.blueocean.service.embedded.BaseTest)2 AbstractProject (hudson.model.AbstractProject)1 Item (hudson.model.Item)1 Run (hudson.model.Run)1 HudsonPrivateSecurityRealm (hudson.security.HudsonPrivateSecurityRealm)1 LegacyAuthorizationStrategy (hudson.security.LegacyAuthorizationStrategy)1 BlueTrendFactory (io.jenkins.blueocean.rest.factory.BlueTrendFactory)1 BlueOrganization (io.jenkins.blueocean.rest.model.BlueOrganization)1 BluePipeline (io.jenkins.blueocean.rest.model.BluePipeline)1