Search in sources :

Example 26 with PluginRoleConfig

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

the class RoleConfigurationValidatorTest method shouldAddErrorsInAbsenceOfPlugin.

@Test
public void shouldAddErrorsInAbsenceOfPlugin() throws Exception {
    ConfigurationProperty property = new ConfigurationProperty(new ConfigurationKey("username"), new ConfigurationValue("view"));
    PluginRoleConfig roleConfig = new PluginRoleConfig("admin", "auth_id", property);
    when(extension.validateRoleConfiguration("pluginId", Collections.singletonMap("username", "view"))).thenThrow(new PluginNotFoundException("not found"));
    validator.validate(roleConfig, "pluginId");
    assertTrue(roleConfig.hasErrors());
    assertThat(roleConfig.errors().get("pluginRole").get(0), is("Unable to validate `pluginRole` configuration, missing plugin: pluginId"));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) PluginNotFoundException(com.thoughtworks.go.plugin.access.PluginNotFoundException) PluginRoleConfig(com.thoughtworks.go.config.PluginRoleConfig) Test(org.junit.Test)

Aggregations

PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)26 Test (org.junit.Test)22 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 SecurityAuthConfig (com.thoughtworks.go.config.SecurityAuthConfig)8 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)8 AuthenticationResponse (com.thoughtworks.go.plugin.access.authorization.models.AuthenticationResponse)6 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)4 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)4 User (com.thoughtworks.go.plugin.access.authorization.models.User)4 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)4 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)3 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)3 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)3 AllowedUsers (com.thoughtworks.go.config.security.users.AllowedUsers)2 Users (com.thoughtworks.go.config.security.users.Users)2 ProjectStatus (com.thoughtworks.go.domain.activity.ProjectStatus)2 PreAuthenticatedAuthenticationToken (com.thoughtworks.go.server.security.tokens.PreAuthenticatedAuthenticationToken)2 GoUserPrinciple (com.thoughtworks.go.server.security.userdetail.GoUserPrinciple)2 HashedMap (org.apache.commons.collections.map.HashedMap)2 UserDetails (org.springframework.security.userdetails.UserDetails)2