diff --git a/tests/test_metadata_serialization.py b/tests/test_metadata_serialization.py index 9f228d4c8f..0f5ebb8975 100644 --- a/tests/test_metadata_serialization.py +++ b/tests/test_metadata_serialization.py @@ -168,6 +168,25 @@ def test_role_serialization(self, test_case_data: str): "keys": {"keyid" : {"keytype": "rsa", "scheme": "rsassa-pss-sha256", "keyval": {"public": "foo"}}}, \ "roles": { "targets": {"keyids": ["keyid"], "threshold": 3}}, \ "foo": "bar"}', + "many keys": '{"_type": "root", "spec_version": "1.0.0", "version": 1, \ + "expires": "2030-01-01T00:00:00Z", "consistent_snapshot": false, \ + "keys": { \ + "keyid1" : {"keytype": "rsa", "scheme": "rsassa-pss-sha256", "keyval": {"public": "foo"}}, \ + "keyid2" : {"keytype": "ed25519", "scheme": "ed25519", "keyval": {"public": "bar"}}}, \ + "roles": { "targets": {"keyids": ["keyid"], "threshold": 3}} \ + }', + "many roles": '{"_type": "root", "spec_version": "1.0.0", "version": 1, \ + "expires": "2030-01-01T00:00:00Z", "consistent_snapshot": false, \ + "keys": {"keyid" : {"keytype": "rsa", "scheme": "rsassa-pss-sha256", "keyval": {"public": "foo"}}}, \ + "roles": { \ + "targets": {"keyids": ["keyid1"], "threshold": 1}, \ + "snapshot": {"keyids": ["keyid2"], "threshold": 1}} \ + }', + "many role keyids": '{"_type": "root", "spec_version": "1.0.0", "version": 1, \ + "expires": "2030-01-01T00:00:00Z", "consistent_snapshot": false, \ + "keys": {"keyid" : {"keytype": "rsa", "scheme": "rsassa-pss-sha256", "keyval": {"public": "foo"}}}, \ + "roles": {"targets": {"keyids": ["keyid1", "keyid2"], "threshold": 3}} \ + }', } @run_sub_tests_with_dataset(valid_roots) @@ -184,6 +203,7 @@ def test_root_serialization(self, test_case_data: str): "empty hashes dict": '{"version": 1, "length": 1, "hashes": {}}', "hashes wrong type": '{"version": 1, "length": 1, "hashes": 1}', "hashes values wrong type": '{"version": 1, "length": 1, "hashes": {"sha256": 1}}', + "zero hashes": '{"version": 1, "length": 1, "hashes": {}}', } @run_sub_tests_with_dataset(invalid_metafiles) @@ -198,6 +218,7 @@ def test_invalid_metafile_serialization(self, test_case_data: Dict[str, str]): "no length": '{"hashes": {"sha256" : "abc"}, "version": 1 }', "no hashes": '{"length": 12, "version": 1}', "unrecognized field": '{"hashes": {"sha256" : "abc"}, "length": 12, "version": 1, "foo": "bar"}', + "many hashes": '{"hashes": {"sha256" : "abc", "sha512": "cde"}, "length": 12, "version": 1}', } @run_sub_tests_with_dataset(valid_metafiles) @@ -246,6 +267,9 @@ def test_snapshot_serialization(self, test_case_data: str): '{"keyids": ["keyid"], "name": "a", "terminating": true, "threshold": 3}', "unrecognized field": '{"keyids": ["keyid"], "name": "a", "terminating": true, "threshold": 3, "foo": "bar"}', + "many keyids": + '{"keyids": ["keyid1", "keyid2"], "name": "a", "paths": ["fn1", "fn2"], \ + "terminating": false, "threshold": 1}', } @run_sub_tests_with_dataset(valid_delegated_roles) @@ -262,6 +286,12 @@ def test_delegated_role_serialization(self, test_case_data: str): '{"keys": {"keyid" : {"keytype": "rsa", "scheme": "rsassa-pss-sha256", "keyval": {"public": "foo"}}}, \ "roles": [ {"keyids": ["keyid"], "name": "a", "terminating": true, "threshold": 3} ], \ "foo": "bar"}', + "many keys": + '{"keys": { \ + "keyid1" : {"keytype": "rsa", "scheme": "rsassa-pss-sha256", "keyval": {"public": "foo"}}, \ + "keyid2" : {"keytype": "ed25519", "scheme": "ed25519", "keyval": {"public": "bar"}}}, \ + "roles": [ {"keyids": ["keyid"], "name": "a", "terminating": true, "threshold": 3} ] \ + }', } @run_sub_tests_with_dataset(valid_delegations)