use of com.thoughtworks.go.config.PluginRoleConfig in project gocd by gocd.
the class RoleConfigCreateCommandTest method update_shouldAddPluginRoleConfigToRoles.
@Test
public void update_shouldAddPluginRoleConfigToRoles() throws Exception {
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
PluginRoleConfig role = new PluginRoleConfig("blackbird", "ldap");
RoleConfigCreateCommand command = new RoleConfigCreateCommand(null, role, null, null);
command.update(cruiseConfig);
assertThat(cruiseConfig.server().security().getRoles().findByName(new CaseInsensitiveString("blackbird")), equalTo(role));
}
use of com.thoughtworks.go.config.PluginRoleConfig in project gocd by gocd.
the class RoleConfigUpdateCommandTest method shouldNotContinueIfExistingRoleIsDeleted.
@Test
public void shouldNotContinueIfExistingRoleIsDeleted() throws Exception {
PluginRoleConfig updatedRole = new PluginRoleConfig("foo", "github");
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
when(goConfigService.isUserAdmin(currentUser)).thenReturn(true);
RoleConfigCommand command = new RoleConfigUpdateCommand(goConfigService, updatedRole, null, currentUser, result, entityHashingService, "bad-md5");
assertThat(command.canContinue(cruiseConfig), is(false));
assertFalse(result.isSuccessful());
assertThat(result.httpCode(), is(404));
}
use of com.thoughtworks.go.config.PluginRoleConfig in project gocd by gocd.
the class SecurityAuthConfigDeleteCommandTest method shouldNotValidateIfProfileIsInUseByRole.
@Test
public void shouldNotValidateIfProfileIsInUseByRole() throws Exception {
SecurityAuthConfig authConfig = new SecurityAuthConfig("foo", "ldap");
cruiseConfig.server().security().addRole(new PluginRoleConfig("blackbird", "foo"));
SecurityAuthConfigDeleteCommand command = new SecurityAuthConfigDeleteCommand(null, authConfig, null, null, new HttpLocalizedOperationResult());
thrown.expect(GoConfigInvalidException.class);
thrown.expectMessage("The security auth config 'foo' is being referenced by role(s): blackbird.");
command.isValid(cruiseConfig);
}
use of com.thoughtworks.go.config.PluginRoleConfig in project gocd by gocd.
the class AuthorizationMessageConverterV1 method getProcessRoleConfigsResponseBody.
@Override
public String getProcessRoleConfigsResponseBody(List<PluginRoleConfig> roles) {
List<Map> list = new ArrayList<>();
for (PluginRoleConfig role : roles) {
LinkedHashMap<String, Object> e = new LinkedHashMap<>();
e.put("name", role.getName().toString());
e.put("configuration", role.getConfigurationAsMap(true));
list.add(e);
}
return GSON.toJson(list);
}
use of com.thoughtworks.go.config.PluginRoleConfig in project gocd by gocd.
the class RoleConfigurationValidatorTest method shouldAddConfigurationAndMapErrorsInAbsenceOfConfiguration.
@Test
public void shouldAddConfigurationAndMapErrorsInAbsenceOfConfiguration() throws Exception {
ConfigurationProperty property = new ConfigurationProperty(new ConfigurationKey("username"), new ConfigurationValue("view"));
PluginRoleConfig roleConfig = new PluginRoleConfig("admin", "auth_id", property);
ValidationResult result = new ValidationResult();
result.addError(new ValidationError("password", "password is required"));
when(extension.validateRoleConfiguration("pluginId", Collections.singletonMap("username", "view"))).thenReturn(result);
validator.validate(roleConfig, "pluginId");
assertTrue(roleConfig.hasErrors());
assertThat(roleConfig.getProperty("password").errors().get("password").get(0), is("password is required"));
assertNull(roleConfig.getProperty("password").getValue());
}
Aggregations