mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
Metadata test full serialization cycle
Replace the usage of Metadata.to_dict inside test_valid_metadata_serialization and instead use Metadata.to_bytes() in order to test that the full serialization cycle is working as expected: Metadata.from_bytes -> Metadata.to_bytes Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
This commit is contained in:
parent
a347d034a2
commit
be2c8f078c
1 changed files with 9 additions and 2 deletions
|
|
@ -73,8 +73,15 @@ def test_invalid_metadata_serialization(self, test_data: bytes) -> None:
|
|||
@utils.run_sub_tests_with_dataset(valid_metadata)
|
||||
def test_valid_metadata_serialization(self, test_case_data: bytes) -> None:
|
||||
md = Metadata.from_bytes(test_case_data)
|
||||
input_dict = json.loads(test_case_data)
|
||||
self.assertDictEqual(input_dict, md.to_dict())
|
||||
|
||||
# Convert to a JSON and sort the keys the way we do in JSONSerializer.
|
||||
separators = (",", ":")
|
||||
test_json = json.loads(test_case_data)
|
||||
test_bytes = json.dumps(
|
||||
test_json, separators=separators, sort_keys=True
|
||||
).encode("utf-8")
|
||||
|
||||
self.assertEqual(test_bytes, md.to_bytes())
|
||||
|
||||
invalid_signatures: utils.DataSet = {
|
||||
"missing keyid attribute in a signature": '{ "sig": "abc" }',
|
||||
|
|
|
|||
Loading…
Reference in a new issue