Search in sources :

Example 1 with GlobalSecurityConfig

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

the class SAMLPluginTest method authenticationOKFromURL.

@Test
@WithDocker
@WithPlugins({ "saml", "matrix-auth" })
public void authenticationOKFromURL() throws IOException, InterruptedException {
    // navigate to root
    jenkins.open();
    String rootUrl = jenkins.getCurrentUrl();
    SAMLContainer samlServer = startSimpleSAML(rootUrl);
    GlobalSecurityConfig sc = new GlobalSecurityConfig(jenkins);
    sc.open();
    // Authentication
    SamlSecurityRealm realm = configureBasicSettings(sc);
    realm.setUrl(createIdPMetadataURL(samlServer));
    configureEncrytion(realm);
    configureAuthorization(sc);
    // SAML service login page
    waitFor().withTimeout(10, TimeUnit.SECONDS).until(() -> hasContent("Enter your username and password"));
    // SAML server login
    makeLoginWithUser1();
}
Also used : SAMLContainer(org.jenkinsci.test.acceptance.docker.fixtures.SAMLContainer) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) GlobalSecurityConfig(org.jenkinsci.test.acceptance.po.GlobalSecurityConfig) SamlSecurityRealm(org.jenkinsci.test.acceptance.plugins.saml.SamlSecurityRealm) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins) WithDocker(org.jenkinsci.test.acceptance.junit.WithDocker)

Example 2 with GlobalSecurityConfig

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

the class SAMLPluginTest method authenticationFail.

@Test
@WithDocker
@WithPlugins({ "saml", "matrix-auth" })
public void authenticationFail() throws IOException, InterruptedException {
    // navigate to root
    jenkins.open();
    String rootUrl = jenkins.getCurrentUrl();
    SAMLContainer samlServer = startSimpleSAML(rootUrl);
    GlobalSecurityConfig sc = new GlobalSecurityConfig(jenkins);
    sc.open();
    // Authentication
    SamlSecurityRealm realm = configureBasicSettings(sc);
    String idpMetadata = readIdPMetadataFromURL(samlServer);
    realm.setXml(idpMetadata);
    configureEncrytion(realm);
    configureAuthorization(sc);
    // SAML service login page
    waitFor().withTimeout(10, TimeUnit.SECONDS).until(() -> hasContent("Enter your username and password"));
    // SAML server login
    find(by.id("username")).sendKeys("user1");
    find(by.id("password")).sendKeys("WrOnGpAsSwOrD");
    find(by.button("Login")).click();
    // wait for the login to propagate
    waitFor().withTimeout(5, TimeUnit.SECONDS).until(() -> hasContent("Either no user with the given username could be found, or the password you gave was wrong").matchesSafely(driver));
    assertThat(jenkins.getCurrentUrl(), containsString("simplesaml/module.php/core/loginuserpass.php"));
}
Also used : SAMLContainer(org.jenkinsci.test.acceptance.docker.fixtures.SAMLContainer) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) GlobalSecurityConfig(org.jenkinsci.test.acceptance.po.GlobalSecurityConfig) SamlSecurityRealm(org.jenkinsci.test.acceptance.plugins.saml.SamlSecurityRealm) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins) WithDocker(org.jenkinsci.test.acceptance.junit.WithDocker)

Example 3 with GlobalSecurityConfig

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

the class SAMLPluginTest method authenticationOK.

@Test
@WithDocker
@WithPlugins({ "saml", "matrix-auth" })
public void authenticationOK() throws IOException, InterruptedException {
    // navigate to root
    jenkins.open();
    String rootUrl = jenkins.getCurrentUrl();
    SAMLContainer samlServer = startSimpleSAML(rootUrl);
    GlobalSecurityConfig sc = new GlobalSecurityConfig(jenkins);
    sc.open();
    // Authentication
    SamlSecurityRealm realm = configureBasicSettings(sc);
    String idpMetadata = readIdPMetadataFromURL(samlServer);
    realm.setXml(idpMetadata);
    realm.setBinding(SAML2_REDIRECT_BINDING_URI);
    configureEncrytion(realm);
    configureAuthorization(sc);
    // SAML service login page
    waitFor().withTimeout(10, TimeUnit.SECONDS).until(() -> hasContent("Enter your username and password"));
    makeLoginWithUser1();
}
Also used : SAMLContainer(org.jenkinsci.test.acceptance.docker.fixtures.SAMLContainer) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) GlobalSecurityConfig(org.jenkinsci.test.acceptance.po.GlobalSecurityConfig) SamlSecurityRealm(org.jenkinsci.test.acceptance.plugins.saml.SamlSecurityRealm) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins) WithDocker(org.jenkinsci.test.acceptance.junit.WithDocker)

Example 4 with GlobalSecurityConfig

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

the class WarningsPluginTest method configureSecurity.

// TODO: Create a new security mock that can be used by other plugins
private void configureSecurity(final String admin, final String user) {
    GlobalSecurityConfig security = new GlobalSecurityConfig(jenkins);
    security.configure(() -> {
        MockSecurityRealm realm = security.useRealm(MockSecurityRealm.class);
        realm.configure(admin, user);
        MatrixAuthorizationStrategy mas = security.useAuthorizationStrategy(MatrixAuthorizationStrategy.class);
        mas.addUser(admin).admin();
        mas.addUser(user).developer();
    });
}
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)

Example 5 with GlobalSecurityConfig

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

the class KerberosSsoTest method setupRealmUser.

/**
 * Create KDC user in backend realm.
 *
 * It is necessary the backend realm recognises all the users kerberos let in. The user is logged in when this method completes.
 */
private User setupRealmUser() {
    // Populate realm with users
    GlobalSecurityConfig sc = new GlobalSecurityConfig(jenkins);
    sc.configure();
    JenkinsDatabaseSecurityRealm realm = sc.useRealm(JenkinsDatabaseSecurityRealm.class);
    sc.save();
    // The password needs to be the same as in kerberos
    return realm.signup().password("ATH").fullname("Full Name").email("ath@ath.com").signup("user");
}
Also used : GlobalSecurityConfig(org.jenkinsci.test.acceptance.po.GlobalSecurityConfig) JenkinsDatabaseSecurityRealm(org.jenkinsci.test.acceptance.po.JenkinsDatabaseSecurityRealm)

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