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();
}
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();
}
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();
}
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);
}
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);
}
Aggregations