use of com.thoughtworks.go.server.service.EntityHashingService in project gocd by gocd.
the class RoleConfigUpdateCommandTest method shouldNotContinueWithConfigSaveIfRequestIsNotFresh.
@Test
public void shouldNotContinueWithConfigSaveIfRequestIsNotFresh() {
when(goConfigService.isUserAdmin(currentUser)).thenReturn(true);
PluginRoleConfig oldRole = new PluginRoleConfig("foo", "ldap");
PluginRoleConfig updatedRole = new PluginRoleConfig("foo", "github");
cruiseConfig.server().security().getRoles().add(oldRole);
EntityHashingService entityHashingService = mock(EntityHashingService.class);
when(entityHashingService.md5ForEntity(oldRole)).thenReturn("md5");
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
RoleConfigCommand command = new RoleConfigUpdateCommand(goConfigService, updatedRole, null, currentUser, result, entityHashingService, "bad-md5");
assertThat(command.canContinue(cruiseConfig), is(false));
assertThat(result.toString(), containsString("STALE_RESOURCE_CONFIG"));
}
use of com.thoughtworks.go.server.service.EntityHashingService in project gocd by gocd.
the class ElasticAgentProfileUpdateCommandTest method shouldNotContinueWithConfigSaveIfRequestIsNotFresh.
@Test
public void shouldNotContinueWithConfigSaveIfRequestIsNotFresh() {
when(goConfigService.isUserAdmin(currentUser)).thenReturn(true);
ElasticProfile oldProfile = new ElasticProfile("foo", "docker");
ElasticProfile newProfile = new ElasticProfile("foo", "aws");
cruiseConfig.server().getElasticConfig().getProfiles().add(oldProfile);
EntityHashingService entityHashingService = mock(EntityHashingService.class);
when(entityHashingService.md5ForEntity(oldProfile)).thenReturn("md5");
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
ElasticAgentProfileUpdateCommand command = new ElasticAgentProfileUpdateCommand(goConfigService, newProfile, null, currentUser, result, entityHashingService, "bad-md5");
assertThat(command.canContinue(cruiseConfig), is(false));
assertThat(result.toString(), containsString("STALE_RESOURCE_CONFIG"));
}
use of com.thoughtworks.go.server.service.EntityHashingService in project gocd by gocd.
the class SecurityAuthConfigUpdateCommandTest method shouldNotContinueWithConfigSaveIfRequestIsNotFresh.
@Test
public void shouldNotContinueWithConfigSaveIfRequestIsNotFresh() {
when(goConfigService.isUserAdmin(currentUser)).thenReturn(true);
SecurityAuthConfig oldAuthConfig = new SecurityAuthConfig("foo", "ldap");
SecurityAuthConfig newAuthConfig = new SecurityAuthConfig("foo", "github");
cruiseConfig.server().security().securityAuthConfigs().add(oldAuthConfig);
EntityHashingService entityHashingService = mock(EntityHashingService.class);
when(entityHashingService.md5ForEntity(oldAuthConfig)).thenReturn("md5");
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
SecurityAuthConfigUpdateCommand command = new SecurityAuthConfigUpdateCommand(goConfigService, newAuthConfig, null, currentUser, result, entityHashingService, "bad-md5");
assertThat(command.canContinue(cruiseConfig), is(false));
assertThat(result.toString(), containsString("STALE_RESOURCE_CONFIG"));
}
Aggregations