diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 9031ab98..4b71b471 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -1,6 +1,7 @@
name: Build, test and analyze
on:
+ workflow_dispatch:
push:
branches:
- 'release/**'
diff --git a/pom.xml b/pom.xml
index 2a3f2a87..51a6dadc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,7 +50,7 @@
**/*Dto.java
- **/*Dto.java,**/config/*,**/*Exception.java,**/*Constants.java,**/*Registry.java,**/*Config.java,**/*Mock*,**/*Application.java,**/*HttpResponseHeaderFilter.java,**/*ActuatorSecurity.java
+ **/*Dto.java,**/config/*,**/*Exception.java,**/*Constants.java,**/*Registry.java,**/*Config.java,**/*Mock*,**/*Application.java,**/*HttpResponseHeaderFilter.java,**/*ActuatorSecurity.java,**/*TestCovidCertificateGenerationService,java
admin-ch_CovidCertificate-Management-Service
diff --git a/src/main/java/ch/admin/bag/covidcertificate/service/RevocationService.java b/src/main/java/ch/admin/bag/covidcertificate/service/RevocationService.java
index 98d293d4..322e8c55 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/service/RevocationService.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/service/RevocationService.java
@@ -44,6 +44,10 @@ public class RevocationService {
@Transactional
public void createRevocation(String uvci, boolean fraud) {
+ this.createRevocationInternal(uvci, fraud);
+ }
+
+ private void createRevocationInternal(String uvci, boolean fraud) {
try {
if (revocationRepository.findByUvci(uvci) != null) {
log.info("Revocation for {} already exists.", uvci);
@@ -59,6 +63,7 @@ public void createRevocation(String uvci, boolean fraud) {
}
}
+ @Transactional
public RevocationListResponseDto performMassRevocation(RevocationListDto revocationListDto) {
Map uvcisToErrorMessage = getUvcisWithErrorMessage(
revocationListDto.getUvcis()
@@ -70,7 +75,7 @@ public RevocationListResponseDto performMassRevocation(RevocationListDto revocat
// revoke uvci if there are no error messages
if (uvcisToErrorMessage.get(uvciForRevocation.getUvci()) == null) {
try {
- createRevocation(uvciForRevocation.getUvci(), uvciForRevocation.getFraud());
+ createRevocationInternal(uvciForRevocation.getUvci(), uvciForRevocation.getFraud());
kpiLogService.logRevocationKpi(
KPI_REVOKE_CERTIFICATE_SYSTEM_KEY,
KPI_TYPE_MASS_REVOCATION_SUCCESS,
@@ -118,7 +123,7 @@ public Map getUvcisWithErrorMessage(List u
.map(UvciForRevocationDto::getUvci)
.collect(Collectors.toList());
- Map uvcisToErrorMessage = Stream.of(
+ return Stream.of(
// get all possible errors for uvcis
getInvalidUvcis(uvcis).entrySet(),
getUvcisWithMissingFraudFlag(uvciForRevocationDtos).entrySet(),
@@ -134,8 +139,6 @@ public Map getUvcisWithErrorMessage(List u
return left;
}
));
-
- return uvcisToErrorMessage;
}
private Map getInvalidUvcis(List uvciList) {
diff --git a/src/main/java/ch/admin/bag/covidcertificate/service/test/TestCovidCertificateGenerationService.java b/src/main/java/ch/admin/bag/covidcertificate/service/test/TestCovidCertificateGenerationService.java
index cca79f1d..70b13a5d 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/service/test/TestCovidCertificateGenerationService.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/service/test/TestCovidCertificateGenerationService.java
@@ -2,7 +2,14 @@
import ch.admin.bag.covidcertificate.api.Constants;
import ch.admin.bag.covidcertificate.api.mapper.CertificatePrintRequestDtoMapper;
-import ch.admin.bag.covidcertificate.api.request.*;
+import ch.admin.bag.covidcertificate.api.request.AntibodyCertificateCreateDto;
+import ch.admin.bag.covidcertificate.api.request.CertificateCreateDto;
+import ch.admin.bag.covidcertificate.api.request.ExceptionalCertificateCreateDto;
+import ch.admin.bag.covidcertificate.api.request.RecoveryCertificateCreateDto;
+import ch.admin.bag.covidcertificate.api.request.RecoveryRatCertificateCreateDto;
+import ch.admin.bag.covidcertificate.api.request.TestCertificateCreateDto;
+import ch.admin.bag.covidcertificate.api.request.VaccinationCertificateCreateDto;
+import ch.admin.bag.covidcertificate.api.request.VaccinationTouristCertificateCreateDto;
import ch.admin.bag.covidcertificate.api.request.conversion.VaccinationCertificateConversionRequestDto;
import ch.admin.bag.covidcertificate.api.response.ConvertedCertificateResponseDto;
import ch.admin.bag.covidcertificate.api.response.ConvertedCertificateResponseEnvelope;
diff --git a/src/test/java/ch/admin/bag/covidcertificate/api/mapper/pdfgeneration/AntibodyCertificatePdfGenerateRequestDtoMapperTest.java b/src/test/java/ch/admin/bag/covidcertificate/api/mapper/pdfgeneration/AntibodyCertificatePdfGenerateRequestDtoMapperTest.java
new file mode 100644
index 00000000..95757389
--- /dev/null
+++ b/src/test/java/ch/admin/bag/covidcertificate/api/mapper/pdfgeneration/AntibodyCertificatePdfGenerateRequestDtoMapperTest.java
@@ -0,0 +1,111 @@
+package ch.admin.bag.covidcertificate.api.mapper.pdfgeneration;
+
+import ch.admin.bag.covidcertificate.api.request.pdfgeneration.AntibodyCertificatePdfGenerateRequestDto;
+import ch.admin.bag.covidcertificate.service.domain.AntibodyCertificatePdf;
+import ch.admin.bag.covidcertificate.service.domain.CovidCertificateDiseaseOrAgentTargeted;
+import com.flextrade.jfixture.JFixture;
+import org.junit.Test;
+
+import static ch.admin.bag.covidcertificate.api.Constants.ISSUER;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class AntibodyCertificatePdfGenerateRequestDtoMapperTest {
+
+ private final JFixture fixture = new JFixture();
+ private final String countryOfTest = "Schweiz";
+ private final String countryOfTestEn = "Switzerland";
+
+ @Test
+ public void mapsFamilyName() {
+ AntibodyCertificatePdfGenerateRequestDto incoming = fixture.create(AntibodyCertificatePdfGenerateRequestDto.class);
+ AntibodyCertificatePdf actual = AntibodyCertificatePdfGenerateRequestDtoMapper.toAntibodyCertificatePdf(
+ incoming, countryOfTest, countryOfTestEn);
+ assertEquals(incoming.getDecodedCert().getPersonData().getName().getFamilyName(), actual.getFamilyName());
+ }
+
+ @Test
+ public void mapsGivenName() {
+ AntibodyCertificatePdfGenerateRequestDto incoming = fixture.create(AntibodyCertificatePdfGenerateRequestDto.class);
+ AntibodyCertificatePdf actual = AntibodyCertificatePdfGenerateRequestDtoMapper.toAntibodyCertificatePdf(
+ incoming, countryOfTest, countryOfTestEn);
+ assertEquals(incoming.getDecodedCert().getPersonData().getName().getGivenName(), actual.getGivenName());
+ }
+
+ @Test
+ public void mapsDateOfBirth() {
+ AntibodyCertificatePdfGenerateRequestDto incoming = fixture.create(AntibodyCertificatePdfGenerateRequestDto.class);
+ AntibodyCertificatePdf actual = AntibodyCertificatePdfGenerateRequestDtoMapper.toAntibodyCertificatePdf(
+ incoming, countryOfTest, countryOfTestEn);
+ assertEquals(incoming.getDecodedCert().getPersonData().getDateOfBirth(), actual.getDateOfBirth());
+ }
+
+ @Test
+ public void mapsLanguage() {
+ AntibodyCertificatePdfGenerateRequestDto incoming = fixture.create(AntibodyCertificatePdfGenerateRequestDto.class);
+ AntibodyCertificatePdf actual = AntibodyCertificatePdfGenerateRequestDtoMapper.toAntibodyCertificatePdf(
+ incoming, countryOfTest, countryOfTestEn);
+ assertEquals(incoming.getLanguage(), actual.getLanguage());
+ }
+
+ @Test
+ public void mapsDiseaseOrAgentTargetedCode() {
+ AntibodyCertificatePdfGenerateRequestDto incoming = fixture.create(AntibodyCertificatePdfGenerateRequestDto.class);
+ AntibodyCertificatePdf actual = AntibodyCertificatePdfGenerateRequestDtoMapper.toAntibodyCertificatePdf(
+ incoming, countryOfTest, countryOfTestEn);
+ assertEquals(
+ CovidCertificateDiseaseOrAgentTargeted.getStandardInstance().getCode(),
+ actual.getDiseaseOrAgentTargetedCode());
+ }
+
+ @Test
+ public void mapsDiseaseOrAgentTargetedSystem() {
+ AntibodyCertificatePdfGenerateRequestDto incoming = fixture.create(AntibodyCertificatePdfGenerateRequestDto.class);
+ AntibodyCertificatePdf actual = AntibodyCertificatePdfGenerateRequestDtoMapper.toAntibodyCertificatePdf(
+ incoming, countryOfTest, countryOfTestEn);
+ assertEquals(
+ CovidCertificateDiseaseOrAgentTargeted.getStandardInstance().getSystem(),
+ actual.getDiseaseOrAgentTargetedSystem());
+ }
+
+ @Test
+ public void mapsDateOfFirstPositiveTestResult() {
+ AntibodyCertificatePdfGenerateRequestDto incoming = fixture.create(AntibodyCertificatePdfGenerateRequestDto.class);
+ AntibodyCertificatePdf actual = AntibodyCertificatePdfGenerateRequestDtoMapper.toAntibodyCertificatePdf(
+ incoming, countryOfTest, countryOfTestEn);
+ assertEquals(
+ incoming.getDecodedCert().getAntibodyInfo().get(0).getSampleDateTime().toLocalDate(),
+ actual.getSampleDate());
+ }
+
+ @Test
+ public void mapsCountryOfTest() {
+ AntibodyCertificatePdfGenerateRequestDto incoming = fixture.create(AntibodyCertificatePdfGenerateRequestDto.class);
+ AntibodyCertificatePdf actual = AntibodyCertificatePdfGenerateRequestDtoMapper.toAntibodyCertificatePdf(
+ incoming, countryOfTest, countryOfTestEn);
+ assertEquals(countryOfTest, actual.getCountryOfTest());
+ }
+
+ @Test
+ public void mapsCountryOfTestEn() {
+ AntibodyCertificatePdfGenerateRequestDto incoming = fixture.create(AntibodyCertificatePdfGenerateRequestDto.class);
+ AntibodyCertificatePdf actual = AntibodyCertificatePdfGenerateRequestDtoMapper.toAntibodyCertificatePdf(
+ incoming, countryOfTest, countryOfTestEn);
+ assertEquals(countryOfTestEn, actual.getCountryOfTestEn());
+ }
+
+ @Test
+ public void mapsIssuer() {
+ AntibodyCertificatePdfGenerateRequestDto incoming = fixture.create(AntibodyCertificatePdfGenerateRequestDto.class);
+ AntibodyCertificatePdf actual = AntibodyCertificatePdfGenerateRequestDtoMapper.toAntibodyCertificatePdf(
+ incoming, countryOfTest, countryOfTestEn);
+ assertEquals(ISSUER, actual.getIssuer());
+ }
+
+ @Test
+ public void mapsUvci() {
+ AntibodyCertificatePdfGenerateRequestDto incoming = fixture.create(AntibodyCertificatePdfGenerateRequestDto.class);
+ AntibodyCertificatePdf actual = AntibodyCertificatePdfGenerateRequestDtoMapper.toAntibodyCertificatePdf(
+ incoming, countryOfTest, countryOfTestEn);
+ assertEquals(incoming.getDecodedCert().getAntibodyInfo().get(0).getIdentifier(), actual.getIdentifier());
+ }
+}
diff --git a/src/test/java/ch/admin/bag/covidcertificate/client/inapp_delivery/internal/DefaultInAppDeliveryClientITTest.java b/src/test/java/ch/admin/bag/covidcertificate/client/inapp_delivery/internal/DefaultInAppDeliveryClientITTest.java
deleted file mode 100644
index 235f3b83..00000000
--- a/src/test/java/ch/admin/bag/covidcertificate/client/inapp_delivery/internal/DefaultInAppDeliveryClientITTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package ch.admin.bag.covidcertificate.client.inapp_delivery.internal;
-
-import ch.admin.bag.covidcertificate.api.exception.CreateCertificateException;
-import ch.admin.bag.covidcertificate.api.request.SystemSource;
-import ch.admin.bag.covidcertificate.client.inapp_delivery.domain.InAppDeliveryRequestDto;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.context.ActiveProfiles;
-
-import static ch.admin.bag.covidcertificate.FixtureCustomization.createUVCI;
-import static ch.admin.bag.covidcertificate.api.Constants.APP_DELIVERY_FAILED;
-import static org.junit.jupiter.api.Assertions.*;
-
-@SpringBootTest(properties = {
- "spring.jpa.hibernate.ddl-auto=create",
- "spring.datasource.driver-class-name=org.h2.Driver",
- "spring.datasource.url=jdbc:h2:~/test;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE",
- "spring.datasource.username=sa",
- "spring.datasource.password=sa",
- "spring.flyway.clean-on-validation-error=true"
-})
-@ActiveProfiles("local")
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
-@Disabled("Only runs manually")
-class DefaultInAppDeliveryClientITTest {
-
- private static final String validTestCode = "BITBITBIT";
-
- @Autowired
- private DefaultInAppDeliveryClient client;
-
- @Test
- void deliverToApp_invalid() {
- var requestDto = new InAppDeliveryRequestDto("test", "test", "test");
- CreateCertificateException exception = assertThrows(
- CreateCertificateException.class,
- () -> client.deliverToApp(createUVCI(), SystemSource.WebUI, "0815", requestDto));
-
- assertEquals(APP_DELIVERY_FAILED, exception.getError());
- }
-
- @Test
- void deliverToApp_valid() {
- var requestDto = new InAppDeliveryRequestDto(validTestCode, "test", "test");
- assertDoesNotThrow(() -> client.deliverToApp(createUVCI(), SystemSource.WebUI, "0815", requestDto));
- }
-}
diff --git a/src/test/java/ch/admin/bag/covidcertificate/service/CBORServiceTest.java b/src/test/java/ch/admin/bag/covidcertificate/service/CBORServiceTest.java
index 807cdb90..f2739df6 100644
--- a/src/test/java/ch/admin/bag/covidcertificate/service/CBORServiceTest.java
+++ b/src/test/java/ch/admin/bag/covidcertificate/service/CBORServiceTest.java
@@ -74,7 +74,7 @@ void throwsIllegalArgumentException_ifKeyIdentifierIsNullOrBlank(String keyIdent
@Test
void throwsDecoderException_ifKeyIdentifierIsNotAValidHexString() {
- DecoderException exception = assertThrows(DecoderException.class,
+ assertThrows(DecoderException.class,
() -> cborService.getProtectedHeader(fixture.create(String.class)));
}
}
@@ -142,9 +142,9 @@ void throwsIllegalArgumentException_ifHCertIsNullOrEmpty(byte[] hcert) {
@Test
void throwsCBORException_ifHCertIsNotAValidCborObject() {
- var hcert = fixture.create(byte[].class);
+ var hcert = new byte[] {38, 41, 89};
var expiredAt = fixture.create(Instant.class);
- var exception = assertThrows(CBORException.class,
+ assertThrows(CBORException.class,
() -> cborService.getPayload(hcert, expiredAt));
}
}
@@ -267,7 +267,7 @@ void throwsIllegalArgumentException_ifSignatureIsNullOrEmpty(byte[] signature) {
byte[] payload = fixture.create(byte[].class);
// when then
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class,
- () -> cborService.getCOSESign1(protectedHeader, protectedHeader, signature));
+ () -> cborService.getCOSESign1(protectedHeader, payload, signature));
assertTrue(exception.getMessage().toLowerCase().contains("signature"));
}
}