Skip to content

Commit 1558ee9

Browse files
Test update (#63)
1 parent aa213a5 commit 1558ee9

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

decoder/src/test/java/dgca/verifier/app/decoder/QrCodeTests.kt

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,30 @@ class QrCodeTests {
4040
.generateCertificate(inputStream) as X509Certificate
4141
}
4242

43+
fun verifyResult(prefix: String?, PublicKey: String?): VerificationResult {
44+
val result = VerificationResult()
45+
val b45Service: Base45Service = DefaultBase45Service()
46+
val prefService: PrefixValidationService = DefaultPrefixValidationService()
47+
val compressorService: CompressorService = DefaultCompressorService()
48+
val validator: SchemaValidator = DefaultSchemaValidator()
49+
val coseservice: CoseService = DefaultCoseService()
50+
val greenCertificateMapper: GreenCertificateMapper = DefaultGreenCertificateMapper()
51+
val cborservice: CborService = DefaultCborService(greenCertificateMapper)
52+
val base45 = prefService.decode(prefix!!, result)
53+
val compressed = b45Service.decode(base45, result)
54+
val cose: ByteArray = compressorService.decode(compressed, result)!!
55+
val cbor = coseservice.decode(cose, result)
56+
val greenCertificate = cborservice.decode(cbor!!.cbor, result)
57+
val schemaresult = validator.validate(cbor.cbor, result)
58+
val cryptoService: CryptoService = VerificationCryptoService(X509())
59+
try {
60+
val cert: X509Certificate = toCertificate(PublicKey)
61+
cryptoService.validate(cose, cert, result, greenCertificate!!.getType())
62+
} catch (ex: Exception) {
63+
}
64+
return result
65+
}
66+
4367
fun verify(prefix: String?, PublicKey: String?): Boolean {
4468
val result = VerificationResult()
4569
val b45Service: Base45Service = DefaultBase45Service()
@@ -111,7 +135,8 @@ class QrCodeTests {
111135
assertTrue(result is CertificateDecodingResult.Success)
112136
val pubkey =
113137
"MIICKTCCAc+gAwIBAgITewAAAB77yzK1mZYu7QAAAAAAHjAKBggqhkjOPQQDAjA/MQswCQYDVQQGEwJOTzEbMBkGA1UEChMSTm9yc2sgaGVsc2VuZXR0IFNGMRMwEQYDVQQDEwpDU0NBIE5PIHYxMB4XDTIxMDYwNzA1NTY0MloXDTIzMDYwNzA2MDY0MlowUjELMAkGA1UEBhMCTk8xLTArBgNVBAoTJE5vcndlZ2lhbiBJbnN0aXR1dGUgb2YgUHVibGljIEhlYWx0aDEUMBIGA1UEAxMLRFNDIEhOIEVVIDIwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAR0UprGbSmy5WsMAyb0GXbzemkLRvmUNswy1lBGavDjHW7CTYPd+7yG/OGaXetTnboH0jDJeL1vVQvOr12T4+teo4GWMIGTMA4GA1UdDwEB/wQEAwIHgDAzBgNVHSUELDAqBgwrBgEEAQCON49lAQEGDCsGAQQBAI43j2UBAgYMKwYBBAEAjjePZQEDMB0GA1UdDgQWBBT1z+dhLhI7/AUOAdFiK4oqzEAlrzAfBgNVHSMEGDAWgBRBY3L2ecPBcffxgRI2UhCjJQp0JzAMBgNVHRMBAf8EAjAAMAoGCCqGSM49BAMCA0gAMEUCIDnEDlot8V1hen18ra7Xjv2bGL1mdz7453ItRdx4ubllAiEAkZZKE14rprcfPW6lKcS+SwQr7IWCrMYb/nZdhecUAHM="
114-
assertTrue(verify(hCert, pubkey))
138+
val res = verifyResult(hCert, pubkey)
139+
assertTrue(res.coseVerified)
115140
}
116141

117142
@Test

0 commit comments

Comments
 (0)