Search in sources :

Example 21 with SecurityConfig

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)));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) User(com.thoughtworks.go.plugin.domain.authorization.User) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) UserSearchModel(com.thoughtworks.go.presentation.UserSearchModel) Test(org.junit.jupiter.api.Test)

Example 22 with SecurityConfig

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));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ServerConfig(com.thoughtworks.go.config.ServerConfig) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.jupiter.api.Test)

Example 23 with SecurityConfig

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;
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ServerConfig(com.thoughtworks.go.config.ServerConfig) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig)

Example 24 with SecurityConfig

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));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ServerConfig(com.thoughtworks.go.config.ServerConfig) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.jupiter.api.Test)

Example 25 with SecurityConfig

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));
}
Also used : SecurityAuthConfig(com.thoughtworks.go.config.SecurityAuthConfig) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) Test(org.junit.jupiter.api.Test)

Aggregations

SecurityConfig (com.thoughtworks.go.config.SecurityConfig)28 Test (org.junit.jupiter.api.Test)9 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)6 LdapConfig (com.thoughtworks.go.config.LdapConfig)5 SecurityAuthConfig (com.thoughtworks.go.config.SecurityAuthConfig)5 Before (org.junit.Before)5 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)4 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)4 PasswordFileConfig (com.thoughtworks.go.config.PasswordFileConfig)4 ServerConfig (com.thoughtworks.go.config.ServerConfig)4 AuthorizationExtension (com.thoughtworks.go.plugin.access.authorization.AuthorizationExtension)4 Test (org.junit.Test)4 AuthorityGranter (com.thoughtworks.go.server.security.AuthorityGranter)3 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)3 UserSearchModel (com.thoughtworks.go.presentation.UserSearchModel)2 GoCipher (com.thoughtworks.go.security.GoCipher)2 PluginRoleService (com.thoughtworks.go.server.service.PluginRoleService)2 UserService (com.thoughtworks.go.server.service.UserService)2 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)2 FilterChain (javax.servlet.FilterChain)2