Skip to content

Commit

Permalink
Merge pull request #5970 from davidwatkins73/waltz-5969-fix
Browse files Browse the repository at this point in the history
Removing redundant failing test
  • Loading branch information
davidwatkins73 authored Mar 13, 2022
2 parents ae40295 + 8b9adfd commit 0252311
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,6 @@ public void basicRetrieval() {
}


@Test
public void cannotAttestIfNotAssociated() {
String user = mkUserId("cannotAttestIfNotAssociated");
EntityReference appRef = mkNewAppRef();

AttestEntityCommand cmd = ImmutableAttestEntityCommand.builder()
.attestedEntityKind(EntityKind.LOGICAL_DATA_FLOW)
.entityReference(appRef)
.build();

assertThrows(
UpdateFailedException.class,
() -> aiSvc.attestForEntity(user, cmd),
"Should not be able to attest as user not associated to app");
}


@Test
public void cannotAttestIfNoFlows() {
long invId = involvementHelper.mkInvolvementKind(mkName("cannotAttestIfNoFlows"));
Expand All @@ -172,7 +155,7 @@ public void cannotAttestIfNoFlows() {
.build();

assertThrows(
Exception.class,
IllegalArgumentException.class,
() -> aiSvc.attestForEntity(user, cmd),
"Should not be able to attest as no flows");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.finos.waltz.model.attestation.*;
import org.finos.waltz.model.changelog.ImmutableChangeLog;
import org.finos.waltz.model.external_identifier.ExternalIdValue;
import org.finos.waltz.model.permission_group.CheckPermissionCommand;
import org.finos.waltz.model.permission_group.ImmutableCheckPermissionCommand;
import org.finos.waltz.model.person.Person;
import org.finos.waltz.service.application.ApplicationService;
Expand Down Expand Up @@ -188,7 +189,7 @@ private void logChange(String username, AttestationInstance instance, EntityKind
public boolean attestForEntity(String username, AttestEntityCommand createCommand) {
checkAttestationPermission(username, createCommand);

if(createCommand.attestedEntityKind().equals(EntityKind.LOGICAL_DATA_FLOW)){
if(createCommand.attestedEntityKind() == EntityKind.LOGICAL_DATA_FLOW){
checkLogicalFlowsCanBeAttested(createCommand);
}

Expand Down Expand Up @@ -237,16 +238,16 @@ public Set<LatestMeasurableAttestationInfo> findLatestMeasurableAttestations(Ent

private void checkAttestationPermission(String username, AttestEntityCommand createCommand) {

boolean hasAttestationPermission = permissionGroupService.hasPermission(ImmutableCheckPermissionCommand
CheckPermissionCommand checkPermissionCommand = ImmutableCheckPermissionCommand
.builder()
.parentEntityRef(createCommand.entityReference())
.subjectKind(EntityKind.ATTESTATION)
.qualifierKind(createCommand.attestedEntityKind())
.qualifierId(createCommand.attestedEntityId())
.user(username)
.build());
.build();

if (!hasAttestationPermission) {
if (! permissionGroupService.hasPermission(checkPermissionCommand)) {
throw new UpdateFailedException("ATTESTATION_FAILED",
"user does not have permission to attest " + createCommand.attestedEntityKind().prettyName());
}
Expand Down

0 comments on commit 0252311

Please sign in to comment.