Skip to content

Commit 23e4f5c

Browse files
author
Jussi Kukkonen
authored
Merge pull request #1481 from MVrachev/fix-role-keyids-order
Metadata API: preserve Role.keyids order
2 parents 04bbc03 + df9f3df commit 23e4f5c

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

tests/test_metadata_serialization.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def test_invalid_role_serialization(self, test_case_data: Dict[str, str]):
141141

142142
valid_roles: DataSet = {
143143
"all": '{"keyids": ["keyid"], "threshold": 3}',
144+
"many keyids": '{"keyids": ["a", "b", "c", "d", "e"], "threshold": 1}',
144145
"unrecognized field": '{"keyids": ["keyid"], "threshold": 3, "foo": "bar"}',
145146
}
146147

tuf/api/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ def from_dict(cls, role_dict: Dict[str, Any]) -> "Role":
614614
def to_dict(self) -> Dict[str, Any]:
615615
"""Returns the dictionary representation of self."""
616616
return {
617-
"keyids": list(self.keyids),
617+
"keyids": sorted(self.keyids),
618618
"threshold": self.threshold,
619619
**self.unrecognized_fields,
620620
}

0 commit comments

Comments
 (0)