From 67fbc2b867aa82aa75cecb77966477641f650b83 Mon Sep 17 00:00:00 2001 From: Renata Date: Mon, 11 Nov 2024 18:12:07 -0500 Subject: [PATCH] fix: minor create repo fix --- taf/tests/tuf/test_create_edit_repo/test_keys.py | 3 ++- taf/tuf/repository.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/taf/tests/tuf/test_create_edit_repo/test_keys.py b/taf/tests/tuf/test_create_edit_repo/test_keys.py index b80ba48e..112aec12 100644 --- a/taf/tests/tuf/test_create_edit_repo/test_keys.py +++ b/taf/tests/tuf/test_create_edit_repo/test_keys.py @@ -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 diff --git a/taf/tuf/repository.py b/taf/tuf/repository.py index e5032af6..615ffefd 100644 --- a/taf/tuf/repository.py +++ b/taf/tuf/repository.py @@ -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( @@ -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]: