Git Product home page Git Product logo

Comments (6)

barsa-net avatar barsa-net commented on August 19, 2024

There is a folder assets used by unit tests: https://github.com/ministero-salute/it-dgc-verificaC19-android/tree/develop/app/src/test/assets

They are used here:

class ServiceMocks {
companion object {
private const val VERIFICATION_RULES_SUCCESS = "verification_rules_success_response.json"
private const val QR_CODE_EXAMPLE = "qr_code.txt"
private const val QR_CODE_PLAIN_INPUT = "qr_code_plain_input.txt"
private const val QR_CODE_COMPRESSED_COSE = "qr_code_compressed_cose.txt"
private const val QR_CODE_COSE = "qr_code_cose.txt"
private const val QR_CODE_KID = "qr_code_kid.txt"
private const val QR_CODE_CBOR = "qr_code_cbor.txt"
private const val QR_CODE_CERTIFICATE = "qr_code_certificate.txt"
@JvmStatic
fun getVerificationRulesSuccessResponse(): Array<Rule>{
val systemResponse = MockDataUtils.GSON.fromJson(
MockDataUtils.readFile(VERIFICATION_RULES_SUCCESS), Array<Rule>::class.java)
return systemResponse
}
@JvmStatic
fun getVerificationRulesStringResponse(): String{
return MockDataUtils.readFile(VERIFICATION_RULES_SUCCESS)
}
@JvmStatic
fun getQrCode(): String{
return MockDataUtils.readFile(QR_CODE_EXAMPLE)
}
@JvmStatic
fun getQrCodePlainInput(): String{
return MockDataUtils.readFile(QR_CODE_PLAIN_INPUT)
}
@JvmStatic
fun getQrCodeCompressedCose(): String{
return MockDataUtils.readFile(QR_CODE_COMPRESSED_COSE)
}
@JvmStatic
fun getQrCodeCose(): String{
return MockDataUtils.readFile(QR_CODE_COSE)
}
@JvmStatic
fun getQrCodeKid(): String{
return MockDataUtils.readFile(QR_CODE_KID)
}
@JvmStatic
fun getQrCodeCbor(): String{
return MockDataUtils.readFile(QR_CODE_CBOR)
}
@JvmStatic
fun getQrCodeCertificate(): String{
return MockDataUtils.readFile(QR_CODE_CERTIFICATE)
}
}
}

And then here:

@ExperimentalCoroutinesApi
@Test
fun `test decode function`() = mainCoroutineScopeRule.runBlockingTest {
val qrCode = ServiceMocks.getQrCode()
val plainInput = ServiceMocks.getQrCodePlainInput()
val compressedCose = ServiceMocks.getQrCodeCompressedCose()
val cose = ServiceMocks.getQrCodeCose()
val kid = ServiceMocks.getQrCodeKid()
val cbor = ServiceMocks.getQrCodeCbor()
val caseData = CoseData(cbor.toByteArray(), kid.toByteArray())
val certificate = ServiceMocks.getQrCodeCertificate()
val mockObserver = mockk<Observer<Boolean>>()
val slot = slot<Boolean>()
val listOfResponse = arrayListOf<Boolean>()
every{prefixValidationService.decode(any(), any())}.returns(plainInput)
every{base45Service.decode(any(), any())}.returns(compressedCose.toByteArray())
every{compressorService.decode(any(), any())}.returns(cose.toByteArray())
every{coseService.decode(any(), any())}.returns(caseData)
coEvery{verifierRepository.getCertificate(any())}.returns(certificate.base64ToX509Certificate() as Certificate)
every { mockObserver.onChanged(capture(slot)) } answers {
listOfResponse.add(slot.captured)
}
viewModel.inProgress.observeForever(mockObserver)
viewModel.decode(qrCode)
assertNotEquals(viewModel.certificate.value, null)
assertEquals(true, listOfResponse[0])
assertEquals(false, listOfResponse[1])
}

from it-dgc-verificac19-android.

Lazza avatar Lazza commented on August 19, 2024

https://dgc.a-sit.at/ehn/

from it-dgc-verificac19-android.

aiotech-pub avatar aiotech-pub commented on August 19, 2024

There is a folder assets used by unit tests: https://github.com/ministero-salute/it-dgc-verificaC19-android/tree/develop/app/src/test/assets

these are mocks I mean if you have fake QR to be used in user testing or functional testing. If you do not have I could make fake QR codes starting by the mocks (supposing the mocks contain all the data a QR code contains) but I need the QR parameters to be sure to produce a complaint QR code.

