Search in sources :

Example 11 with GlobalSecurityConfig

use of org.jenkinsci.test.acceptance.po.GlobalSecurityConfig in project acceptance-test-harness by jenkinsci.

the class ActiveDirectoryTest method userCanLoginToJenkinsAsAdmin.

private void userCanLoginToJenkinsAsAdmin(String userOrGroupToAddAsAdmin) {
    GlobalSecurityConfig security = saveSecurityConfig(userOrGroupToAddAsAdmin);
    jenkins.login().doLogin(ENV.getUser(), ENV.getPassword());
    security.configure();
    WebElement domain = getElement(by.name("_.domain"));
    assertThat(domain, is(notNullValue()));
    assertThat(domain.getAttribute("value"), is(equalTo(ENV.getDomain())));
}
Also used : WebElement(org.openqa.selenium.WebElement) GlobalSecurityConfig(org.jenkinsci.test.acceptance.po.GlobalSecurityConfig)

Example 12 with GlobalSecurityConfig

use of org.jenkinsci.test.acceptance.po.GlobalSecurityConfig in project acceptance-test-harness by jenkinsci.

the class FavoriteTest method shouldBeAbleToFavoriteAJob.

@Test
public void shouldBeAbleToFavoriteAJob() throws Exception {
    jenkins.jobs.create(FreeStyleJob.class, "my-project");
    final GlobalSecurityConfig security = new GlobalSecurityConfig(jenkins);
    security.open();
    MockSecurityRealm realm = security.useRealm(MockSecurityRealm.class);
    realm.configure(USER);
    security.save();
    jenkins.login().doLogin(USER);
    waitFor(by.id("fav_my-project")).click();
    // ensure the project is now a favourite
    waitFor(by.css(".icon-fav-active"));
    final User user = new User(jenkins, USER);
    jenkins.visit(user.getConfigUrl().toString());
    // will fail if the project has not been favourited
    waitFor(by.id("favorites"));
    waitFor(by.id("fav_my-project")).click();
    // ensure the project is no longer a favourite
    waitFor(by.css(".icon-fav-inactive"));
    jenkins.visit(user.getConfigUrl().toString());
    waitFor(driver).until(Matchers.hasContent("Favorites"));
    assertFalse(findIfNotVisible(by.id("favorites")).isDisplayed());
}
Also used : User(org.jenkinsci.test.acceptance.po.User) MockSecurityRealm(org.jenkinsci.test.acceptance.plugins.mock_security_realm.MockSecurityRealm) GlobalSecurityConfig(org.jenkinsci.test.acceptance.po.GlobalSecurityConfig) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 13 with GlobalSecurityConfig

use of org.jenkinsci.test.acceptance.po.GlobalSecurityConfig in project acceptance-test-harness by jenkinsci.

the class ScriptSecurityPluginTest method setUp.

@Before
public void setUp() {
    final GlobalSecurityConfig security = new GlobalSecurityConfig(jenkins);
    security.open();
    {
        MockSecurityRealm realm = security.useRealm(MockSecurityRealm.class);
        realm.configure(ADMIN, USER);
        MatrixAuthorizationStrategy mas = security.useAuthorizationStrategy(MatrixAuthorizationStrategy.class);
        mas.addUser(ADMIN).admin();
        mas.addUser(USER).developer();
    }
    security.save();
}
Also used : MockSecurityRealm(org.jenkinsci.test.acceptance.plugins.mock_security_realm.MockSecurityRealm) GlobalSecurityConfig(org.jenkinsci.test.acceptance.po.GlobalSecurityConfig) MatrixAuthorizationStrategy(org.jenkinsci.test.acceptance.plugins.matrix_auth.MatrixAuthorizationStrategy) Before(org.junit.Before)

Example 14 with GlobalSecurityConfig

use of org.jenkinsci.test.acceptance.po.GlobalSecurityConfig in project acceptance-test-harness by jenkinsci.

the class MatrixAuthPluginTest method helloWorld.

/**
 * Test scenario:
 *
 * - we create admin user "alice" and regular limited user "bob"
 * - alice creates a new project
 * - bob shouldn't be able to see it
 */
