Merge pull request #1481 from MVrachev/fix-role-keyids-order

Metadata API: preserve Role.keyids order
This commit is contained in:
Jussi Kukkonen 2021-07-15 11:52:35 +03:00 committed by GitHub
commit 23e4f5cdcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View file

@ -141,6 +141,7 @@ def test_invalid_role_serialization(self, test_case_data: Dict[str, str]):
valid_roles: DataSet = {
"all": '{"keyids": ["keyid"], "threshold": 3}',
"many keyids": '{"keyids": ["a", "b", "c", "d", "e"], "threshold": 1}',
"unrecognized field": '{"keyids": ["keyid"], "threshold": 3, "foo": "bar"}',
}

View file

@ -614,7 +614,7 @@ def from_dict(cls, role_dict: Dict[str, Any]) -> "Role":
def to_dict(self) -> Dict[str, Any]:
"""Returns the dictionary representation of self."""
return {
"keyids": list(self.keyids),
"keyids": sorted(self.keyids),
"threshold": self.threshold,
**self.unrecognized_fields,
}