Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #213 -> test script is stricter than spec and Updated Known Issue List #224

Merged
merged 27 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e26b302
Updated known Issue List
bhavin-qryptal May 21, 2021
402368c
Merge branch 'eu-digital-green-certificates:main' into main
bhavin-qryptal May 21, 2021
c728358
Updated known issue listing
bhavin-qryptal May 21, 2021
b802bac
Merge branch 'eu-digital-green-certificates:main' into main
bhavin-qryptal May 21, 2021
dd74bfc
Merge branch 'eu-digital-green-certificates:main' into main
bhavin-qryptal May 22, 2021
7c21f54
Enhanced Error Handling Capability to be able to flag invalid JSON fi…
bhavin-qryptal May 22, 2021
a2f6af1
Enhanced Error Handling Capability to be able to flag invalid JSON fi…
bhavin-qryptal May 22, 2021
f730c9f
Update dgc-testdata-verification.yml
bhavin-qryptal May 23, 2021
f81ab70
Merge branch 'eu-digital-green-certificates:main' into main
bhavin-qryptal May 23, 2021
c817108
Merge branch 'eu-digital-green-certificates:main' into test_workflow
bhavin-qryptal May 23, 2021
0f60828
Update dgc-testdata-verification.yml
bhavin-qryptal May 23, 2021
676dfd6
Merge pull request #3 from bhavin-qryptal/test_workflow
bhavin-qryptal May 23, 2021
fbf4b80
Update dgc-testdata-verification.yml
bhavin-qryptal May 23, 2021
0d817db
Update dgc-testdata-verification.yml
bhavin-qryptal May 24, 2021
5b8a27f
Merge branch 'eu-digital-green-certificates:main' into main
bhavin-qryptal May 24, 2021
d1a9b51
Update requirements.txt
bhavin-qryptal May 24, 2021
68e534f
Update dgc-testdata-verification.yml
bhavin-qryptal May 24, 2021
0cd6501
Update dgc-testdata-verification.yml
bhavin-qryptal May 24, 2021
1bcdfc5
Update requirements.txt
bhavin-qryptal May 24, 2021
4d346ee
Merge pull request #5 from bhavin-qryptal/test
bhavin-qryptal May 24, 2021
c609a44
Enhanced error handling and reporting for test_picture_decode
bhavin-qryptal May 25, 2021
b1a857e
Merge branch 'eu-digital-green-certificates:main' into main
bhavin-qryptal May 25, 2021
dfeef80
Merge remote-tracking branch 'origin/main'
bhavin-qryptal May 25, 2021
2b5d3fb
Merge branch 'eu-digital-green-certificates:main' into main
bhavin-qryptal May 26, 2021
91c3724
Merge branch 'eu-digital-green-certificates:main' into main
bhavin-qryptal May 26, 2021
38238f4
Merge branch 'eu-digital-green-certificates:main' into main
bhavin-qryptal May 26, 2021
e999aad
Fix for #213 -> test script is stricter than spec and Updated Known I…
bhavin-qryptal May 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions BE/2DCode/raw/3.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"t": [{
"tg": "840539006",
"tt": "LP6464-4",
"sc": "2021-05-25T09:02:07Z",
"dr": "2021-05-15T19:21:22Z",
"sc": "2021-05-25T09:02:07.000000Z",
"dr": "2021-05-15T19:21:22.000000Z",
"tr": "260415000",
"tc": "81160393",
"co": "BE",
Expand Down
20 changes: 0 additions & 20 deletions tests/known_issues.csv
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
test_name,country,test_set,reason
test_expected_key_usage,NL,,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/146
test_cose_schema,NL,,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/107
test_verification_check,ES,401,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/32
test_verification_check,ES,402,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/32
test_verification_check,ES,403,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/32
,ES,1201,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/32
,ES,1202,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/32
test_expected_key_usage,ES,,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/168
test_verification_check,ES,1203,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/32
test_expiration_check,ES,,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/169
test_cose_schema,ES,1203,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/32
test_cose_json,ES,1203,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/32
test_cose_cbor,ES,1203,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/32
,BE,3,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/150
,FR,test_pcr_ok,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/141
test_expiration_check,PL,1,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/188
test_cose_json,PL,4,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/189
test_cose_json,PL,5,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/189
test_cbor_json,PL,4,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/189
test_cbor_json,PL,5,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/189
,PT,1,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/151
,PT,2,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/151
,PT,3,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/151
Expand All @@ -31,9 +14,6 @@ test_cbor_json,PL,5,https://github.com/eu-digital-green-certificates/dgc-testdat
,CZ,3,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/172
,CZ,4,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/172
,CZ,5,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/172
test_cose_schema,SE,7,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/213 -> test script is stricter than spec
test_cose_json,SE,7,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/213 -> test script is stricter than spec
test_cbor_json,SE,7,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/213 -> test script is stricter than spec
test_cose_schema,SI,1,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/220
test_cose_schema,SI,2,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/220
test_cose_schema,SI,3,https://github.com/eu-digital-green-certificates/dgc-testdata/issues/220
Expand Down
23 changes: 15 additions & 8 deletions tests/test_ehealth_certs.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from base64 import b64decode
from binascii import hexlify, unhexlify
from csv import DictReader
from datetime import datetime, timezone
from datetime import date, datetime, timezone
from glob import glob
from io import BytesIO
from json import load
Expand Down Expand Up @@ -89,6 +89,7 @@
EXPECTED_SCHEMA_VALIDATION = 'EXPECTEDSCHEMAVALIDATION'
EXPECTED_COMPRESSION = 'EXPECTEDCOMPRESSION'
EXPECTED_KEY_USAGE = 'EXPECTEDKEYUSAGE'
TIMESTAMP_ISO8601_EXTENDED = "%Y-%m-%dT%H:%M:%S.%fZ"

CBOR = 'CBOR'
CERTIFICATE = 'CERTIFICATE'
Expand Down Expand Up @@ -159,10 +160,15 @@ def xfail_known_issues(request, known_issue: str):
request.applymarker(mark.xfail(reason=known_issue))


def _object_hook(decoder, value):
return {k: v.astimezone(timezone.utc).strftime(TIMESTAMP_ISO8601_EXTENDED) if isinstance(v, (date, datetime)) else v
for k, v in value.items()}


def _dgc(config_env: Dict) -> Sign1Message:
if COSE in config_env.keys():
cbor_bytes = unhexlify(config_env[COSE])
cbor_object = loads(cbor_bytes)
cbor_object = loads(cbor_bytes, object_hook=_object_hook)
if isinstance(cbor_object, CBORTag): # Tagged Cose Object
if isinstance(cbor_object.value, CBORTag): # Double Tagged Cose Object
decoded = Sign1Message.from_cose_obj(cbor_object.value.value)
Expand Down Expand Up @@ -265,7 +271,7 @@ def test_cose_schema(config_env: Dict):

if config_env[EXPECTED_RESULTS][EXPECTED_SCHEMA_VALIDATION]:
dgc = _dgc(config_env)
cose_payload = loads(dgc.payload)
cose_payload = loads(dgc.payload, object_hook=_object_hook)
assert PAYLOAD_HCERT in cose_payload.keys()
assert len(cose_payload[PAYLOAD_HCERT]) == 1
assert 1 in cose_payload[PAYLOAD_HCERT].keys()
Expand All @@ -282,7 +288,7 @@ def test_cose_json(config_env: Dict):
if not ({COSE, JSON} <= config_env.keys()):
skip(f'Test dataset does not contain {COSE} and/or {JSON}')
dgc = _dgc(config_env)
cose_payload = loads(dgc.payload)
cose_payload = loads(dgc.payload, object_hook=_object_hook)
if config_env[EXPECTED_RESULTS][EXPECTED_DECODE]:
assert PAYLOAD_HCERT in cose_payload.keys()
assert len(cose_payload[PAYLOAD_HCERT]) == 1
Expand All @@ -302,6 +308,7 @@ def test_cbor_json(config_env: Dict):
skip(f'Test dataset does not contain {CBOR} and/or {JSON}')
cbor_bytes = unhexlify(config_env[CBOR])
cbor_object = loads(cbor_bytes)
cbor_object = loads(cbor_bytes, object_hook=_object_hook)
if config_env[EXPECTED_RESULTS][EXPECTED_DECODE]:
# assert PAYLOAD_HCERT in cbor_object.keys()
if PAYLOAD_HCERT in cbor_object.keys(): # Hack in order to match different level of CBOR Payload
Expand All @@ -319,9 +326,9 @@ def test_cose_cbor(config_env: Dict):
if not ({CBOR, COSE} <= config_env.keys()):
skip(f'Test dataset does not contain {CBOR} and/or {COSE}')
cbor_bytes = unhexlify(config_env[CBOR])
cbor_payload = loads(cbor_bytes)
cbor_payload = loads(cbor_bytes, object_hook=_object_hook)
dgc = _dgc(config_env)
cose_payload = loads(dgc.payload)
cose_payload = loads(dgc.payload, object_hook=_object_hook)

if config_env[EXPECTED_RESULTS][EXPECTED_DECODE]:
if PAYLOAD_HCERT not in cbor_payload.keys(): # Hack in order to match different level of CBOR Payload
Expand Down Expand Up @@ -384,7 +391,7 @@ def test_expiration_check(config_env: Dict):
dsc = _dsc(config_env)
dsc_not_valid_before, dsc_not_valid_after = dsc[3], dsc[4]
dgc = _dgc(config_env)
decoded_payload = loads(dgc.payload)
decoded_payload = loads(dgc.payload, object_hook=_object_hook)
assert {PAYLOAD_EXPIRY_DATE, PAYLOAD_ISSUE_DATE} <= decoded_payload.keys(), \
f'COSE Payload is missing expiry date: {PAYLOAD_EXPIRY_DATE} and/or issue date: {PAYLOAD_ISSUE_DATE}.'
dgc_expiry_date = datetime.fromtimestamp(decoded_payload[PAYLOAD_EXPIRY_DATE], tz=timezone.utc)
Expand Down Expand Up @@ -416,7 +423,7 @@ def test_expected_key_usage(config_env: Dict):
dsc = _dsc(config_env)
dsc_supported_operations = dsc[2]
dgc = _dgc(config_env)
cose_payload = loads(dgc.payload)
cose_payload = loads(dgc.payload, object_hook=_object_hook)
assert PAYLOAD_HCERT in cose_payload.keys()
assert len(cose_payload[PAYLOAD_HCERT]) == 1
assert 1 in cose_payload[PAYLOAD_HCERT].keys()
Expand Down