Skip to content

Commit

Permalink
ToString replaced by ToJsonString. Testcase for tagged Code added. (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
SchulzeStTSI authored Jul 5, 2021
1 parent 965b189 commit e09749c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class DefaultCborService : CborService {
val greenCertificate: GreenCertificate = CBORMapper()
.readValue(hcertv1, GreenCertificate::class.java)
.also { verificationResult.cborDecoded = true }
GreenCertificateData(issuingCountry, cborObject.toString(), greenCertificate, issuedAt.atZone(ZoneOffset.UTC), expirationTime.atZone(ZoneOffset.UTC))
GreenCertificateData(issuingCountry, cborObject.ToJSONString(), greenCertificate, issuedAt.atZone(ZoneOffset.UTC), expirationTime.atZone(ZoneOffset.UTC))
} catch (e: Throwable) {
null
}
Expand Down
27 changes: 27 additions & 0 deletions decoder/src/test/java/dgca/verifier/app/decoder/QrCodeTests.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dgca.verifier.app.decoder

import com.fasterxml.jackson.databind.ObjectMapper
import dgca.verifier.app.decoder.base45.Base45Decoder
import dgca.verifier.app.decoder.base45.Base45Service
import dgca.verifier.app.decoder.base45.DefaultBase45Service
Expand All @@ -17,9 +18,11 @@ import dgca.verifier.app.decoder.prefixvalidation.PrefixValidationService
import dgca.verifier.app.decoder.schema.DefaultSchemaValidator
import dgca.verifier.app.decoder.schema.SchemaValidator
import dgca.verifier.app.decoder.services.X509
import org.junit.Assert
import org.junit.Assert.assertTrue
import org.junit.Test
import java.io.ByteArrayInputStream
import java.io.IOException
import java.io.InputStream
import java.security.cert.CertificateException
import java.security.cert.CertificateFactory
Expand Down Expand Up @@ -120,4 +123,28 @@ class QrCodeTests {
"MIIBzDCCAXGgAwIBAgIUDN8nWnn8gBmlWgL3stwhoinVD5MwCgYIKoZIzj0EAwIwIDELMAkGA1UEBhMCR1IxETAPBgNVBAMMCGdybmV0LmdyMB4XDTIxMD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AK2EQ6YBK S*%NH\$RSC9KIFX80S\$CKX85JLL%IR299 T757A0L /K1:SY70R61M0VWP0FDA4JBSC9HAG-BJDCI-TL-VC4SLW HPOJZ0K PIS\$S0O29T2*ZE6WUAKEG%5TW5A 6YO67N65VC561CSS2+K/KVMAWCUPK-BT-QYFRZJNU 54*A*K66.AORVFCV.YJ72V34K:1BT1GIFE\$EUXNL606KQHEPB/%9YE96.R L7CRAYIO8MRVBWHLV%.P*YSNDM/0HBZVC*IP:2JIJD:61E77%NT9J3-S726O/5U3F$1CJYV0BSLPS/*D-YN%N4:2FSEQMQUHL5W RXWS-ARH.NMVRUNBYWI8:V29AKXTN2Q:ULZ0SM-F\$JU-0R0J3+TUSVU4FB22N+9BQA8TTT:-6: 6YAN.6W8LBX/CC3BM 24CO6WJM4P8QE0M8XY29B93GQ*AE%/9WH2DI7U2VLW1B3B1:JD%70\$AK%D.R6/NF%LCIWLO.B0DR6OMZHUDOQBP6OU9G3WL/VH:TT07QQU2FOQKLRF5E8VTH7/WR6Y0*:B%75"
val result = VerificationResult()
val b45Service: Base45Service = DefaultBase45Service()
val prefService: PrefixValidationService = DefaultPrefixValidationService()
val compressorService: CompressorService = DefaultCompressorService()
val validator: SchemaValidator = DefaultSchemaValidator()
val coseservice: CoseService = DefaultCoseService()
val cborservice: CborService = DefaultCborService()
val base45 = prefService.decode(hCert, result)
val compressed = b45Service.decode(base45, result)
val cose = compressorService.decode(compressed, result)
val cbor = coseservice.decode(cose, result)
val greenCertificate = cborservice.decodeData(cbor!!.cbor, result)
try {
val mapper = ObjectMapper()
mapper.readTree(greenCertificate!!.hcertJson)
} catch (e: IOException) {
Assert.fail()
}
}
}

0 comments on commit e09749c

Please sign in to comment.