Skip to content

Commit daea4f5

Browse files
committed
Remove the "SIGNED_COMMON" constant and f-strings
Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
1 parent a774091 commit daea4f5

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

tests/test_metadata_serialization.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def wrapper(test_cls: "TestSerialization"):
5050

5151
class TestSerialization(unittest.TestCase):
5252

53-
SIGNED_COMMON = '"spec_version": "1.0.0", "version": 1, \
54-
"expires": "2030-01-01T00:00:00Z"'
53+
# SIGNED_COMMON = '"spec_version": "1.0.0", "version": 1, \
54+
# "expires": "2030-01-01T00:00:00Z"'
5555

5656
valid_keys: DataSet = {
5757
"all": '{"keytype": "rsa", "scheme": "rsassa-pss-sha256", \
@@ -77,14 +77,16 @@ def test_role_serialization(self, test_case_data: str):
7777

7878

7979
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-
}}',
80+
"all": '{"_type": "root", "spec_version": "1.0.0", "version": 1, \
81+
"expires": "2030-01-01T00:00:00Z", "consistent_snapshot": false, \
82+
"keys": {"keyid" : {"keytype": "rsa", "scheme": "rsassa-pss-sha256", "keyval": {"public": "foo"}}}, \
83+
"roles": { "targets": {"keyids": ["keyid"], "threshold": 3}} \
84+
}',
85+
"no consistent_snapshot": '{ "_type": "root", "spec_version": "1.0.0", "version": 1, \
86+
"expires": "2030-01-01T00:00:00Z", \
87+
"keys": {"keyid" : {"keytype": "rsa", "scheme": "rsassa-pss-sha256", "keyval": {"public": "foo"} }}, \
88+
"roles": { "targets": {"keyids": ["keyid"], "threshold": 3} } \
89+
}',
8890
}
8991

9092
@run_sub_tests_with_dataset(valid_roots)
@@ -107,9 +109,8 @@ def test_metafile_serialization(self, test_case_data: str):
107109

108110

109111
valid_timestamps: DataSet = {
110-
"all": f'{{ "_type": "timestamp", {SIGNED_COMMON}, \
111-
"meta": {{ "snapshot.json": {{ "hashes": {{"sha256" : "abc"}}, "version": 1 }} }} \
112-
}}'
112+
"all": '{ "_type": "timestamp", "spec_version": "1.0.0", "version": 1, "expires": "2030-01-01T00:00:00Z", \
113+
"meta": {"snapshot.json": {"hashes": {"sha256" : "abc"}, "version": 1}}}'
113114
}
114115

115116
@run_sub_tests_with_dataset(valid_timestamps)
@@ -120,9 +121,8 @@ def test_timestamp_serialization(self, test_case_data: str):
120121

121122

122123
valid_snapshots: DataSet = {
123-
"all": f'{{ "_type": "snapshot", {SIGNED_COMMON}, \
124-
"meta": {{ "file.txt": \
125-
{{ "hashes": {{"sha256" : "abc"}}, "version": 1 }} }} }}'
124+
"all": '{ "_type": "snapshot", "spec_version": "1.0.0", "version": 1, "expires": "2030-01-01T00:00:00Z", \
125+
"meta": { "file.txt": { "hashes": {"sha256" : "abc"}, "version": 1 }}}'
126126
}
127127

128128
@run_sub_tests_with_dataset(valid_snapshots)
@@ -176,21 +176,21 @@ def test_targetfile_serialization(self, test_case_data: str):
176176

177177

178178
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-
}}'
179+
"all attributes": '{"_type": "targets", "spec_version": "1.0.0", "version": 1, "expires": "2030-01-01T00:00:00Z", \
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": '{"_type": "targets", "spec_version": "1.0.0", "version": 1, "expires": "2030-01-01T00:00:00Z", \
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": '{"_type": "targets", "spec_version": "1.0.0", "version": 1, "expires": "2030-01-01T00:00:00Z", \
192+
"targets": { "file.txt": {"length": 12, "hashes": {"sha256" : "abc"} } } \
193+
}'
194194
}
195195

196196
@run_sub_tests_with_dataset(valid_targets)

0 commit comments

Comments
 (0)