They are used here:

class ServiceMocks {
companion object {
private const val VERIFICATION_RULES_SUCCESS = "verification_rules_success_response.json"
private const val QR_CODE_EXAMPLE = "qr_code.txt"
private const val QR_CODE_PLAIN_INPUT = "qr_code_plain_input.txt"
private const val QR_CODE_COMPRESSED_COSE = "qr_code_compressed_cose.txt"
private const val QR_CODE_COSE = "qr_code_cose.txt"
private const val QR_CODE_KID = "qr_code_kid.txt"
private const val QR_CODE_CBOR = "qr_code_cbor.txt"
private const val QR_CODE_CERTIFICATE = "qr_code_certificate.txt"
@JvmStatic
fun getVerificationRulesSuccessResponse(): Array<Rule>{
val systemResponse = MockDataUtils.GSON.fromJson(
MockDataUtils.readFile(VERIFICATION_RULES_SUCCESS), Array<Rule>::class.java)
return systemResponse
}
@JvmStatic
fun getVerificationRulesStringResponse(): String{
return MockDataUtils.readFile(VERIFICATION_RULES_SUCCESS)
}
@JvmStatic
fun getQrCode(): String{
return MockDataUtils.readFile(QR_CODE_EXAMPLE)
}
@JvmStatic
fun getQrCodePlainInput(): String{
return MockDataUtils.readFile(QR_CODE_PLAIN_INPUT)
}
@JvmStatic
fun getQrCodeCompressedCose(): String{
return MockDataUtils.readFile(QR_CODE_COMPRESSED_COSE)
}
@JvmStatic
fun getQrCodeCose(): String{
return MockDataUtils.readFile(QR_CODE_COSE)
}
@JvmStatic
fun getQrCodeKid(): String{
return MockDataUtils.readFile(QR_CODE_KID)
}
@JvmStatic
fun getQrCodeCbor(): String{
return MockDataUtils.readFile(QR_CODE_CBOR)
}
@JvmStatic
fun getQrCodeCertificate(): String{
return MockDataUtils.readFile(QR_CODE_CERTIFICATE)
}
}
}

And then here:

@ExperimentalCoroutinesApi
@Test
fun `test decode function`() = mainCoroutineScopeRule.runBlockingTest {
val qrCode = ServiceMocks.getQrCode()
val plainInput = ServiceMocks.getQrCodePlainInput()
val compressedCose = ServiceMocks.getQrCodeCompressedCose()
val cose = ServiceMocks.getQrCodeCose()
val kid = ServiceMocks.getQrCodeKid()
val cbor = ServiceMocks.getQrCodeCbor()
val caseData = CoseData(cbor.toByteArray(), kid.toByteArray())
val certificate = ServiceMocks.getQrCodeCertificate()
val mockObserver = mockk<Observer<Boolean>>()
val slot = slot<Boolean>()
val listOfResponse = arrayListOf<Boolean>()
every{prefixValidationService.decode(any(), any())}.returns(plainInput)
every{base45Service.decode(any(), any())}.returns(compressedCose.toByteArray())
every{compressorService.decode(any(), any())}.returns(cose.toByteArray())
every{coseService.decode(any(), any())}.returns(caseData)
coEvery{verifierRepository.getCertificate(any())}.returns(certificate.base64ToX509Certificate() as Certificate)
every { mockObserver.onChanged(capture(slot)) } answers {
listOfResponse.add(slot.captured)
}
viewModel.inProgress.observeForever(mockObserver)
viewModel.decode(qrCode)
assertNotEquals(viewModel.certificate.value, null)
assertEquals(true, listOfResponse[0])
assertEquals(false, listOfResponse[1])
}

from it-dgc-verificac19-android.

barsa-net avatar barsa-net commented on August 19, 2024

@aiotech-pub sorry, but I'm not a developer nor a mantainer of this application, I was just searching the same infos myself and pointed you out to my findings.

from it-dgc-verificac19-android.

aiotech-pub avatar aiotech-pub commented on August 19, 2024

@aiotech-pub sorry, but I'm not a developer nor a mantainer of this application, I was just searching the same infos myself and pointed you out to my findings.

Ah OK you were in the same black sea I was. Anyway I found themo, just four but I found them.

from it-dgc-verificac19-android.

aiotech-pub avatar aiotech-pub commented on August 19, 2024

I found the QR codes by myself: https://github.com/eu-digital-green-certificates/dgc-testdata contains test data for every EU state more or less.

from it-dgc-verificac19-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.