use of hudson.security.LDAPSecurityRealm 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());
}
use of hudson.security.LDAPSecurityRealm in project configuration-as-code-plugin by jenkinsci.
the class TopReadmeTest method configure_demo_first_code_block.
@Test
@ConfiguredWithReadme("README.md#0")
public void configure_demo_first_code_block() {
final Jenkins jenkins = Jenkins.get();
assertEquals("Jenkins configured automatically by Jenkins Configuration as Code plugin\n\n", jenkins.getSystemMessage());
final LDAPSecurityRealm securityRealm = (LDAPSecurityRealm) jenkins.getSecurityRealm();
assertEquals(1, securityRealm.getConfigurations().size());
assertEquals(50000, jenkins.getSlaveAgentPort());
assertEquals(1, jenkins.getNodes().size());
assertEquals("static-agent", jenkins.getNode("static-agent").getNodeName());
final GitTool.DescriptorImpl gitTool = (GitTool.DescriptorImpl) jenkins.getDescriptor(GitTool.class);
assertEquals(1, gitTool.getInstallations().length);
List<BasicSSHUserPrivateKey> sshPrivateKeys = CredentialsProvider.lookupCredentials(BasicSSHUserPrivateKey.class, jenkins, ACL.SYSTEM, Collections.emptyList());
assertThat(sshPrivateKeys, hasSize(1));
final BasicSSHUserPrivateKey ssh_with_passphrase = sshPrivateKeys.get(0);
assertThat(ssh_with_passphrase.getPassphrase().getPlainText(), equalTo("ABCD"));
final DirectEntryPrivateKeySource source = (DirectEntryPrivateKeySource) ssh_with_passphrase.getPrivateKeySource();
assertThat(source.getPrivateKey().getPlainText(), equalTo("s3cr3t"));
}
use of hudson.security.LDAPSecurityRealm in project configuration-as-code-plugin by jenkinsci.
the class LDAPSecurityRealmTest method configure_securityRealm.
@Test
@ConfiguredWithCode("LDAPSecurityRealmTest.yml")
public void configure_securityRealm() {
final Jenkins jenkins = Jenkins.getInstance();
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());
}
use of hudson.security.LDAPSecurityRealm in project configuration-as-code-plugin by jenkinsci.
the class TopReadmeTest method configure_demo_second_code_block.
@Test
@ConfiguredWithReadme("README.md#1")
public void configure_demo_second_code_block() {
final Jenkins jenkins = Jenkins.get();
final LDAPSecurityRealm securityRealm = (LDAPSecurityRealm) jenkins.getSecurityRealm();
assertEquals(1, securityRealm.getConfigurations().size());
}
Aggregations