Search in sources :

Example 1 with BasesConfig

use of com.thoughtworks.go.config.server.security.ldap.BasesConfig in project gocd by gocd.

the class SecurityConfigTest method shouldBeAbleToTellIfSecurityMethodChangedFromNothingToLdap.

@Test
public void shouldBeAbleToTellIfSecurityMethodChangedFromNothingToLdap() {
    SecurityConfig ldapSecurity = new SecurityConfig();
    ldapSecurity.modifyLdap(new LdapConfig("ldap://uri", "dn", "p", null, true, new BasesConfig(new BaseConfig("")), ""));
    assertTrue(new SecurityConfig().hasSecurityMethodChanged(ldapSecurity));
}
Also used : BasesConfig(com.thoughtworks.go.config.server.security.ldap.BasesConfig) BaseConfig(com.thoughtworks.go.config.server.security.ldap.BaseConfig) Test(org.junit.Test)

Example 2 with BasesConfig

use of com.thoughtworks.go.config.server.security.ldap.BasesConfig in project gocd by gocd.

the class LdapConfigTest method shouldConvertNullAttributesToEmptyStringUponConstruct.

@Test
public void shouldConvertNullAttributesToEmptyStringUponConstruct() {
    LdapConfig ldapConfig = new LdapConfig(null, null, null, null, false, new BasesConfig(), null);
    assertThat(ldapConfig.uri(), is(""));
    assertThat(ldapConfig.searchFilter(), is(""));
    assertThat(ldapConfig.currentManagerPassword(), is(""));
    assertThat(ldapConfig.isEnabled(), is(false));
}
Also used : BasesConfig(com.thoughtworks.go.config.server.security.ldap.BasesConfig) Test(org.junit.Test)

Example 3 with BasesConfig

use of com.thoughtworks.go.config.server.security.ldap.BasesConfig in project gocd by gocd.

the class LdapConfigTest method shouldConsiderTwoLdapConfigsWithDifferentPasswordsUnequal.

@Test
public void shouldConsiderTwoLdapConfigsWithDifferentPasswordsUnequal() {
    LdapConfig ldapConfig1 = new LdapConfig("uri", "managerDn", "password-1", null, true, new BasesConfig(new BaseConfig("blah")), "blah");
    LdapConfig ldapConfig2 = new LdapConfig("uri", "managerDn", "password-2", null, true, new BasesConfig(new BaseConfig("blah")), "blah");
    assertThat(ldapConfig1, is(Matchers.not(ldapConfig2)));
    assertThat(ldapConfig1.hashCode(), is(Matchers.not(ldapConfig2.hashCode())));
}
Also used : BasesConfig(com.thoughtworks.go.config.server.security.ldap.BasesConfig) BaseConfig(com.thoughtworks.go.config.server.security.ldap.BaseConfig) Test(org.junit.Test)

Example 4 with BasesConfig

use of com.thoughtworks.go.config.server.security.ldap.BasesConfig in project gocd by gocd.

the class GoConfigServiceTest method shouldUnderstandIfLdapIsConfigured.

@Test
public void shouldUnderstandIfLdapIsConfigured() throws Exception {
    CruiseConfig config = new BasicCruiseConfig();
    config.setServerConfig(new ServerConfig(null, new SecurityConfig(new LdapConfig("test", "test", "test", null, true, new BasesConfig(new BaseConfig("test")), "test"), null, true, null)));
    expectLoad(config);
    assertThat("Ldap is configured", goConfigService.isLdapConfigured(), is(true));
}
Also used : BasesConfig(com.thoughtworks.go.config.server.security.ldap.BasesConfig) BaseConfig(com.thoughtworks.go.config.server.security.ldap.BaseConfig) Test(org.junit.Test)

Example 5 with BasesConfig

use of com.thoughtworks.go.config.server.security.ldap.BasesConfig in project gocd by gocd.

the class GoConfigFileHelper method addLdapSecurity.

public void addLdapSecurity(String uri, String managerDn, String managerPassword, String searchBase, String searchFilter) {
    LdapConfig ldapConfig = new LdapConfig(uri, managerDn, managerPassword, null, true, new BasesConfig(new BaseConfig(searchBase)), searchFilter);
    addLdapSecurityWith(ldapConfig, true, new PasswordFileConfig(), new AdminsConfig());
}
Also used : BasesConfig(com.thoughtworks.go.config.server.security.ldap.BasesConfig) BaseConfig(com.thoughtworks.go.config.server.security.ldap.BaseConfig)

Aggregations

BasesConfig (com.thoughtworks.go.config.server.security.ldap.BasesConfig)35 Test (org.junit.Test)33 BaseConfig (com.thoughtworks.go.config.server.security.ldap.BaseConfig)30 LdapConfig (com.thoughtworks.go.config.LdapConfig)14 FilterBasedLdapUserSearch (org.springframework.security.ldap.search.FilterBasedLdapUserSearch)10 DirContextOperations (org.springframework.ldap.core.DirContextOperations)6 UsernameNotFoundException (org.springframework.security.userdetails.UsernameNotFoundException)6 GoCipher (com.thoughtworks.go.security.GoCipher)4 AdminsConfig (com.thoughtworks.go.config.AdminsConfig)3 PasswordFileConfig (com.thoughtworks.go.config.PasswordFileConfig)3 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)2 SearchControls (javax.naming.directory.SearchControls)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 AttributesMapperCallbackHandler (org.springframework.ldap.core.AttributesMapperCallbackHandler)2 DefaultSpringSecurityContextSource (org.springframework.security.ldap.DefaultSpringSecurityContextSource)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1 AbstractContextSource (org.springframework.ldap.core.support.AbstractContextSource)1