Skip to content

Commit

Permalink
Test at least one delegated bin has path_hash_prefixes
Browse files Browse the repository at this point in the history
When testing delegate_hashed_bins to ensure that hash_path_prefixes
map to the generated name of the bin, also check to ensure that at least
one of the delegations contains one or more path_hash_prefixes.

Signed-off-by: Joshua Lock <[email protected]>
  • Loading branch information
joshuagl committed Mar 30, 2020
1 parent f5cbe09 commit f362544
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/test_repository_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1374,10 +1374,13 @@ def test_delegate_hashed_bins(self):
def check_prefixes_match_range():
roleinfo = tuf.roledb.get_roleinfo(self.targets_object.rolename,
'test_repository')
have_prefixes = False

for delegated_role in roleinfo['delegations']['roles']:
if len(delegated_role['path_hash_prefixes']) > 0:
rolename = delegated_role['name']
prefixes = delegated_role['path_hash_prefixes']
have_prefixes = True

if len(prefixes) > 1:
prefix_range = "{}-{}".format(prefixes[0], prefixes[-1])
Expand All @@ -1386,6 +1389,8 @@ def check_prefixes_match_range():

self.assertEqual(rolename, prefix_range)

# We expect at least one delegation with some path_hash_prefixes
self.assertTrue(have_prefixes)


# Test delegate_hashed_bins() and verify that 16 hashed bins have
Expand Down

0 comments on commit f362544

Please sign in to comment.