Search in sources :

Example 1 with LdapContainer

use of org.jenkinsci.test.acceptance.docker.fixtures.LdapContainer 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)

Aggregations

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