Skip to content

Commit

Permalink
fix: minor create repo fix
Browse files Browse the repository at this point in the history
  • Loading branch information
renatav committed Nov 11, 2024
1 parent d9e5cc0 commit 67fbc2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion taf/tests/tuf/test_create_edit_repo/test_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ def test_revoke_metadata_key(tuf_repo, signers_with_delegations, public_keys_wit
assert tuf_repo.snapshot().version == 3
assert tuf_repo.targets().version == 3

# now try removing one of delegated key again
assert delegated_key1_id in tuf_repo._role_obj("delegated_role").keyids
# now try removing one of delegated keys again
removed_from_roles, not_added_roles, less_than_threshold_roles = tuf_repo.revoke_metadata_key(signers_with_delegations, ["delegated_role"], delegated_key1_id)
assert len(removed_from_roles) == 1
assert len(not_added_roles) == 0
Expand Down
6 changes: 4 additions & 2 deletions taf/tuf/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ def create(self, roles_keys_data: RolesKeysData, signers: dict, additional_verif
continue
parent = role.parent.name
parent_obj = target_roles.get(parent)
keyids = []
for signer in signers[role.name]:
self.signer_cache[role.name][key_id] = signer
delegated_role = DelegatedRole(
Expand All @@ -421,7 +420,10 @@ def create(self, roles_keys_data: RolesKeysData, signers: dict, additional_verif

for parent, role_data in delegations_per_parent.items():
parent_obj = target_roles[parent]
delegations = Delegations(roles=role_data, keys=public_keys[role.name])
delegated_keys = {}
for delegated_role_name in role_data:
delegated_keys.update(public_keys[delegated_role_name])
delegations = Delegations(roles=role_data, keys=delegated_keys)
parent_obj.delegations = delegations

for signed in [root, Timestamp(), sn, targets]:
Expand Down

0 comments on commit 67fbc2b

Please sign in to comment.