Search in sources :

Example 1 with FromGroupSearchLDAPGroupMembershipStrategy

use of jenkins.security.plugins.ldap.FromGroupSearchLDAPGroupMembershipStrategy in project configuration-as-code-plugin by jenkinsci.

the class LDAPTest method configure_ldap.

@Test
@ConfiguredWithReadme("ldap/README.md")
public void configure_ldap() {
    final Jenkins jenkins = Jenkins.get();
    final LDAPSecurityRealm securityRealm = (LDAPSecurityRealm) jenkins.getSecurityRealm();
    assertEquals(1, securityRealm.getConfigurations().size());
    assertTrue(securityRealm.getUserIdStrategy() instanceof IdStrategy.CaseInsensitive);
    assertTrue(securityRealm.getGroupIdStrategy() instanceof IdStrategy.CaseSensitive);
    final LDAPConfiguration configuration = securityRealm.getConfigurations().get(0);
    assertEquals("ldap.acme.com", configuration.getServer());
    assertEquals("SECRET", configuration.getManagerPassword());
    assertEquals("manager", configuration.getManagerDN());
    assertEquals("(&(objectCategory=User)(sAMAccountName={0}))", configuration.getUserSearch());
    assertEquals("(&(cn={0})(objectclass=group))", configuration.getGroupSearchFilter());
    final FromGroupSearchLDAPGroupMembershipStrategy strategy = ((FromGroupSearchLDAPGroupMembershipStrategy) configuration.getGroupMembershipStrategy());
    assertEquals("(&(objectClass=group)(|(cn=GROUP_1)(cn=GROUP_2)))", strategy.getFilter());
}
Also used : Jenkins(jenkins.model.Jenkins) LDAPSecurityRealm(hudson.security.LDAPSecurityRealm) FromGroupSearchLDAPGroupMembershipStrategy(jenkins.security.plugins.ldap.FromGroupSearchLDAPGroupMembershipStrategy) IdStrategy(jenkins.model.IdStrategy) LDAPConfiguration(jenkins.security.plugins.ldap.LDAPConfiguration) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Aggregations

LDAPSecurityRealm (hudson.security.LDAPSecurityRealm)1 ConfiguredWithReadme (io.jenkins.plugins.casc.misc.ConfiguredWithReadme)1 IdStrategy (jenkins.model.IdStrategy)1 Jenkins (jenkins.model.Jenkins)1 FromGroupSearchLDAPGroupMembershipStrategy (jenkins.security.plugins.ldap.FromGroupSearchLDAPGroupMembershipStrategy)1 LDAPConfiguration (jenkins.security.plugins.ldap.LDAPConfiguration)1 Test (org.junit.Test)1