Skip to content

Commit

Permalink
Include deleted SignerInformation only if isModifiedSince is set (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
bergmann-dierk authored Mar 25, 2022
1 parent 3e7290c commit bca4327
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ List<SignerInformationEntity> getByCertificateTypeAndCountry(
@Query(SELECT_SINCE)
List<SignerInformationEntity> getIsSince(@Param("since")ZonedDateTime since, Pageable pageable);

List<SignerInformationEntity> getByDeletedAtIsNull();

List<SignerInformationEntity> getByDeletedAtIsNull(Pageable pageable);

@Query(SELECT_BY_TYPE_SINCE)
List<SignerInformationEntity> getByCertificateTypeIsSince(
@Param("certType")SignerInformationEntity.CertificateType type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class SignerInformationService {
* @return List of SignerInformation
*/
public List<SignerInformationEntity> getSignerInformation() {
return signerInformationRepository.findAll();
return signerInformationRepository.getByDeletedAtIsNull();
}

/**
Expand Down Expand Up @@ -109,7 +109,7 @@ public List<SignerInformationEntity> getSignerInformation(ZonedDateTime ifModif
} else if (ifModifiedSince != null) {
return signerInformationRepository.getIsSince(ifModifiedSince);
} else if (page != null && size != null) {
return signerInformationRepository.findAll(PageRequest.of(page, size)).toList();
return signerInformationRepository.getByDeletedAtIsNull(PageRequest.of(page, size));
} else {
return getSignerInformation();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ void testTrustListDownloadNoFilterPageable() throws Exception {
.andExpect(c -> assertTrustListItem(c, certDscEu, "EU", CertificateTypeDto.DSC, "sig2"))
.andExpect(c -> assertTrustListItem(c, certDscDe2, "DE", CertificateTypeDto.DSC, "sig3"))
.andExpect(c -> assertTrustListItem(c, certDscEu2, "EU", CertificateTypeDto.DSC, "sig4"))
.andExpect(c -> assertTrustListItem(c, certDscEuDeleted, "EU", CertificateTypeDto.DSC, null, true))
.andExpect(c -> assertTrustListItem(c, certCscaDe, "DE", CertificateTypeDto.CSCA, null))
.andExpect(c -> assertTrustListItem(c, certCscaEu, "EU", CertificateTypeDto.CSCA, null))
.andExpect(c -> assertTrustListItem(c, certUploadDe, "DE", CertificateTypeDto.UPLOAD, null))
Expand All @@ -206,7 +205,7 @@ void testTrustListDownloadNoFilterPageable() throws Exception {
.andExpect(c -> assertTrustListItem(c, certUploadEu2, "EU", CertificateTypeDto.UPLOAD, null))
.andExpect(c -> assertTrustListItem(c, certAuthDe2, "DE", CertificateTypeDto.AUTHENTICATION, null))
.andExpect(c -> assertTrustListItem(c, certAuthEu2, "EU", CertificateTypeDto.AUTHENTICATION, null))
.andExpect(c -> assertTrustListLength(c, 17));
.andExpect(c -> assertTrustListLength(c, 16));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,24 @@ void testSuccessfulGetSignerInformationIsSincePageable() throws Exception {

List<SignerInformationEntity> signerInformationEntities =
signerInformationService.getSignerInformation(null, null, null);
Assertions.assertEquals(7, signerInformationEntities.size());
Assertions.assertTrue(signerInformationEntities.stream().anyMatch(it -> it.getDeletedAt() != null && it.getSignature() == null));
// No deleted entries if modified-since is not set
Assertions.assertEquals(6, signerInformationEntities.size());
Assertions.assertFalse(signerInformationEntities.stream().anyMatch(it -> it.getDeletedAt() != null && it.getSignature() == null));

List<SignerInformationEntity> signerInformationEntities7 =
signerInformationService.getSignerInformation(nowMinusOneHour, null, null);
// Include deleted entries if modified-since is set
Assertions.assertEquals(7, signerInformationEntities7.size());
Assertions.assertTrue(signerInformationEntities7.stream().anyMatch(it -> it.getDeletedAt() != null && it.getSignature() == null));


List<SignerInformationEntity> signerInformationEntities2 = signerInformationService.getSignerInformation(
nowMinusOneMinute, null, null);
Assertions.assertEquals(3, signerInformationEntities2.size());

List<SignerInformationEntity> signerInformationEntities3 = signerInformationService.getSignerInformation(
null, 0, 10);
Assertions.assertEquals(7, signerInformationEntities3.size());
Assertions.assertEquals(6, signerInformationEntities3.size());

List<SignerInformationEntity> signerInformationEntities4 = signerInformationService.getSignerInformation(
null, 10, 10);
Expand Down

0 comments on commit bca4327

Please sign in to comment.