use of org.jenkinsci.test.acceptance.plugins.matrix_auth.ProjectBasedMatrixAuthorizationStrategy in project acceptance-test-harness by jenkinsci.
the class MatrixAuthPluginTest method projectMatrixAuth.
/**
* Test scenario:
*/
@Test
public void projectMatrixAuth() throws Exception {
GlobalSecurityConfig sc = new GlobalSecurityConfig(jenkins);
sc.open();
{
MockSecurityRealm ms = sc.useRealm(MockSecurityRealm.class);
ms.configure("alice", "bob");
ProjectBasedMatrixAuthorizationStrategy mas = sc.useAuthorizationStrategy(ProjectBasedMatrixAuthorizationStrategy.class);
MatrixRow a = mas.addUser("alice");
a.admin();
MatrixRow bob = mas.addUser("bob");
bob.on(OVERALL_READ);
}
sc.save();
jenkins.login().doLogin("alice");
// just create the job without configuring
FreeStyleJob j = jenkins.jobs.create();
jenkins.logout();
// bob shouldn't be able to see it without adding a permission for him
jenkins.login().doLogin("bob");
// check for job's existence
assertFalse(j.open().getTitle().contains(j.name));
jenkins.logout();
// alice will expose this job to bob
jenkins.login().doLogin("alice");
j.configure();
{
ProjectMatrixProperty p = new ProjectMatrixProperty(j);
p.enable.check();
MatrixRow bob = p.addUser("bob");
bob.on(ITEM_READ);
}
j.save();
jenkins.logout();
// bob should see this job
jenkins.login().doLogin("bob");
assertTrue(j.open().getTitle().contains(j.name));
}
Aggregations