@Test
public void helloWorld() throws Exception {
    GlobalSecurityConfig sc = new GlobalSecurityConfig(jenkins);
    sc.open();
    {
        MockSecurityRealm ms = sc.useRealm(MockSecurityRealm.class);
        ms.configure("alice", "bob");
        MatrixAuthorizationStrategy mas = sc.useAuthorizationStrategy(MatrixAuthorizationStrategy.class);
        MatrixRow a = mas.addUser("alice");
        a.admin();
        MatrixRow bob = mas.addUser("bob");
        bob.on(OVERALL_READ);
    }
    sc.save();
    jenkins.login().doLogin("alice");
    FreeStyleJob j = jenkins.jobs.create();
    j.save();
    jenkins.logout();
    // if we login as Bob, he shouldn't see the job
    jenkins.login().doLogin("bob");
    // check for job's existence
    assertFalse(j.open().getTitle().contains(j.name));
    jenkins.logout();
    // control assertion: alice should see the link
    jenkins.login().doLogin("alice");
    assertTrue(j.open().getTitle().contains(j.name));
}
Also used : MockSecurityRealm(org.jenkinsci.test.acceptance.plugins.mock_security_realm.MockSecurityRealm) MatrixRow(org.jenkinsci.test.acceptance.plugins.matrix_auth.MatrixRow) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) GlobalSecurityConfig(org.jenkinsci.test.acceptance.po.GlobalSecurityConfig) MatrixAuthorizationStrategy(org.jenkinsci.test.acceptance.plugins.matrix_auth.MatrixAuthorizationStrategy) ProjectBasedMatrixAuthorizationStrategy(org.jenkinsci.test.acceptance.plugins.matrix_auth.ProjectBasedMatrixAuthorizationStrategy) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 15 with GlobalSecurityConfig

use of org.jenkinsci.test.acceptance.po.GlobalSecurityConfig in project acceptance-test-harness by jenkinsci.

the class AuthorizeProjectTest method authorizeUserToLaunchProject.

private void authorizeUserToLaunchProject(final String user) {
    final GlobalSecurityConfig security = new GlobalSecurityConfig(jenkins);
    security.open();
    final ProjectDefaultBuildAccessControl control = security.addBuildAccessControl(ProjectDefaultBuildAccessControl.class);
    control.runAsSpecificUser(user);
    security.save();
}
Also used : GlobalSecurityConfig(org.jenkinsci.test.acceptance.po.GlobalSecurityConfig) ProjectDefaultBuildAccessControl(org.jenkinsci.test.acceptance.plugins.authorize_project.ProjectDefaultBuildAccessControl)

Aggregations

GlobalSecurityConfig (org.jenkinsci.test.acceptance.po.GlobalSecurityConfig)29 Test (org.junit.Test)17 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)15 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)9 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)9 MockSecurityRealm (org.jenkinsci.test.acceptance.plugins.mock_security_realm.MockSecurityRealm)7 JobDslBuildStep (org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep)5 Build (org.jenkinsci.test.acceptance.po.Build)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 SAMLContainer (org.jenkinsci.test.acceptance.docker.fixtures.SAMLContainer)4 WithDocker (org.jenkinsci.test.acceptance.junit.WithDocker)4 MatrixAuthorizationStrategy (org.jenkinsci.test.acceptance.plugins.matrix_auth.MatrixAuthorizationStrategy)4 SamlSecurityRealm (org.jenkinsci.test.acceptance.plugins.saml.SamlSecurityRealm)4 Before (org.junit.Before)4 MatrixRow (org.jenkinsci.test.acceptance.plugins.matrix_auth.MatrixRow)3 LdapSecurityRealm (org.jenkinsci.test.acceptance.po.LdapSecurityRealm)3 LdapDetails (org.jenkinsci.test.acceptance.plugins.ldap.LdapDetails)2 ProjectBasedMatrixAuthorizationStrategy (org.jenkinsci.test.acceptance.plugins.matrix_auth.ProjectBasedMatrixAuthorizationStrategy)2 JenkinsDatabaseSecurityRealm (org.jenkinsci.test.acceptance.po.JenkinsDatabaseSecurityRealm)2 Login (org.jenkinsci.test.acceptance.po.Login)2