use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class PluginProfileCommandTest method shouldNotContinueWithConfigSaveIfUserIsUnauthorized.
@Test
public void shouldNotContinueWithConfigSaveIfUserIsUnauthorized() throws Exception {
SecurityAuthConfig securityAuthConfig = new SecurityAuthConfig("ldap", "cd.go.ldap");
when(goConfigService.isUserAdmin(currentUser)).thenReturn(false);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
PluginProfileCommand command = new StubSecurityAuthConfigCommand(goConfigService, securityAuthConfig, currentUser, result);
assertThat(cruiseConfig.server().security().securityAuthConfigs().find("foo"), nullValue());
assertThat(command.canContinue(cruiseConfig), is(false));
assertThat(result.toString(), containsString("UNAUTHORIZED_TO_EDIT"));
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class PluginProfileCommandTest method shouldValidateIfSecurityAuthConfigIdIsNull.
@Test
public void shouldValidateIfSecurityAuthConfigIdIsNull() {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
SecurityAuthConfig securityAuthConfig = new SecurityAuthConfig(null, "some-plugin", new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value")));
cruiseConfig.server().security().securityAuthConfigs().add(securityAuthConfig);
PluginProfileCommand command = new StubSecurityAuthConfigCommand(goConfigService, securityAuthConfig, currentUser, result);
thrown.expectMessage("some foo object id cannot be null.");
command.isValid(cruiseConfig);
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class PluginProfileCommandTest method shouldContinueWithConfigSaveIfUserIsAuthorized.
@Test
public void shouldContinueWithConfigSaveIfUserIsAuthorized() throws Exception {
SecurityAuthConfig securityAuthConfig = new SecurityAuthConfig("ldap", "cd.go.ldap");
when(goConfigService.isUserAdmin(currentUser)).thenReturn(true);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
PluginProfileCommand command = new StubSecurityAuthConfigCommand(goConfigService, securityAuthConfig, currentUser, result);
assertThat(cruiseConfig.server().security().securityAuthConfigs().find("ldap"), nullValue());
assertThat(command.canContinue(cruiseConfig), is(true));
assertThat(result.httpCode(), is(200));
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class PluginProfileCommandTest method shouldContinueWithConfigSaveIfUserIsAdmin.
@Test
public void shouldContinueWithConfigSaveIfUserIsAdmin() throws Exception {
SecurityAuthConfig securityAuthConfig = new SecurityAuthConfig("ldap", "cd.go.ldap");
when(goConfigService.isUserAdmin(currentUser)).thenReturn(true);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
PluginProfileCommand command = new StubSecurityAuthConfigCommand(goConfigService, securityAuthConfig, currentUser, result);
assertThat(cruiseConfig.server().security().securityAuthConfigs().find("ldap"), nullValue());
assertThat(command.canContinue(cruiseConfig), is(true));
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class RoleConfigCommandTest method shouldContinueWithConfigSaveIfUserIsAuthorized.
@Test
public void shouldContinueWithConfigSaveIfUserIsAuthorized() throws Exception {
PluginRoleConfig role = new PluginRoleConfig("blackbird", "ldap");
when(goConfigService.isUserAdmin(currentUser)).thenReturn(true);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
RoleConfigCommand command = new StubCommand(goConfigService, role, extension, currentUser, result);
assertThat(cruiseConfig.server().security().securityAuthConfigs().find("ldap"), nullValue());
assertThat(command.canContinue(cruiseConfig), is(true));
assertThat(result.httpCode(), is(200));
}
Aggregations