Search in sources :

Example 76 with SecurityAuthConfig

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

the class SecurityAuthConfigServiceTest method shouldPerformPluginValidationsBeforeUpdatingSecurityAuthConfig.

@Test
public void shouldPerformPluginValidationsBeforeUpdatingSecurityAuthConfig() {
    SecurityAuthConfig securityAuthConfig = new SecurityAuthConfig("ldap", "cd.go.ldap", create("key", false, "value"));
    Username username = new Username("username");
    securityAuthConfigService.update(username, "md5", securityAuthConfig, new HttpLocalizedOperationResult());
    verify(extension).validateAuthConfig(securityAuthConfig.getPluginId(), securityAuthConfig.getConfigurationAsMap(true));
}
Also used : SecurityAuthConfig(com.thoughtworks.go.config.SecurityAuthConfig) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.jupiter.api.Test)

Example 77 with SecurityAuthConfig

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

the class SecurityAuthConfigServiceTest method verifyConnection_shouldSendSuccessResponseOnSuccessfulVerification.

@Test
public void verifyConnection_shouldSendSuccessResponseOnSuccessfulVerification() throws Exception {
    VerifyConnectionResponse success = new VerifyConnectionResponse("success", "Connection check passed", new ValidationResult());
    SecurityAuthConfig ldap = new SecurityAuthConfig("ldap", "cd.go.ldap");
    when(extension.verifyConnection("cd.go.ldap", ldap.getConfigurationAsMap(true))).thenReturn(success);
    VerifyConnectionResponse response = securityAuthConfigService.verifyConnection(ldap);
    assertThat(response, is(success));
}
Also used : VerifyConnectionResponse(com.thoughtworks.go.plugin.domain.common.VerifyConnectionResponse) SecurityAuthConfig(com.thoughtworks.go.config.SecurityAuthConfig) ValidationResult(com.thoughtworks.go.plugin.domain.common.ValidationResult) Test(org.junit.jupiter.api.Test)

Example 78 with SecurityAuthConfig

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

the class SecurityAuthConfigServiceTest method shouldNotPerformPluginValidationsWhenDeletingSecurityAuthConfig.

@Test
public void shouldNotPerformPluginValidationsWhenDeletingSecurityAuthConfig() {
    SecurityAuthConfig securityAuthConfig = new SecurityAuthConfig("ldap", "cd.go.ldap", create("key", false, "value"));
    Username username = new Username("username");
    securityAuthConfigService.delete(username, securityAuthConfig, new HttpLocalizedOperationResult());
    verify(extension, never()).validateAuthConfig(securityAuthConfig.getPluginId(), securityAuthConfig.getConfigurationAsMap(true));
}
Also used : SecurityAuthConfig(com.thoughtworks.go.config.SecurityAuthConfig) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.jupiter.api.Test)

Example 79 with SecurityAuthConfig

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

the class SecurityAuthConfigServiceTest method shouldUpdateExistingSecurityAuthConfigInConfig.

@Test
public void shouldUpdateExistingSecurityAuthConfigInConfig() {
    SecurityAuthConfig securityAuthConfig = new SecurityAuthConfig("ldap", "cd.go.ldap");
    Username username = new Username("username");
    securityAuthConfigService.update(username, "md5", securityAuthConfig, new HttpLocalizedOperationResult());
    verify(goConfigService).updateConfig(any(SecurityAuthConfigUpdateCommand.class), eq(username));
}
Also used : SecurityAuthConfig(com.thoughtworks.go.config.SecurityAuthConfig) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) SecurityAuthConfigUpdateCommand(com.thoughtworks.go.config.update.SecurityAuthConfigUpdateCommand) Test(org.junit.jupiter.api.Test)

Example 80 with SecurityAuthConfig

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

the class SecurityAuthConfigServiceTest method shouldDeleteExistingSecurityAuthConfigInConfig.

@Test
public void shouldDeleteExistingSecurityAuthConfigInConfig() {
    SecurityAuthConfig securityAuthConfig = new SecurityAuthConfig("ldap", "cd.go.ldap");
    Username username = new Username("username");
    securityAuthConfigService.delete(username, securityAuthConfig, new HttpLocalizedOperationResult());
    verify(goConfigService).updateConfig(any(SecurityAuthConfigDeleteCommand.class), eq(username));
}
Also used : SecurityAuthConfigDeleteCommand(com.thoughtworks.go.config.update.SecurityAuthConfigDeleteCommand) SecurityAuthConfig(com.thoughtworks.go.config.SecurityAuthConfig) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.jupiter.api.Test)

Aggregations

SecurityAuthConfig (com.thoughtworks.go.config.SecurityAuthConfig)81 Test (org.junit.jupiter.api.Test)46 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)28 Test (org.junit.Test)16 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)14 AuthenticationResponse (com.thoughtworks.go.plugin.access.authorization.models.AuthenticationResponse)14 User (com.thoughtworks.go.plugin.access.authorization.models.User)11 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)9 Username (com.thoughtworks.go.server.domain.Username)9 UserDetails (org.springframework.security.userdetails.UserDetails)8 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)7 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)5 VerifyConnectionResponse (com.thoughtworks.go.plugin.domain.common.VerifyConnectionResponse)5 UsernamePasswordAuthenticationToken (org.springframework.security.providers.UsernamePasswordAuthenticationToken)5 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)4 SecurityAuthConfigs (com.thoughtworks.go.config.SecurityAuthConfigs)4 RecordNotFoundException (com.thoughtworks.go.config.exceptions.RecordNotFoundException)4 DefaultGoPluginApiResponse (com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse)4 ValidationResult (com.thoughtworks.go.plugin.domain.common.ValidationResult)4 GoUserPrinciple (com.thoughtworks.go.server.security.userdetail.GoUserPrinciple)4