diff --git a/pom.xml b/pom.xml index 7f81cde0..b6e28389 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 2.6.4 + 2.6.5 @@ -57,7 +57,8 @@ 2021.0.1 2.1.210 5.6.5.Final - 1.3.0 + 1.3.1 + 2.13.2.1 3.3.0 3.1.2 @@ -266,6 +267,12 @@ shedlock-spring ${shedlock.version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.databind.version} + diff --git a/src/main/java/eu/europa/ec/dgc/gateway/repository/SignerInformationRepository.java b/src/main/java/eu/europa/ec/dgc/gateway/repository/SignerInformationRepository.java index 121992cf..5dc1dbae 100644 --- a/src/main/java/eu/europa/ec/dgc/gateway/repository/SignerInformationRepository.java +++ b/src/main/java/eu/europa/ec/dgc/gateway/repository/SignerInformationRepository.java @@ -52,16 +52,16 @@ public interface SignerInformationRepository extends JpaRepository getByCertificateType(SignerInformationEntity.CertificateType type, + List getByCertificateTypeAndDeletedAtIsNull(SignerInformationEntity.CertificateType type, Pageable pageable); - List getByCertificateType(SignerInformationEntity.CertificateType type); + List getByCertificateTypeAndDeletedAtIsNull(SignerInformationEntity.CertificateType type); - List getByCertificateTypeAndCountry( + List getByCertificateTypeAndCountryAndDeletedAtIsNull( SignerInformationEntity.CertificateType type, String countryCode, Pageable pageable); - List getByCertificateTypeAndCountry( + List getByCertificateTypeAndCountryAndDeletedAtIsNull( SignerInformationEntity.CertificateType type, String countryCode); @Query(SELECT_SINCE) diff --git a/src/main/java/eu/europa/ec/dgc/gateway/service/SignerInformationService.java b/src/main/java/eu/europa/ec/dgc/gateway/service/SignerInformationService.java index 04e6c7c9..d5aa9945 100644 --- a/src/main/java/eu/europa/ec/dgc/gateway/service/SignerInformationService.java +++ b/src/main/java/eu/europa/ec/dgc/gateway/service/SignerInformationService.java @@ -79,7 +79,7 @@ public List getSignerInformation() { * @return List of SignerInformation */ public List getSignerInformation(SignerInformationEntity.CertificateType type) { - return signerInformationRepository.getByCertificateType(type); + return signerInformationRepository.getByCertificateTypeAndDeletedAtIsNull(type); } /** @@ -92,7 +92,7 @@ public List getSignerInformation(SignerInformationEntit public List getSignerInformation( String countryCode, SignerInformationEntity.CertificateType type) { - return signerInformationRepository.getByCertificateTypeAndCountry(type, countryCode); + return signerInformationRepository.getByCertificateTypeAndCountryAndDeletedAtIsNull(type, countryCode); } /** @@ -136,10 +136,10 @@ public List getSignerInformation(SignerInformationEntit } else if (ifModifiedSince != null) { return signerInformationRepository.getByCertificateTypeIsSince(type, ifModifiedSince); } else if (page != null && size != null) { - return signerInformationRepository.getByCertificateType(type, + return signerInformationRepository.getByCertificateTypeAndDeletedAtIsNull(type, PageRequest.of(page, size)); } else { - return signerInformationRepository.getByCertificateType(type); + return signerInformationRepository.getByCertificateTypeAndDeletedAtIsNull(type); } } @@ -166,10 +166,10 @@ public List getSignerInformation( return signerInformationRepository.getByCertificateTypeAndCountryIsSince(type, countryCode, ifModifiedSince); } else if (page != null && size != null) { - return signerInformationRepository.getByCertificateTypeAndCountry(type, countryCode, + return signerInformationRepository.getByCertificateTypeAndCountryAndDeletedAtIsNull(type, countryCode, PageRequest.of(page, size)); } else { - return signerInformationRepository.getByCertificateTypeAndCountry(type, countryCode); + return signerInformationRepository.getByCertificateTypeAndCountryAndDeletedAtIsNull(type, countryCode); } } @@ -308,7 +308,7 @@ public void deleteSignerCertificate( */ public List getCmsPackage(String country) { return signerInformationRepository - .getByCertificateTypeAndCountry(SignerInformationEntity.CertificateType.DSC, country) + .getByCertificateTypeAndCountryAndDeletedAtIsNull(SignerInformationEntity.CertificateType.DSC, country) .stream() .map(this::addCertificateToSignaturePayload) .map(it -> new CmsPackageDto(it.getSignature(), it.getId(), CmsPackageDto.CmsPackageTypeDto.DSC)) diff --git a/src/test/java/eu/europa/ec/dgc/gateway/service/SignerInformationServiceTest.java b/src/test/java/eu/europa/ec/dgc/gateway/service/SignerInformationServiceTest.java index 0b8dd37c..fd13bf52 100644 --- a/src/test/java/eu/europa/ec/dgc/gateway/service/SignerInformationServiceTest.java +++ b/src/test/java/eu/europa/ec/dgc/gateway/service/SignerInformationServiceTest.java @@ -154,7 +154,7 @@ void testSuccessfulGetSignerInformationByTypeAndCountryIsSincePageable() throws List signerInformationEntities = signerInformationService.getSignerInformation(SignerInformationEntity.CertificateType.DSC, null, null, null); - Assertions.assertEquals(7, signerInformationEntities.size()); + Assertions.assertEquals(6, signerInformationEntities.size()); List signerInformationEntities2 = signerInformationService.getSignerInformation( SignerInformationEntity.CertificateType.DSC, @@ -244,9 +244,16 @@ void testSuccessfulAddingNewSignerInformationAndDelete() throws Exception { countryCode ); - List entities = - signerInformationRepository.getByCertificateType(SignerInformationEntity.CertificateType.DSC); + // Deleted certificate should not be returned in queries without isSince + List entitiesByCertificateType = + signerInformationRepository.getByCertificateTypeAndDeletedAtIsNull(SignerInformationEntity.CertificateType.DSC); + Assertions.assertTrue(entitiesByCertificateType.isEmpty()); + List entitiesByCertificateTypeAndCountry = + signerInformationRepository.getByCertificateTypeAndCountryAndDeletedAtIsNull( + SignerInformationEntity.CertificateType.DSC, countryCode); + Assertions.assertTrue(entitiesByCertificateTypeAndCountry.isEmpty()); + List entities = signerInformationRepository.findAll(); Assertions.assertFalse(entities.isEmpty()); SignerInformationEntity deletedSignerInformationEntity = entities.get(0); Assertions.assertEquals(createdSignerInformationEntity.get().getThumbprint(), deletedSignerInformationEntity.getThumbprint());