@@ -50,9 +50,6 @@ def wrapper(test_cls: "TestSerialization"):
50
50
51
51
class TestSerialization (unittest .TestCase ):
52
52
53
- SIGNED_COMMON = '"spec_version": "1.0.0", "version": 1, \
54
- "expires": "2030-01-01T00:00:00Z"'
55
-
56
53
valid_keys : DataSet = {
57
54
"all" : '{"keytype": "rsa", "scheme": "rsassa-pss-sha256", \
58
55
"keyval": {"public": "foo"}}' ,
@@ -77,14 +74,16 @@ def test_role_serialization(self, test_case_data: str):
77
74
78
75
79
76
valid_roots : DataSet = {
80
- "all" : f'{{ "_type": "root", { SIGNED_COMMON } , "consistent_snapshot": false, \
81
- "keys": {{"keyid" : {{"keytype": "rsa", "scheme": "rsassa-pss-sha256", "keyval": {{"public": "foo"}} }} }}, \
82
- "roles": {{ "targets": {{"keyids": ["keyid"], "threshold": 3}} }} \
83
- }}' ,
84
- "no consistent_snapshot" : f'{{ "_type": "root", { SIGNED_COMMON } , \
85
- "keys": {{"keyid" : {{"keytype": "rsa", "scheme": "rsassa-pss-sha256", "keyval": {{"public": "foo"}} }}}}, \
86
- "roles": {{ "targets": {{"keyids": ["keyid"], "threshold": 3}} }} \
87
- }}' ,
77
+ "all" : '{"_type": "root", "spec_version": "1.0.0", "version": 1, \
78
+ "expires": "2030-01-01T00:00:00Z", "consistent_snapshot": false, \
79
+ "keys": {"keyid" : {"keytype": "rsa", "scheme": "rsassa-pss-sha256", "keyval": {"public": "foo"}}}, \
80
+ "roles": { "targets": {"keyids": ["keyid"], "threshold": 3}} \
81
+ }' ,
82
+ "no consistent_snapshot" : '{ "_type": "root", "spec_version": "1.0.0", "version": 1, \
83
+ "expires": "2030-01-01T00:00:00Z", \
84
+ "keys": {"keyid" : {"keytype": "rsa", "scheme": "rsassa-pss-sha256", "keyval": {"public": "foo"} }}, \
85
+ "roles": { "targets": {"keyids": ["keyid"], "threshold": 3} } \
86
+ }' ,
88
87
}
89
88
90
89
@run_sub_tests_with_dataset (valid_roots )
@@ -107,9 +106,8 @@ def test_metafile_serialization(self, test_case_data: str):
107
106
108
107
109
108
valid_timestamps : DataSet = {
110
- "all" : f'{{ "_type": "timestamp", { SIGNED_COMMON } , \
111
- "meta": {{ "snapshot.json": {{ "hashes": {{"sha256" : "abc"}}, "version": 1 }} }} \
112
- }}'
109
+ "all" : '{ "_type": "timestamp", "spec_version": "1.0.0", "version": 1, "expires": "2030-01-01T00:00:00Z", \
110
+ "meta": {"snapshot.json": {"hashes": {"sha256" : "abc"}, "version": 1}}}'
113
111
}
114
112
115
113
@run_sub_tests_with_dataset (valid_timestamps )
@@ -120,9 +118,8 @@ def test_timestamp_serialization(self, test_case_data: str):
120
118
121
119
122
120
valid_snapshots : DataSet = {
123
- "all" : f'{{ "_type": "snapshot", { SIGNED_COMMON } , \
124
- "meta": {{ "file.txt": \
125
- {{ "hashes": {{"sha256" : "abc"}}, "version": 1 }} }} }}'
121
+ "all" : '{ "_type": "snapshot", "spec_version": "1.0.0", "version": 1, "expires": "2030-01-01T00:00:00Z", \
122
+ "meta": { "file.txt": { "hashes": {"sha256" : "abc"}, "version": 1 }}}'
126
123
}
127
124
128
125
@run_sub_tests_with_dataset (valid_snapshots )
@@ -176,21 +173,21 @@ def test_targetfile_serialization(self, test_case_data: str):
176
173
177
174
178
175
valid_targets : DataSet = {
179
- "all attributes" : f'{{ "_type": "targets", { SIGNED_COMMON } , \
180
- "targets": {{ "file.txt": {{ "length": 12, "hashes": {{ "sha256" : "abc"}} }} } }, \
181
- "delegations": {{ "keys": {{ "keyid" : { {"keytype": "rsa", \
182
- "scheme": "rsassa-pss-sha256", "keyval": {{ "public": "foo"}} }} }}, \
183
- "roles": [ {{ "keyids": ["keyid"], "name": "a", "terminating": true, "threshold": 3}} ]} } \
184
- }} ' ,
185
- "empty targets" : f'{{ "_type": "targets", { SIGNED_COMMON } , \
186
- "targets": {{} }, \
187
- "delegations": {{ "keys": {{ "keyid" : { {"keytype": "rsa", \
188
- "scheme": "rsassa-pss-sha256", "keyval": {{ "public": "foo"}} }} }}, \
189
- "roles": [ {{ "keyids": ["keyid"], "name": "a", "terminating": true, "threshold": 3}} ]} } \
190
- }} ' ,
191
- "no delegations" : f'{{ "_type": "targets", { SIGNED_COMMON } , \
192
- "targets": {{ "file.txt": {{ "length": 12, "hashes": {{ "sha256" : "abc"}} }} } } \
193
- }} '
176
+ "all attributes" : '{ "_type": "targets", "spec_version": "1.0.0", "version": 1, "expires": "2030-01-01T00:00:00Z" , \
177
+ "targets": { "file.txt": {"length": 12, "hashes": {"sha256" : "abc"} } }, \
178
+ "delegations": {"keys": {"keyid" : {"keytype": "rsa", \
179
+ "scheme": "rsassa-pss-sha256", "keyval": {"public": "foo"} }}, \
180
+ "roles": [ {"keyids": ["keyid"], "name": "a", "terminating": true, "threshold": 3} ] } \
181
+ }' ,
182
+ "empty targets" : '{ "_type": "targets", "spec_version": "1.0.0", "version": 1, "expires": "2030-01-01T00:00:00Z" , \
183
+ "targets": {}, \
184
+ "delegations": {"keys": {"keyid" : {"keytype": "rsa", \
185
+ "scheme": "rsassa-pss-sha256", "keyval": {"public": "foo"} }}, \
186
+ "roles": [ {"keyids": ["keyid"], "name": "a", "terminating": true, "threshold": 3} ] } \
187
+ }' ,
188
+ "no delegations" : '{ "_type": "targets", "spec_version": "1.0.0", "version": 1, "expires": "2030-01-01T00:00:00Z" , \
189
+ "targets": { "file.txt": {"length": 12, "hashes": {"sha256" : "abc"} } } \
190
+ }'
194
191
}
195
192
196
193
@run_sub_tests_with_dataset (valid_targets )
0 commit comments