use of com.thoughtworks.go.plugin.access.PluginNotFoundException in project gocd by gocd.
the class SecurityAuthConfigServiceTest method verifyConnection_shouldFailInAbsenceOfPlugin.
@Test
public void verifyConnection_shouldFailInAbsenceOfPlugin() throws Exception {
SecurityAuthConfig ldap = new SecurityAuthConfig("ldap", "cd.go.ldap");
when(extension.verifyConnection("cd.go.ldap", ldap.getConfigurationAsMap(true))).thenThrow(new PluginNotFoundException(""));
VerifyConnectionResponse response = securityAuthConfigService.verifyConnection(ldap);
assertThat(response, is(new VerifyConnectionResponse("failure", "Unable to verify connection, missing plugin: cd.go.ldap", new com.thoughtworks.go.plugin.domain.common.ValidationResult())));
}
use of com.thoughtworks.go.plugin.access.PluginNotFoundException in project gocd by gocd.
the class SecurityAuthConfigServiceTest method shouldAddPluginNotFoundErrorOnConfigForANonExistentPluginId.
@Test
public void shouldAddPluginNotFoundErrorOnConfigForANonExistentPluginId() throws Exception {
SecurityAuthConfig securityAuthConfig = new SecurityAuthConfig("some-id", "non-existent-plugin", create("key", false, "value"));
Username username = new Username("username");
when(extension.validateAuthConfig(securityAuthConfig.getPluginId(), securityAuthConfig.getConfigurationAsMap(true))).thenThrow(new PluginNotFoundException("plugin not found"));
securityAuthConfigService.update(username, "md5", securityAuthConfig, new HttpLocalizedOperationResult());
assertThat(securityAuthConfig.errors().isEmpty(), is(false));
assertThat(securityAuthConfig.errors().on("pluginId"), is("Plugin with id `non-existent-plugin` is not found."));
}
use of com.thoughtworks.go.plugin.access.PluginNotFoundException in project gocd by gocd.
the class ElasticProfileServiceTest method shouldAddPluginNotFoundErrorOnConfigForANonExistentPluginIdWhileUpdating.
@Test
public void shouldAddPluginNotFoundErrorOnConfigForANonExistentPluginIdWhileUpdating() throws Exception {
ElasticProfile elasticProfile = new ElasticProfile("some-id", "non-existent-plugin", create("key", false, "value"));
Username username = new Username("username");
when(elasticAgentExtension.validate(elasticProfile.getPluginId(), elasticProfile.getConfigurationAsMap(true))).thenThrow(new PluginNotFoundException("some error"));
elasticProfileService.update(username, "md5", elasticProfile, new HttpLocalizedOperationResult());
assertThat(elasticProfile.errors().isEmpty(), Matchers.is(false));
assertThat(elasticProfile.errors().on("pluginId"), Matchers.is("Plugin with id `non-existent-plugin` is not found."));
}
use of com.thoughtworks.go.plugin.access.PluginNotFoundException in project gocd by gocd.
the class ElasticProfileServiceTest method shouldAddPluginNotFoundErrorOnConfigForANonExistentPluginIdWhileCreating.
@Test
public void shouldAddPluginNotFoundErrorOnConfigForANonExistentPluginIdWhileCreating() throws Exception {
ElasticProfile elasticProfile = new ElasticProfile("some-id", "non-existent-plugin", create("key", false, "value"));
Username username = new Username("username");
when(elasticAgentExtension.validate(elasticProfile.getPluginId(), elasticProfile.getConfigurationAsMap(true))).thenThrow(new PluginNotFoundException("some error"));
elasticProfileService.create(username, elasticProfile, new HttpLocalizedOperationResult());
assertThat(elasticProfile.errors().isEmpty(), Matchers.is(false));
assertThat(elasticProfile.errors().on("pluginId"), Matchers.is("Plugin with id `non-existent-plugin` is not found."));
}
use of com.thoughtworks.go.plugin.access.PluginNotFoundException in project gocd by gocd.
the class RoleConfigurationValidator method validate.
public void validate(PluginRoleConfig role, String pluginId) {
try {
ValidationResult result = authorizationExtension.validateRoleConfiguration(pluginId, role.getConfigurationAsMap(true));
if (!result.isSuccessful()) {
for (ValidationError error : result.getErrors()) {
ConfigurationProperty property = role.getProperty(error.getKey());
if (property == null) {
role.addNewConfiguration(error.getKey(), false);
property = role.getProperty(error.getKey());
}
property.addError(error.getKey(), error.getMessage());
}
}
} catch (PluginNotFoundException e) {
role.addError("pluginRole", String.format("Unable to validate `pluginRole` configuration, missing plugin: %s", pluginId));
}
}
Aggregations