Skip to content

Commit 71d2305

Browse files
committed
Assurances and authorizations vectors
1 parent 6d8fef6 commit 71d2305

File tree

3 files changed

+28
-31
lines changed

3 files changed

+28
-31
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
pip install git+https://github.com/davxy/asn1tools.git
2626
- name: Validate vectors
2727
run: |
28-
for v in codec accumulate; do
28+
for v in codec accumulate assurances authorizations; do
29+
echo "========= Validating $v vectors ========="
2930
./$v/validate.py
3031
done

assurances/validate.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#!/usr/bin/env python
22

3+
import asn1tools
4+
import glob
35
import os
46
import sys
5-
from pathlib import Path
67

7-
import asn1tools
8+
script_dir = os.path.dirname(os.path.abspath(__file__))
9+
sys.path.append(os.path.abspath(os.path.join(script_dir, '../jam-types-asn')))
810

9-
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../jam-types-asn')))
10-
from utils import get_schema_files, validate
11+
from utils import get_schema_files, validate # noqa: E402
1112

13+
os.chdir(script_dir)
1214

1315
# Makes the SEQUENCE of OPTIONAL values ASN.1 compliant (using CHOICE)
1416
def tweak_assignments_sequence_of_options(state_obj):
@@ -19,21 +21,16 @@ def tweak_assignments_sequence_of_options(state_obj):
1921
else:
2022
items[i] = {"some": items[i]}
2123

22-
2324
def tweak_callback(json_obj):
2425
tweak_assignments_sequence_of_options(json_obj['pre_state'])
2526
tweak_assignments_sequence_of_options(json_obj['post_state'])
2627
return json_obj
2728

29+
def validate_spec(spec_name):
30+
print(f"[Validating '{spec_name}' spec]")
31+
schema = asn1tools.compile_files(get_schema_files(spec_name == "full") + ["assurances.asn"], codec="jer")
32+
for json_file in glob.glob(f"{spec_name}/*.json"):
33+
validate(schema, json_file, "TestCase", tweak_callback)
2834

29-
# Validate tiny
30-
schema = asn1tools.compile_files(get_schema_files(False) + ["assurances.asn"], codec="jer")
31-
for path in Path("tiny").iterdir():
32-
if path.is_file() and path.suffix == ".json":
33-
validate(schema, path, "TestCase", tweak_callback)
34-
35-
# Validate full
36-
schema = asn1tools.compile_files(get_schema_files(True) + ["assurances.asn"], codec="jer")
37-
for path in Path("full").iterdir():
38-
if path.is_file() and path.suffix == ".json":
39-
validate(schema, path, "TestCase", tweak_callback)
35+
validate_spec("tiny")
36+
validate_spec("full")

authorizations/validate.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
#!/usr/bin/env python
22

3+
import asn1tools
4+
import glob
35
import os
46
import sys
5-
from pathlib import Path
67

7-
import asn1tools
8+
script_dir = os.path.dirname(os.path.abspath(__file__))
9+
sys.path.append(os.path.abspath(os.path.join(script_dir, '../jam-types-asn')))
810

9-
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../jam-types-asn')))
10-
from utils import get_schema_files, validate
11+
from utils import get_schema_files, validate # noqa: E402
1112

13+
os.chdir(script_dir)
1214

13-
# Validate tiny
14-
schema = asn1tools.compile_files(get_schema_files(False) + ["authorizations.asn"], codec="jer")
15-
for path in Path("tiny").iterdir():
16-
if path.is_file() and path.suffix == ".json":
17-
validate(schema, path, "TestCase")
15+
def validate_spec(spec_name):
16+
print(f"[Validating '{spec_name}' spec]")
17+
schema = asn1tools.compile_files(get_schema_files(spec_name == "full") + ["authorizations.asn"], codec="jer")
18+
for json_file in glob.glob(f"{spec_name}/*.json"):
19+
validate(schema, json_file, "TestCase")
1820

19-
# Validate full
20-
schema = asn1tools.compile_files(get_schema_files(True) + ["authorizations.asn"], codec="jer")
21-
for path in Path("full").iterdir():
22-
if path.is_file() and path.suffix == ".json":
23-
validate(schema, path, "TestCase")
21+
validate_spec("tiny")
22+
validate_spec("full")

0 commit comments

Comments
 (0)