From 5ef86a84492ae72c6605e639186b35d1001f52bf Mon Sep 17 00:00:00 2001 From: oleksandrsarapulovgl <82441124+oleksandrsarapulovgl@users.noreply.github.com> Date: Wed, 21 Jul 2021 11:02:50 +0300 Subject: [PATCH] Updated cert logic to return open result if schema version is greater than hcert version (#41) --- .../verifier/app/engine/DefaultCertLogicEngine.kt | 12 ++++++------ .../app/engine/DefaultCertLogicEngineTest.kt | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/engine/src/main/java/dgca/verifier/app/engine/DefaultCertLogicEngine.kt b/engine/src/main/java/dgca/verifier/app/engine/DefaultCertLogicEngine.kt index 73cb2d8..135d59e 100644 --- a/engine/src/main/java/dgca/verifier/app/engine/DefaultCertLogicEngine.kt +++ b/engine/src/main/java/dgca/verifier/app/engine/DefaultCertLogicEngine.kt @@ -75,11 +75,11 @@ class DefaultCertLogicEngine( val ruleEngineVersion = rule.engineVersion.toVersion() val schemaVersion = rule.schemaVersion.toVersion() val res = when { - rule.engine != CERTLOGIC_KEY - || ruleEngineVersion == null || !CERTLOGIC_VERSION - .isGreaterOrEqualThan(ruleEngineVersion) - || hcertVersion == null || schemaVersion == null || hcertVersion.first != schemaVersion.first -> Result.OPEN - hcertVersion.isGreaterOrEqualThan(schemaVersion) -> + rule.engine == CERTLOGIC_KEY && ruleEngineVersion != null && CERTLOGIC_VERSION.isGreaterOrEqualThan( + ruleEngineVersion + ) && hcertVersion != null && schemaVersion != null && hcertVersion.first == schemaVersion.first && hcertVersion.isGreaterOrEqualThan( + schemaVersion + ) -> when (jsonLogicValidator.isDataValid( rule.logic, dataJsonNode @@ -88,7 +88,7 @@ class DefaultCertLogicEngine( false -> Result.FAIL else -> Result.OPEN } - else -> Result.FAIL + else -> Result.OPEN } val cur: String = affectedFieldsDataRetriever.getAffectedFieldsData( rule, diff --git a/engine/src/test/java/dgca/verifier/app/engine/DefaultCertLogicEngineTest.kt b/engine/src/test/java/dgca/verifier/app/engine/DefaultCertLogicEngineTest.kt index 55b3096..8712573 100644 --- a/engine/src/test/java/dgca/verifier/app/engine/DefaultCertLogicEngineTest.kt +++ b/engine/src/test/java/dgca/verifier/app/engine/DefaultCertLogicEngineTest.kt @@ -127,7 +127,7 @@ internal class DefaultCertLogicEngineTest { val externalParameter = mockExternalParameter() assertEquals( - Result.FAIL, + Result.OPEN, certLogicEngine.validate( CertificateType.VACCINATION, "2.1.0",