Search in sources :

Example 1 with PasswordFileConfig

use of com.thoughtworks.go.config.PasswordFileConfig in project gocd by gocd.

the class LdapConfigChangedListenerTest method shouldReinitializeDelegator_whenLdapManagerPasswordChanges.

@Test
public void shouldReinitializeDelegator_whenLdapManagerPasswordChanges() {
    LdapConfig oldLdapConfig = new LdapConfig("oldOne", "manager", "pwd", null, true, new BasesConfig(new BaseConfig("foo")), "bar");
    helper.addLdapSecurityWith(oldLdapConfig, true, new PasswordFileConfig(), new AdminsConfig());
    LdapContextFactory mockContextFactory = mock(LdapContextFactory.class);
    LdapConfigChangedListener listener = new LdapConfigChangedListener(oldLdapConfig, mockContextFactory);
    LdapConfig newLdapConfig = new LdapConfig("oldOne", "manager", "new_pwd", null, true, new BasesConfig(new BaseConfig("foo")), "bar");
    helper.addLdapSecurityWith(newLdapConfig, true, new PasswordFileConfig(), new AdminsConfig());
    listener.onConfigChange(helper.currentConfig());
    verify(mockContextFactory).initializeDelegator();
}
Also used : LdapConfig(com.thoughtworks.go.config.LdapConfig) BasesConfig(com.thoughtworks.go.config.server.security.ldap.BasesConfig) BaseConfig(com.thoughtworks.go.config.server.security.ldap.BaseConfig) PasswordFileConfig(com.thoughtworks.go.config.PasswordFileConfig) AdminsConfig(com.thoughtworks.go.config.AdminsConfig) Test(org.junit.Test)

Example 2 with PasswordFileConfig

use of com.thoughtworks.go.config.PasswordFileConfig in project gocd by gocd.

the class LdapConfigChangedListenerTest method shouldNotTriggerReintializeOfContextFactoryWhenLdapConfigDoesNotChange.

@Test
public void shouldNotTriggerReintializeOfContextFactoryWhenLdapConfigDoesNotChange() {
    LdapConfig oldLdapConfig = new LdapConfig("oldOne", "manager", "pwd", null, true, new BasesConfig(new BaseConfig("foo")), "bar");
    helper.addLdapSecurityWith(oldLdapConfig, true, new PasswordFileConfig(), new AdminsConfig());
    LdapContextFactory mockContextFactory = mock(LdapContextFactory.class);
    LdapConfigChangedListener listener = new LdapConfigChangedListener(oldLdapConfig, mockContextFactory);
    helper.addLdapSecurityWith(oldLdapConfig, true, new PasswordFileConfig(), new AdminsConfig());
    listener.onConfigChange(helper.currentConfig());
    verify(mockContextFactory, never()).initializeDelegator();
}
Also used : LdapConfig(com.thoughtworks.go.config.LdapConfig) BasesConfig(com.thoughtworks.go.config.server.security.ldap.BasesConfig) BaseConfig(com.thoughtworks.go.config.server.security.ldap.BaseConfig) PasswordFileConfig(com.thoughtworks.go.config.PasswordFileConfig) AdminsConfig(com.thoughtworks.go.config.AdminsConfig) Test(org.junit.Test)

Example 3 with PasswordFileConfig

use of com.thoughtworks.go.config.PasswordFileConfig in project gocd by gocd.

the class LdapContextFactoryTest method shouldNotInitializeDelegatorWhenAnLDAPConfigurationIsRemovedFromOurConfig.

@Test
public void shouldNotInitializeDelegatorWhenAnLDAPConfigurationIsRemovedFromOurConfig() {
    LdapContextFactory factory = new LdapContextFactory(goConfigService);
    when(goConfigService.security()).thenReturn(new SecurityConfig(new LdapConfig(goCipher), new PasswordFileConfig(), true));
    try {
        factory.initializeDelegator();
    } catch (Exception e) {
        e.printStackTrace();
        fail("should not have thrown an execption");
    }
    verify(goConfigService).security();
}
Also used : LdapConfig(com.thoughtworks.go.config.LdapConfig) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) PasswordFileConfig(com.thoughtworks.go.config.PasswordFileConfig) Test(org.junit.Test)

Example 4 with PasswordFileConfig

use of com.thoughtworks.go.config.PasswordFileConfig in project gocd by gocd.

the class FileAuthenticationProviderTest method setupFile.

private void setupFile(String userAndPasswordAndRoles) throws IOException {
    final File passwordFile = TestFileUtil.createTempFile("password.properties");
    passwordFile.deleteOnExit();
    FileUtils.writeStringToFile(passwordFile, userAndPasswordAndRoles);
    final SecurityConfig securityConfig = new SecurityConfig(new LdapConfig(new GoCipher()), new PasswordFileConfig(passwordFile.getAbsolutePath()), true, null);
    when(goConfigService.security()).thenReturn(securityConfig);
}
Also used : LdapConfig(com.thoughtworks.go.config.LdapConfig) GoCipher(com.thoughtworks.go.security.GoCipher) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) File(java.io.File) PasswordFileConfig(com.thoughtworks.go.config.PasswordFileConfig)

Example 5 with PasswordFileConfig

use of com.thoughtworks.go.config.PasswordFileConfig in project gocd by gocd.

the class FileAuthenticationProviderTest method shouldThrowExceptionIfFileDoesNotExist.

@Test(expected = UsernameNotFoundException.class)
public void shouldThrowExceptionIfFileDoesNotExist() throws Exception {
    when(goConfigService.security()).thenReturn(new SecurityConfig(new LdapConfig(new GoCipher()), new PasswordFileConfig("ueyrweiyri"), true, null));
    AuthorityGranter authorityGranter = new AuthorityGranter(securityService);
    FileAuthenticationProvider provider = new FileAuthenticationProvider(goConfigService, authorityGranter, userService, securityService);
    provider.retrieveUser("blah", null);
}
Also used : LdapConfig(com.thoughtworks.go.config.LdapConfig) AuthorityGranter(com.thoughtworks.go.server.security.AuthorityGranter) GoCipher(com.thoughtworks.go.security.GoCipher) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) PasswordFileConfig(com.thoughtworks.go.config.PasswordFileConfig) Test(org.junit.Test)

Aggregations

PasswordFileConfig (com.thoughtworks.go.config.PasswordFileConfig)7 LdapConfig (com.thoughtworks.go.config.LdapConfig)6 Test (org.junit.Test)6 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)4 AdminsConfig (com.thoughtworks.go.config.AdminsConfig)3 BaseConfig (com.thoughtworks.go.config.server.security.ldap.BaseConfig)3 BasesConfig (com.thoughtworks.go.config.server.security.ldap.BasesConfig)3 GoCipher (com.thoughtworks.go.security.GoCipher)2 AuthorityGranter (com.thoughtworks.go.server.security.AuthorityGranter)1 File (java.io.File)1 UsernamePasswordAuthenticationToken (org.springframework.security.providers.UsernamePasswordAuthenticationToken)1