Fixup token key todo
Change-Id: I49adfc9f4b4504fbacbee259424ab0afc55febf2
Signed-off-by: Mate Toth-Pal <mate.toth-pal@arm.com>
diff --git a/iat-verifier/tests/synthetic_data/correct_tagging.cbor b/iat-verifier/tests/synthetic_data/correct_tagging.cbor
index f4cf91a..e25fcdb 100644
--- a/iat-verifier/tests/synthetic_data/correct_tagging.cbor
+++ b/iat-verifier/tests/synthetic_data/correct_tagging.cbor
Binary files differ
diff --git a/iat-verifier/tests/synthetic_data/invalid_tags.cbor b/iat-verifier/tests/synthetic_data/invalid_tags.cbor
index 874f1fe..d155d1a 100644
--- a/iat-verifier/tests/synthetic_data/invalid_tags.cbor
+++ b/iat-verifier/tests/synthetic_data/invalid_tags.cbor
Binary files differ
diff --git a/iat-verifier/tests/synthetic_data/inverted_p_header2.cbor b/iat-verifier/tests/synthetic_data/inverted_p_header2.cbor
index 7aee38e..7969e64 100644
--- a/iat-verifier/tests/synthetic_data/inverted_p_header2.cbor
+++ b/iat-verifier/tests/synthetic_data/inverted_p_header2.cbor
Binary files differ
diff --git a/iat-verifier/tests/synthetic_data/missing_tags.cbor b/iat-verifier/tests/synthetic_data/missing_tags.cbor
index 423f5ec..f9f2fb6 100644
--- a/iat-verifier/tests/synthetic_data/missing_tags.cbor
+++ b/iat-verifier/tests/synthetic_data/missing_tags.cbor
Binary files differ
diff --git a/iat-verifier/tests/synthetic_data/synthetic_token_another_token_2.yaml b/iat-verifier/tests/synthetic_data/synthetic_token_another_token_2.yaml
new file mode 100644
index 0000000..94f6d03
--- /dev/null
+++ b/iat-verifier/tests/synthetic_data/synthetic_token_another_token_2.yaml
@@ -0,0 +1,22 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2022, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+syn_claim_int: 12
+syn_boxes:
+ - box_color: red
+ - box_width: 7
+ box_height: 7
+ box_depth: 7
+ box_color: blue
+ - box_width: 5
+ box_height: 5
+ box_depth: 5
+ box_color: green
+ synthetic_internal_token_2:
+ syn_claim_int: 1000
+ syn_boxes:
+ - box_color: grey
diff --git a/iat-verifier/tests/synthetic_token_verifier.py b/iat-verifier/tests/synthetic_token_verifier.py
index f44c87d..a8ac500 100644
--- a/iat-verifier/tests/synthetic_token_verifier.py
+++ b/iat-verifier/tests/synthetic_token_verifier.py
@@ -18,8 +18,7 @@
class SyntheticTokenVerifier(Verifier):
"""A test token that may contain other tokens"""
def get_claim_key(self=None):
- return 0x54a14e11 #TODO: some made up claim. Change claim indexing to use name
- # and this should return None
+ return None # In case of root tokens the key is not used.
def get_claim_name(self=None):
return 'SYNTHETIC_TOKEN'
@@ -93,8 +92,7 @@
class SyntheticTokenVerifier2(Verifier):
"""Another test token that may contain other tokens"""
def get_claim_key(self=None):
- return 0x54a14e11 #TODO: some made up claim. Change claim indexing to use name
- # and this should return None
+ return None # In case of root tokens the key is not used.
def get_claim_name(self=None):
return 'SYNTHETIC_TOKEN_2'
@@ -175,8 +173,7 @@
"""A Test token that is intended to use inside another token"""
def get_claim_key(self=None):
- return 0x54a14e12 #TODO: some made up claim. Change claim indexing to use name
- # and this should return None
+ return 0x54a14e12
def get_claim_name(self=None):
return 'SYNTHETIC_INTERNAL_TOKEN'
@@ -223,8 +220,7 @@
"""Another Test token that is intended to use inside another token"""
def get_claim_key(self=None):
- return 0x54a14e12 #TODO: some made up claim. Change claim indexing to use name
- # and this should return None
+ return 0x54a14e13
def get_claim_name(self=None):
return 'SYNTHETIC_INTERNAL_TOKEN_2'
diff --git a/iat-verifier/tests/test_utils.py b/iat-verifier/tests/test_utils.py
index 20a2e5e..7c54ef6 100644
--- a/iat-verifier/tests/test_utils.py
+++ b/iat-verifier/tests/test_utils.py
@@ -45,21 +45,25 @@
token_map = read_token_map(source_path)
return convert_map_to_token_bytes(token_map, verifier, add_p_header)
+def create_token_file(data_dir, source_name, verifier, dest_path, *, add_p_header=False):
+ """Create a cbor token from a yaml file and write it to a file
+ """
+ token = create_token(
+ data_dir=data_dir,
+ source_name=source_name,
+ verifier=verifier,
+ add_p_header=add_p_header)
+
+ with open(dest_path, 'wb') as wfh:
+ wfh.write(token)
+
def create_token_tmp_file(data_dir, source_name, verifier):
"""Create a cbor token from a yaml file and write it to a temp file. Return the name of the temp
file
"""
temp_file, dest_path = tempfile.mkstemp()
os.close(temp_file)
-
- token = create_token(
- data_dir=data_dir,
- source_name=source_name,
- verifier=verifier,
- add_p_header=False)
-
- with open(dest_path, 'wb') as wfh:
- wfh.write(token)
+ create_token_file(data_dir, source_name, verifier, dest_path)
return dest_path