use of com.thoughtworks.go.config.SecurityConfig in project gocd by gocd.
the class UserSearchServiceTest method shouldSearchUserUsingPlugins.
@Test
public void shouldSearchUserUsingPlugins() throws Exception {
final String searchTerm = "foo";
List<String> pluginIds = asList("plugin-id-1", "plugin-id-2", "plugin-id-3", "plugin-id-4");
addPluginSupportingUserSearch(pluginIds.get(0));
addPluginSupportingUserSearch(pluginIds.get(1));
addPluginSupportingUserSearch(pluginIds.get(2));
addPluginSupportingUserSearch(pluginIds.get(3));
when(authorizationExtension.canHandlePlugin(anyString())).thenReturn(true);
when(goConfigService.security()).thenReturn(new SecurityConfig());
when(authorizationExtension.searchUsers("plugin-id-1", searchTerm, Collections.emptyList())).thenReturn(asList(getPluginUser(1)));
when(authorizationExtension.searchUsers("plugin-id-2", searchTerm, Collections.emptyList())).thenReturn(asList(getPluginUser(2), getPluginUser(3)));
when(authorizationExtension.searchUsers("plugin-id-3", searchTerm, Collections.emptyList())).thenReturn(new ArrayList<>());
when(authorizationExtension.searchUsers("plugin-id-4", searchTerm, Collections.emptyList())).thenReturn(asList(new User("username-" + 4, null, null)));
List<UserSearchModel> models = userSearchService.search(searchTerm, new HttpLocalizedOperationResult());
assertThat(models, Matchers.containsInAnyOrder(new UserSearchModel(getUser(1), UserSourceType.PLUGIN), new UserSearchModel(getUser(2), UserSourceType.PLUGIN), new UserSearchModel(getUser(3), UserSourceType.PLUGIN), new UserSearchModel(new com.thoughtworks.go.domain.User("username-" + 4, "", ""), UserSourceType.PLUGIN)));
}
use of com.thoughtworks.go.config.SecurityConfig in project gocd by gocd.
the class DiskSpaceWarningCheckerTest method shouldUseWarningLimit.
@Test
public void shouldUseWarningLimit() {
new SystemEnvironment().setProperty(SystemEnvironment.ARTIFACT_WARNING_SIZE_LIMIT, "1M");
CruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setServerConfig(new ServerConfig(".", new SecurityConfig()));
ArtifactsDiskSpaceWarningChecker fullChecker = new ArtifactsDiskSpaceWarningChecker(new SystemEnvironment(), sender, goConfigService, new SystemDiskSpaceChecker(), serverHealthService);
assertThat(fullChecker.limitInMb(), is(1L));
}
use of com.thoughtworks.go.config.SecurityConfig in project gocd by gocd.
the class DiskSpaceFullCheckerTest method simulateFullDisk.
private CruiseConfig simulateFullDisk() {
new SystemEnvironment().setProperty(SystemEnvironment.ARTIFACT_FULL_SIZE_LIMIT, "1200009M");
CruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setServerConfig(new ServerConfig(".", new SecurityConfig()));
return cruiseConfig;
}
use of com.thoughtworks.go.config.SecurityConfig in project gocd by gocd.
the class DiskSpaceFullCheckerTest method shouldReturnTrueIfTheArtifactFolderHasSizeLimit.
@Test
public void shouldReturnTrueIfTheArtifactFolderHasSizeLimit() {
new SystemEnvironment().setProperty(SystemEnvironment.ARTIFACT_FULL_SIZE_LIMIT, "1M");
CruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setServerConfig(new ServerConfig(".", new SecurityConfig()));
ArtifactsDiskSpaceFullChecker fullChecker = createChecker(cruiseConfig);
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
fullChecker.check(result);
assertThat(result.canContinue(), is(true));
}
use of com.thoughtworks.go.config.SecurityConfig in project gocd by gocd.
the class SecurityAuthConfigServiceTest method shouldReturnAMapOfSecurityAuthConfigs.
@Test
public void shouldReturnAMapOfSecurityAuthConfigs() throws Exception {
SecurityAuthConfig authConfig = new SecurityAuthConfig("ldap", "cd.go.ldap");
SecurityConfig securityConfig = new SecurityConfig();
securityConfig.securityAuthConfigs().add(authConfig);
when(goConfigService.security()).thenReturn(securityConfig);
HashMap<String, SecurityAuthConfig> expectedMap = new HashMap<>();
expectedMap.put("ldap", authConfig);
Map<String, SecurityAuthConfig> authConfigMap = securityAuthConfigService.listAll();
assertThat(authConfigMap.size(), is(1));
assertThat(authConfigMap, is(expectedMap));
}
Aggregations