Search in sources :

Example 1 with LdapDetails

use of org.jenkinsci.test.acceptance.plugins.ldap.LdapDetails in project acceptance-test-harness by jenkinsci.

the class LdapPluginTest method enable_cache.

@Test
public void enable_cache() throws IOException {
    // Given
    LdapDetails details = createDefaults(ldap.get());
    details.setEnableCache(true);
    useLdapAsSecurityRealm(details);
    // When
    Login login = jenkins.login();
    login.doLogin("jenkins", "root");
    // Then
    assertThat(jenkins, hasLoggedInUser("jenkins"));
}
Also used : LdapDetails(org.jenkinsci.test.acceptance.plugins.ldap.LdapDetails) Login(org.jenkinsci.test.acceptance.po.Login) Test(org.junit.Test)

Example 2 with LdapDetails

use of org.jenkinsci.test.acceptance.plugins.ldap.LdapDetails in project acceptance-test-harness by jenkinsci.

the class LdapPluginTest method do_not_resolve_email.

@Test
public void do_not_resolve_email() {
    // Given
    LdapDetails details = createDefaults(ldap.get());
    details.setDisableLdapEmailResolver(true);
    useLdapAsSecurityRealm(details);
    // When
    Login login = jenkins.login();
    login.doLogin("jenkins", "root");
    // Then
    assertThat(jenkins, hasLoggedInUser("jenkins"));
    User u = new User(jenkins, "jenkins");
    assertThat(u.mail(), nullValue());
}
Also used : LdapDetails(org.jenkinsci.test.acceptance.plugins.ldap.LdapDetails) User(org.jenkinsci.test.acceptance.po.User) Login(org.jenkinsci.test.acceptance.po.Login) Test(org.junit.Test)

Example 3 with LdapDetails

use of org.jenkinsci.test.acceptance.plugins.ldap.LdapDetails in project acceptance-test-harness by jenkinsci.

the class LdapPluginTest method login_use_fallback_server.

@Test
public void login_use_fallback_server() {
    // Given
    LdapContainer ldapContainer = ldap.get();
    GlobalSecurityConfig securityConfig = new GlobalSecurityConfig(jenkins);
    securityConfig.configure();
    LdapSecurityRealm realm = securityConfig.useRealm(LdapSecurityRealm.class);
    int freePort = this.findAvailablePort();
    LdapDetails ldapDetails = new LdapDetails("", 0, ldapContainer.getManagerDn(), ldapContainer.getManagerPassword(), ldapContainer.getRootDn());
    // Fallback-Config: primary server is not running, alternative server is running docker fixture
    ldapDetails.setHostWithPort("localhost:" + freePort + ' ' + ldapContainer.getHost() + ':' + ldapContainer.getPort());
    realm.configure(ldapDetails);
    securityConfig.save();
    // When
    Login login = jenkins.login();
    login.doLogin("jenkins", "root");
    // Then
    assertThat(jenkins, hasLoggedInUser("jenkins"));
}
Also used : LdapDetails(org.jenkinsci.test.acceptance.plugins.ldap.LdapDetails) LdapSecurityRealm(org.jenkinsci.test.acceptance.po.LdapSecurityRealm) Login(org.jenkinsci.test.acceptance.po.Login) LdapContainer(org.jenkinsci.test.acceptance.docker.fixtures.LdapContainer) GlobalSecurityConfig(org.jenkinsci.test.acceptance.po.GlobalSecurityConfig) Test(org.junit.Test)

Example 4 with LdapDetails

use of org.jenkinsci.test.acceptance.plugins.ldap.LdapDetails in project acceptance-test-harness by jenkinsci.

the class LdapPluginTest method use_environment_varibales.

@Test
public void use_environment_varibales() {
    // Given
    LdapDetails details = createDefaultsWithoutManagerCred(ldap.get());
    details.addEnvironmentVariable(new LdapEnvironmentVariable("java.naming.security.protocol", "ssl"));
    useLdapAsSecurityRealm(details);
    // When
    Login login = jenkins.login();
    login.doLogin("jenkins", "root");
    // Then
    assertThat(jenkins, not(hasLoggedInUser("jenkins")));
}
Also used : LdapDetails(org.jenkinsci.test.acceptance.plugins.ldap.LdapDetails) LdapEnvironmentVariable(org.jenkinsci.test.acceptance.plugins.ldap.LdapEnvironmentVariable) Login(org.jenkinsci.test.acceptance.po.Login) Test(org.junit.Test)

Example 5 with LdapDetails

use of org.jenkinsci.test.acceptance.plugins.ldap.LdapDetails in project acceptance-test-harness by jenkinsci.

the class LdapPluginTest method login_no_ldap.

@Test
public void login_no_ldap() throws InterruptedException {
    // Given
    // don't start docker fixture here
    // When
    GlobalSecurityConfig security = new GlobalSecurityConfig(jenkins);
    security.configure();
    LdapSecurityRealm realm = security.useRealm(LdapSecurityRealm.class);
    int freePort = findAvailablePort();
    LdapDetails notRunningLdap = new LdapDetails("localhost", freePort, "cn=admin,dc=jenkins-ci,dc=org", "root", "dc=jenkins-ci,dc=org");
    realm.configure(notRunningLdap);
    security.save();
    // Then
    waitFor(security.open(), hasContent("Unable to connect to localhost:" + freePort), 5);
    Login login = jenkins.login();
    login.doLogin("jenkins", "root");
    assertThat(jenkins, not(hasLoggedInUser("jenkins")));
}
Also used : LdapDetails(org.jenkinsci.test.acceptance.plugins.ldap.LdapDetails) LdapSecurityRealm(org.jenkinsci.test.acceptance.po.LdapSecurityRealm) Login(org.jenkinsci.test.acceptance.po.Login) GlobalSecurityConfig(org.jenkinsci.test.acceptance.po.GlobalSecurityConfig) Test(org.junit.Test)

Aggregations

LdapDetails (org.jenkinsci.test.acceptance.plugins.ldap.LdapDetails)5 Login (org.jenkinsci.test.acceptance.po.Login)5 Test (org.junit.Test)5 GlobalSecurityConfig (org.jenkinsci.test.acceptance.po.GlobalSecurityConfig)2 LdapSecurityRealm (org.jenkinsci.test.acceptance.po.LdapSecurityRealm)2 LdapContainer (org.jenkinsci.test.acceptance.docker.fixtures.LdapContainer)1 LdapEnvironmentVariable (org.jenkinsci.test.acceptance.plugins.ldap.LdapEnvironmentVariable)1 User (org.jenkinsci.test.acceptance.po.User)1