Search in sources :

Example 1 with LdapEnvironmentVariable

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

the class LdapSecurityRealm method configure.

/**
 * Fills the input fields for ldap access control.
 */
public void configure(LdapDetails<T> ldapDetails) {
    ldapServer.set(ldapDetails.getHostWithPort());
    advancedServer.click();
    rootDn.set(ldapDetails.getRootDn());
    managerDn.set(ldapDetails.getManagerDn());
    managerPassword.set(ldapDetails.getManagerPassword());
    userSearchBase.set(ldapDetails.getUserSearchBase());
    userSearchFilter.set(ldapDetails.getUserSearchFilter());
    groupSearchBase.set(ldapDetails.getGroupSearchBase());
    groupSearchFilter.set(ldapDetails.getGroupSearchFilter());
    configureGroupMembership(ldapDetails);
    if (this.sinceVersion116) {
        advanced.click();
    }
    disableLdapEmailResolver.check(ldapDetails.isDisableLdapEmailResolver());
    if (ldapDetails.isEnableCache()) {
        enableCache.check(true);
        control("cache/size").select(String.valueOf(ldapDetails.getCacheSize()));
        control("cache/ttl").select(String.valueOf(ldapDetails.getCacheTTL()));
    }
    if (ldapDetails.getDisplayNameAttributeName() != null) {
        displayNameAttributeName.set(ldapDetails.getDisplayNameAttributeName());
    }
    if (ldapDetails.getMailAddressAttributeName() != null) {
        mailAddressAttributeName.set(ldapDetails.getMailAddressAttributeName());
    }
    if (ldapDetails.getEnvironmentVariables() != null && !ldapDetails.getEnvironmentVariables().isEmpty()) {
        int i = 0;
        String envVarSelector;
        for (LdapEnvironmentVariable envVariable : ldapDetails.getEnvironmentVariables()) {
            addEnvVariableButton.click();
            envVarSelector = i == 0 ? "" : "[" + i + "]";
            control("configurations/environmentProperties" + envVarSelector + "/name", /* >= 1.16 */
            "/environmentProperties" + envVarSelector + "/name").set(envVariable.getName());
            control("configurations/environmentProperties" + envVarSelector + "/value", /* >= 1.16 */
            "/environmentProperties" + envVarSelector + "/value").set(envVariable.getValue());
            i++;
        }
    }
}
Also used : LdapEnvironmentVariable(org.jenkinsci.test.acceptance.plugins.ldap.LdapEnvironmentVariable)

Example 2 with LdapEnvironmentVariable

use of org.jenkinsci.test.acceptance.plugins.ldap.LdapEnvironmentVariable 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)

Aggregations

LdapEnvironmentVariable (org.jenkinsci.test.acceptance.plugins.ldap.LdapEnvironmentVariable)2 LdapDetails (org.jenkinsci.test.acceptance.plugins.ldap.LdapDetails)1 Login (org.jenkinsci.test.acceptance.po.Login)1 Test (org.junit.Test)1