Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #87 from admin-ch/feature/revocation-db
Browse files Browse the repository at this point in the history
add getPrepopulatedSinceHeader to store
  • Loading branch information
benz-ubique authored Sep 13, 2022
2 parents 6575eb5 + f3408cc commit 193180d
Show file tree
Hide file tree
Showing 5 changed files with 369 additions and 799 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kotlin.code.style=official
# Artifact metadata
GROUP=ch.admin.bag.covidcertificate
POM_ARTIFACT_ID=sdk-core
VERSION_NAME=3.2.1
VERSION_NAME=3.3.0

# POM metadata
POM_NAME=sdk-core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ class RevokedCertificatesInMemoryImpl(private var revokedCertificates: List<Stri
}
}

override fun getPrepopulatedSinceHeader(isProd: Boolean): String {
return "0"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ interface RevokedCertificatesStore {
fun containsCertificate(certificate: String): Boolean

fun addCertificates(certificates: List<String>)

fun getPrepopulatedSinceHeader(isProd: Boolean): String
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,88 +47,6 @@ class EOLBannerTests {
utcClock = Clock.systemUTC()
}


@Test
fun testinvalidInThreeWeeks() {
val clockToday = Clock.fixed(Instant.parse("2022-01-20T12:00:00Z"), ZoneId.systemDefault())
val clockFirstFeb = Clock.fixed(Instant.parse("2022-02-01T12:00:00Z"), ZoneId.systemDefault())
var vaccinationDate = LocalDate.now(clockFirstFeb).atStartOfDay().minusDays(270 - 1L)

var vaccine = Vaccine.BIONTECH
var vaccination = TestDataGenerator.generateVaccineCert(
2,
2,
vaccine.manufacturer,
vaccine.identifier,
AcceptanceCriteriasConstants.TARGET_DISEASE,
vaccine.prophylaxis,
vaccinationDate,
)
var data = getJsonNodeData(vaccination, null, clockToday)
var bannerID = displayValidityCalculator.getEolBannerIdentifier(nationalRuleSet.displayRules, data)
Assertions.assertEquals(bannerID, "invalidInThreeWeeks")


vaccinationDate = LocalDate.now(clockFirstFeb).atStartOfDay().minusDays(270).minusDays(21).plusDays(1)
vaccine = Vaccine.JANSSEN
vaccination = TestDataGenerator.generateVaccineCert(
1,
1,
vaccine.manufacturer,
vaccine.identifier,
AcceptanceCriteriasConstants.TARGET_DISEASE,
vaccine.prophylaxis,
vaccinationDate,
)
data = getJsonNodeData(vaccination, null, clockToday)
bannerID = displayValidityCalculator.getEolBannerIdentifier(nationalRuleSet.displayRules, data)
Assertions.assertEquals(bannerID, "invalidInThreeWeeks")

//recovery
val firstTestResult = LocalDate.now(clockFirstFeb).minusDays(180).plusDays(1)
val validFrom = firstTestResult.plusDays(10)
val validUntil = firstTestResult.plusDays(179)
val recovery = TestDataGenerator.generateRecoveryCertFromDate(
validFrom.atStartOfDay(),
validUntil.atStartOfDay(),
firstTestResult.atStartOfDay(),
AcceptanceCriteriasConstants.TARGET_DISEASE

)

data = getJsonNodeData(recovery, null, clockToday)
bannerID = displayValidityCalculator.getEolBannerIdentifier(nationalRuleSet.displayRules, data)
Assertions.assertEquals(bannerID, "invalidInThreeWeeks")

//antigen
var now = OffsetDateTime.now(clockFirstFeb).minusDays(180).plusDays(1)
var sampleCollectionTime = now
var test = TestDataGenerator.generateTestCertFromDate(
TestType.RAT.code,
AcceptanceCriteriasConstants.POSITIVE_CODE,
"Nucleic acid amplification with probe detection",
AcceptanceCriteriasConstants.TARGET_DISEASE,
sampleCollectionTime
)
data = getJsonNodeData(test, null, clockToday)
bannerID = displayValidityCalculator.getEolBannerIdentifier(nationalRuleSet.displayRules, data)
Assertions.assertEquals(bannerID, "invalidInThreeWeeks")

now = OffsetDateTime.now(clockFirstFeb).minusDays(365).plusDays(1)
sampleCollectionTime = now
test = TestDataGenerator.generateTestCertFromDate(
TestType.MEDICAL_EXEMPTION.code,
AcceptanceCriteriasConstants.NEGATIVE_CODE,
"Ausnahme",
AcceptanceCriteriasConstants.TARGET_DISEASE,
sampleCollectionTime
)

data = getJsonNodeData(test, null, clockToday)
bannerID = displayValidityCalculator.getEolBannerIdentifier(nationalRuleSet.displayRules, data)
Assertions.assertEquals(bannerID, "invalidInThreeWeeks")
}

@Test
fun testNotInvalid() {
val clockFirstFeb = Clock.fixed(Instant.parse("2022-02-01T12:00:00Z"), ZoneId.systemDefault())
Expand Down
Loading

0 comments on commit 193180d

Please sign in to comment.