Skip to content

Commit

Permalink
ipatests: fixture can produce IndexError
Browse files Browse the repository at this point in the history
The fixture issue_and_expire_acme_cert returns a function
that fills the hosts array. If the function is not called in
the test (for instance because a test is skipped, as in
TestACMEPrune::test_prune_cert_search_size_limit), hosts = []
and hosts[0] raises an IndexError.

Fix the fixture to check first that hosts is not empty.

Related: https://pagure.io/freeipa/issue/9348

Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
Reviewed-By: Mohammad Rizwan Yusuf <myusuf@redhat.com>
  • Loading branch information
flo-renaud committed Aug 16, 2023
1 parent 33c2740 commit a6f0111
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ipatests/test_integration/test_acme.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,13 @@ def _issue_and_expire_acme_cert(
tasks.move_date(host, 'start', '-90days-60minutes')

# restart ipa services as date moved and wait to get things settle
time.sleep(10)
hosts[0].run_command(['ipactl', 'restart'])
time.sleep(10)
# if the internal fixture was not called (for instance because the test
# was skipped), hosts = [] and hosts[0] would produce an IndexError
# exception.
if hosts:
time.sleep(10)
hosts[0].run_command(['ipactl', 'restart'])
time.sleep(10)


class TestACMERenew(IntegrationTest):
Expand Down

0 comments on commit a6f0111

Please sign in to comment.