Search in sources :

Example 11 with MockFolder

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

the class ItemPathResolverTest method shouldProvideNewBehaviorByDefault.

@Test
public void shouldProvideNewBehaviorByDefault() throws Exception {
    assertsPath("prj", null, projectInTop);
    // FOO exists on both top level and within the folder
    final MockFolder folder = rule.createFolder("F");
    final FreeStyleProject prjInRoot = rule.createFreeStyleProject("FOO");
    final FreeStyleProject prjInFolder = folder.createProject(FreeStyleProject.class, "FOO");
    // Raw addressing with different roots, should always point to the root
    assertsPath("FOO", null, prjInRoot);
    assertsPath("FOO", prjInRoot, prjInRoot);
    assertsPath("FOO", folder, prjInFolder);
    assertsPath("FOO", prjInFolder, prjInFolder);
}
Also used : MockFolder(org.jvnet.hudson.test.MockFolder) FreeStyleProject(hudson.model.FreeStyleProject) Test(org.junit.Test)

Example 12 with MockFolder

use of org.jvnet.hudson.test.MockFolder 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 = BlueOceanWebURLBuilder.toBlueOceanURL(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 = BlueOceanWebURLBuilder.toBlueOceanURL(masterJob);
    assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/branches", blueOceanURL);
    WorkflowJob featureUx1Job = findBranchProject(mp, "feature/ux-1");
    blueOceanURL = BlueOceanWebURLBuilder.toBlueOceanURL(featureUx1Job);
    assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/branches", blueOceanURL);
    WorkflowJob feature2Job = findBranchProject(mp, "feature2");
    blueOceanURL = BlueOceanWebURLBuilder.toBlueOceanURL(feature2Job);
    assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/branches", blueOceanURL);
    // Runs on the jobs
    blueOceanURL = BlueOceanWebURLBuilder.toBlueOceanURL(masterJob.getFirstBuild());
    assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/detail/master/1", blueOceanURL);
    blueOceanURL = BlueOceanWebURLBuilder.toBlueOceanURL(featureUx1Job.getFirstBuild());
    assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/detail/feature%2Fux-1/1", blueOceanURL);
}
Also used : WorkflowMultiBranchProject(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject) GitSCMSource(jenkins.plugins.git.GitSCMSource) SCMSource(jenkins.scm.api.SCMSource) GitSCMSource(jenkins.plugins.git.GitSCMSource) MockFolder(org.jvnet.hudson.test.MockFolder) BranchSource(jenkins.branch.BranchSource) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) DefaultBranchPropertyStrategy(jenkins.branch.DefaultBranchPropertyStrategy) Test(org.junit.Test)

Example 13 with MockFolder

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

the class MultiBranchTest method getMultiBranchPipelineInsideFolder.

@Test
public void getMultiBranchPipelineInsideFolder() throws IOException, ExecutionException, InterruptedException {
    MockFolder folder1 = j.createFolder("folder1");
    WorkflowMultiBranchProject mp = folder1.createProject(WorkflowMultiBranchProject.class, "p");
    mp.setDisplayName("My MBP");
    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/");
    validateMultiBranchPipeline(mp, r, 3);
    Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/p/", ((Map) ((Map) r.get("_links")).get("self")).get("href"));
    Assert.assertEquals("folder1/My%20MBP", r.get("fullDisplayName"));
    r = get("/organizations/jenkins/pipelines/folder1/pipelines/p/master/");
    Assert.assertEquals("folder1/My%20MBP/master", r.get("fullDisplayName"));
}
Also used : WorkflowMultiBranchProject(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject) GitSCMSource(jenkins.plugins.git.GitSCMSource) SCMSource(jenkins.scm.api.SCMSource) GitSCMSource(jenkins.plugins.git.GitSCMSource) MockFolder(org.jvnet.hudson.test.MockFolder) BranchSource(jenkins.branch.BranchSource) DefaultBranchPropertyStrategy(jenkins.branch.DefaultBranchPropertyStrategy) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 14 with MockFolder

use of org.jvnet.hudson.test.MockFolder 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"));
}
Also used : WorkflowMultiBranchProject(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject) LegacyAuthorizationStrategy(hudson.security.LegacyAuthorizationStrategy) GitSCMSource(jenkins.plugins.git.GitSCMSource) SCMSource(jenkins.scm.api.SCMSource) GitSCMSource(jenkins.plugins.git.GitSCMSource) MockFolder(org.jvnet.hudson.test.MockFolder) BranchSource(jenkins.branch.BranchSource) HudsonPrivateSecurityRealm(hudson.security.HudsonPrivateSecurityRealm) DefaultBranchPropertyStrategy(jenkins.branch.DefaultBranchPropertyStrategy) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 15 with MockFolder

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

the class ItemPathResolverTest method shouldProperlyHandleEqualNames.

@Test
public void shouldProperlyHandleEqualNames() throws Exception {
    final MockFolder folder = rule.createFolder("FOO");
    final FreeStyleProject prj = folder.createProject(FreeStyleProject.class, "FOO");
    assertsPath("/FOO/FOO", null, prj);
    assertsPath("FOO/FOO", null, prj);
    // Addressing starts from the folder
    assertsPath("FOO", folder, prj);
    assertsPath("./FOO", folder, prj);
    assertsPath(".", folder, folder);
    assertsPath("../FOO", folder, folder);
    assertsPath("../FOO/FOO", folder, prj);
    // Addressing starts from the parent folder
    assertsPath("FOO", prj, prj);
    assertsPath("./FOO", prj, prj);
    assertsPath(".", prj, folder);
    assertsPath("../FOO", prj, folder);
    assertsPath("../FOO/FOO", prj, prj);
}
Also used : MockFolder(org.jvnet.hudson.test.MockFolder) FreeStyleProject(hudson.model.FreeStyleProject) 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