Source:
public void testManualPromotionPermissionsViaWebClient() throws Exception { enableSecurity(j); FreeStyleProject p = j.createFreeStyleProject(); PromotionProcess pp = addPromotionProcess(p, "foo"); WebClient wc = j.createWebClient(); FreeStyleBuild b = j.assertBuildStatusSuccess(p.scheduleBuild2(0)); ManualCondition cond = new ManualCondition(); pp.conditions.add(cond); j.assertBuildStatusSuccess(cond.approve(b, pp, Collections.EMPTY_LIST)); assertThat(b.getAction(ManualApproval.class), notNullValue()); { wc.login("non-promoter", "non-promoter"); wc.goTo(String.format("job/%s/%d/promotion/%s/build?json={}", p.getName(), b.getNumber(), pp.getName()), ""); assertThat(pp.getBuildByNumber(2), nullValue()); } { wc.login("promoter", "promoter"); try { wc.getPage(b, String.format("promotion/%s/build?json={}", pp.getName())); fail(); } catch (FailingHttpStatusCodeException e) { assertThat(e.getStatusCode(), equalTo(404)); } assertThat(waitForBuildByNumber(pp, 2).getResult(), equalTo(Result.SUCCESS)); } { cond.setUsers("non-promoter"); wc.login("non-promoter", "non-promoter"); try { wc.getPage(b, String.format("promotion/%s/build?json={}", pp.getName())); fail(); } catch (FailingHttpStatusCodeException e) { assertThat(e.getStatusCode(), equalTo(404)); } assertThat(waitForBuildByNumber(pp, 3).getResult(), equalTo(Result.SUCCESS)); } { cond.setUsers("non-promoter"); wc.login("promoter", "promoter"); try { wc.goTo(String.format("job/%s/%d/promotion/%s/build?json={}", p.getName(), b.getNumber(), pp.getName()), ""); } catch (FailingHttpStatusCodeException e) { fail(); } assertThat(pp.getBuildByNumber(4), nullValue()); } }

Target:
public void testManualPromotionPermissionsViaWebClient() throws Exception { enableSecurity(j); FreeStyleProject p = j.createFreeStyleProject(); PromotionProcess pp = addPromotionProcess(p, "foo"); WebClient wc = j.createWebClient(); FreeStyleBuild b = j.assertBuildStatusSuccess(p.scheduleBuild2(0)); ManualCondition cond = new ManualCondition(); pp.conditions.add(cond); j.assertBuildStatusSuccess(cond.approve(b, pp, Collections.EMPTY_LIST)); assertThat(b.getAction(ManualApproval.class), notNullValue()); { wc.login("non-promoter", "non-promoter"); wc.goTo(String.format("job/%s/%d/promotion/%s/build?json={}", p.getName(), b.getNumber(), pp.getName()), ""); assertThat(pp.getBuildByNumber(2), nullValue()); } { wc.login("promoter", "promoter"); try { wc.getPage(b, String.format("promotion/%s/build?json={}", pp.getName())); fail(); } catch (FailingHttpStatusCodeException e) { assertThat(e.getStatusCode(), equalTo(404)); } assertThat(waitForBuildByNumber(pp, 2).getResult(), equalTo(Result.SUCCESS)); } { cond.setUsers("non-promoter"); wc.login("non-promoter", "non-promoter"); try { wc.getPage(b, String.format("promotion/%s/build?json={}", pp.getName())); fail(); } catch (FailingHttpStatusCodeException e) { assertThat(e.getStatusCode(), equalTo(404)); } assertThat(waitForBuildByNumber(pp, 3).getResult(), equalTo(Result.SUCCESS)); } { cond.setUsers("non-promoter"); wc.login("promoter", "promoter"); wc.goTo(String.format("job/%s/%d/promotion/%s/build?json={}", p.getName(), b.getNumber(), pp.getName()), ""); assertThat(pp.getBuildByNumber(4), nullValue()); } }