use of org.jenkinsci.test.acceptance.po.LdapSecurityRealm in project acceptance-test-harness by jenkinsci.
the class LdapPluginTest method useLdapAsSecurityRealm.
/**
* "Jenkins is using ldap as security realm"
*/
private void useLdapAsSecurityRealm(LdapDetails ldapDetails) {
GlobalSecurityConfig security = new GlobalSecurityConfig(jenkins);
security.configure();
LdapSecurityRealm realm = security.useRealm(LdapSecurityRealm.class);
realm.configure(ldapDetails);
security.save();
}
use of org.jenkinsci.test.acceptance.po.LdapSecurityRealm 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"));
}
use of org.jenkinsci.test.acceptance.po.LdapSecurityRealm 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")));
}
Aggregations