Skip to content

Commit e7007b1

Browse files
committed
Allow additional properties for extra EU countries in validation script
1 parent c3c12ff commit e7007b1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

tests/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
DCC_TYPES = {'v': "VAC", 't': "TEST", 'r': "REC"}
44
EXTENDED_KEY_USAGE_OIDs = {'t':'1.3.6.1.4.1.0.1847.2021.1.1','v':'1.3.6.1.4.1.0.1847.2021.1.2','r':'1.3.6.1.4.1.0.1847.2021.1.3',
55
'T':'1.3.6.1.4.1.1847.2021.1.1', 'V':'1.3.6.1.4.1.1847.2021.1.2', 'R':'1.3.6.1.4.1.1847.2021.1.3'}
6+
EU_COUNTRIES = ['BE', 'EL', 'GR', 'LT', 'PT', 'BG', 'ES', 'LU', 'RO', 'CZ', 'FR', 'HU', 'SI', 'DK', 'HR', 'MT', 'SK', 'DE', 'IT', 'NL', 'FI', 'EE', 'CY', 'AT', 'SE', 'IE', 'LV', 'PL'] # Greece included as EL and GR
67

78
# URLs
89
ACC_KID_LIST = 'https://dgca-verifier-service-eu-acc.cfapps.eu10.hana.ondemand.com/signercertificateStatus'

tests/test_qrqualitycheck.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def test_payload_version_matches_path_version( dccQrCode ):
144144

145145

146146
@filecache(DAY)
147-
def get_json_schema(version):
147+
def get_json_schema(version, extra_eu):
148148
''' Get the json schema depending on the version of the DCC data.
149149
Schema code is obtained from https://raw.githubusercontent.com/ehn-dcc-development/ehn-dcc-schema/
150150
'''
@@ -174,17 +174,26 @@ def __call__(self, uri, **kwargs):
174174
rewritingLoader = RewritingLoader({'https://id.uvci.eu/' : versioned_path,
175175
"\"properties\"": "\"additionalProperties\": false, \"properties\""} )
176176

177+
rewritingLoaderExtraEU = RewritingLoader({'https://id.uvci.eu/' : versioned_path,
178+
"\"properties\"": "\"additionalProperties\": true, \"properties\""} )
179+
177180
print(f'Loading HCERT schema {version} ...')
178181
try:
179182
schema = jsonref.load_uri(f'{versioned_path}{main_file}', loader=rewritingLoader )
183+
schemaExtraEU = jsonref.load_uri(f'{versioned_path}{main_file}', loader=rewritingLoaderExtraEU )
180184
except:
181185
raise LookupError(f'Could not load schema definition for {version}')
186+
187+
if extra_eu:
188+
return schemaExtraEU
182189
return schema
183190

184191
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
185192
def test_json_schema( dccQrCode ):
186193
"Performs a schema validation against the ehn-dcc-development/ehn-dcc-schema definition"
187-
schema = get_json_schema( dccQrCode.payload[constants.PAYLOAD_HCERT][1]['ver'] )
194+
extra_eu = dccQrCode.get_path_country() not in constants.EU_COUNTRIES
195+
schema = get_json_schema( dccQrCode.payload[constants.PAYLOAD_HCERT][1]['ver'], extra_eu)
196+
188197
jsonschema.validate( dccQrCode.payload[constants.PAYLOAD_HCERT][1], schema )
189198

190199

0 commit comments

Comments
 (0)