mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
new API: make sure targets in Targets can be empty
This change is relevant to the new metadata class Targets.
In the specification, when describing the Targets metadata file format
and more precisely "TARGETPATH" (or targets containing the actual
target files) it's said:
"It is allowed to have a TARGETS object with no TARGETPATH elements.
This can be used to indicate that no target files are available."
If there is no "TARGETPATH" keys for the dictionary "targets", this
would mean that "Targets.targets" is {}.
Make sure we test for that.
See: https://theupdateframework.github.io/specification/latest/#targetpath
Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
This commit is contained in:
parent
f935ea33da
commit
737c249067
1 changed files with 7 additions and 0 deletions
|
|
@ -585,6 +585,13 @@ def test_metadata_targets(self):
|
|||
targets.signed.targets[filename].to_dict(), fileinfo.to_dict()
|
||||
)
|
||||
|
||||
# Test from_dict/to_dict Targets with empty targets.
|
||||
targets_dict = copy.deepcopy(targets.to_dict())
|
||||
targets_dict["signed"]["targets"] = {}
|
||||
tmp_dict = copy.deepcopy(targets_dict["signed"])
|
||||
targets_obj = Targets.from_dict(tmp_dict)
|
||||
self.assertEqual(targets_dict["signed"], targets_obj.to_dict())
|
||||
|
||||
# Test from_dict/to_dict Targets without delegations
|
||||
targets_dict = targets.to_dict()
|
||||
del targets_dict["signed"]["delegations"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue