Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-45431] Updated after review
  • Loading branch information
fcojfernandez committed Aug 30, 2017
1 parent 4b856d3 commit b32622d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 43 deletions.
31 changes: 0 additions & 31 deletions src/test/java/hudson/security/LDAPEmbeddedTest.java
Expand Up @@ -489,35 +489,4 @@ public void validate() throws Exception {
assertThat("Always report outer kind as OK", validation.kind, is(FormValidation.Kind.OK));
}

@Test
@LDAPSchema(ldif = "planetexpress", id = "planetexpress", dn = "dc=planetexpress,dc=com")
public void usingEnvironmentProperties() throws Exception {
LDAPConfiguration c = new LDAPConfiguration(ads.getUrl(), "", false, "uid=admin,ou=system", Secret.fromString("pass"));

LDAPSecurityRealm.EnvironmentProperty[] environmentProperties = {new LDAPSecurityRealm.EnvironmentProperty("java.naming.ldap.typesOnly", "true")};
c.setEnvironmentProperties(environmentProperties);

List<LDAPConfiguration> configurations = new ArrayList<LDAPConfiguration>();
configurations.add(c);
LDAPSecurityRealm realm = new LDAPSecurityRealm(
configurations,
false,
new LDAPSecurityRealm.CacheConfiguration(100, 1000),
IdStrategy.CASE_INSENSITIVE,
IdStrategy.CASE_INSENSITIVE
);

r.jenkins.setSecurityRealm(realm);
r.submit(r.createWebClient().goTo("configureSecurity").getFormByName("config"));
//r.configRoundtrip();

try {
r.createWebClient().login("fry", "fry");
fail("Should not be able to login");
} catch (FailingHttpStatusCodeException e) {
System.out.println("Got a bad login==good");
}
}


}
24 changes: 12 additions & 12 deletions src/test/java/hudson/security/LDAPSecurityRealmTest.java
Expand Up @@ -464,19 +464,19 @@ public void configRoundTripEnvironmentProperties() throws Exception {

LDAPSecurityRealm newRealm = (LDAPSecurityRealm) r.jenkins.getSecurityRealm();
assertNotSame(realm, newRealm);
LDAPConfiguration config = newRealm.getConfigurations().get(0);
assertEquals(server, config.getServer());
assertEquals(rootDN, config.getRootDN());
assertEquals(userSearchBase, config.getUserSearchBase());
assertEquals(managerDN, config.getManagerDN());
assertEquals(managerSecret, config.getManagerPassword());
LDAPConfiguration newConfig = newRealm.getConfigurations().get(0);
assertEquals(server, newConfig.getServer());
assertEquals(rootDN, newConfig.getRootDN());
assertEquals(userSearchBase, newConfig.getUserSearchBase());
assertEquals(managerDN, newConfig.getManagerDN());
assertEquals(managerSecret, newConfig.getManagerPassword());
assertThat(newRealm.getUserIdStrategy(), instanceOf(IdStrategy.CaseInsensitive.class));
assertEquals(LDAPSecurityRealm.DescriptorImpl.DEFAULT_USER_SEARCH, config.getUserSearch());
assertEquals(LDAPSecurityRealm.DescriptorImpl.DEFAULT_DISPLAYNAME_ATTRIBUTE_NAME, config.getDisplayNameAttributeName());
assertEquals(LDAPSecurityRealm.DescriptorImpl.DEFAULT_MAILADDRESS_ATTRIBUTE_NAME, config.getMailAddressAttributeName());
assertTrue(config.getEnvironmentProperties().length > 0);
assertEquals(config.getEnvironmentProperties()[0].getName(), c.getEnvironmentProperties()[0].getName());
assertEquals(config.getEnvironmentProperties()[0].getValue(), c.getEnvironmentProperties()[0].getValue());
assertEquals(LDAPSecurityRealm.DescriptorImpl.DEFAULT_USER_SEARCH, newConfig.getUserSearch());
assertEquals(LDAPSecurityRealm.DescriptorImpl.DEFAULT_DISPLAYNAME_ATTRIBUTE_NAME, newConfig.getDisplayNameAttributeName());
assertEquals(LDAPSecurityRealm.DescriptorImpl.DEFAULT_MAILADDRESS_ATTRIBUTE_NAME, newConfig.getMailAddressAttributeName());
assertTrue(newConfig.getEnvironmentProperties().length > 0);
assertEquals(newConfig.getEnvironmentProperties()[0].getName(), c.getEnvironmentProperties()[0].getName());
assertEquals(newConfig.getEnvironmentProperties()[0].getValue(), c.getEnvironmentProperties()[0].getValue());
}


Expand Down

0 comments on commit b32622d

Please sign in to comment.