Skip to content

Commit

Permalink
add clamAV to local env; make delete attachment idempotent
Browse files Browse the repository at this point in the history
  • Loading branch information
mafasva committed Sep 16, 2024
1 parent 40bc1c1 commit 7872603
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
19 changes: 15 additions & 4 deletions local-env/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
volumes:
- ./keycloak.conf:/opt/keycloak/conf/keycloak.conf
ports:
- 8180:8080
- "8180:8080"
networks:
- num-portal
depends_on:
Expand All @@ -23,7 +23,7 @@ services:
image: postgres:16.2
restart: always
ports:
- 5432:5432
- "5432:5432"
networks:
- num-portal
environment:
Expand All @@ -35,7 +35,7 @@ services:
image: dpage/pgadmin4:8.9
restart: always
ports:
- 8888:80
- "8888:80"
networks:
- num-portal
environment:
Expand All @@ -48,7 +48,7 @@ services:
ehrbase:
image: ehrbase/ehrbase:2.5.0
ports:
- 8080:8080
- "8080:8080"
networks:
- num-portal
env_file:
Expand All @@ -62,10 +62,21 @@ services:
DB_PASS: ${DB_PASS}
depends_on:
- postgres
clamav:
image: clamav/clamav:1.3.2
container_name: clamav
ports:
- "3310:3310"
volumes:
- clamav-db:/var/lib/clamav
environment:
- CLAMD_CONF_FILE=/etc/clamav/clamd.conf
- FRESHCLAM_CONF_FILE=/etc/clamav/freshclam.conf

volumes:
pgdata:
pgadmin-data:
clamav-db:
networks:
num-portal:
driver: bridge
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ public void deleteAttachments(Set<Long> attachmentsId, Long projectId, String lo
for(Long attachmentId : attachmentsId) {
Optional<Attachment> attachment = attachmentRepository.findByIdAndProjectId(attachmentId, projectId);
if(attachment.isEmpty()) {
throw new ResourceNotFound(AttachmentService.class, "Attachment not found", String.format("Attachment not found: %s", attachmentId));
log.info("Attachment is already deleted, attachment: {}, project: {}", attachmentId, projectId);
return;
}
Attachment currentAttachment = attachment.get();
if (Boolean.FALSE.equals(userIsApprover) && currentAttachment.getReviewCounter() > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@ public void deleteAttachmentsTest() {
Mockito.verify(attachmentRepository, Mockito.times(2)).deleteAttachment(Mockito.anyLong());
}

@Test(expected = ResourceNotFound.class)
public void deleteAttachmentsAndExpectResourceNotFoundTest() {
attachmentService.deleteAttachments(Set.of(3L), 9L, "loggedInUser", true);
}

@Test(expected = ForbiddenException.class)
public void deleteAttachmentsHandleReviewCounterExceededTest() {
Attachment one = Attachment.builder()
Expand Down

0 comments on commit 7872603

Please sign in to comment.