diff --git a/.github/workflows/api-and-integration-tests.yml b/.github/workflows/api-and-integration-tests.yml index e69d7b878..bb2433d67 100644 --- a/.github/workflows/api-and-integration-tests.yml +++ b/.github/workflows/api-and-integration-tests.yml @@ -123,6 +123,12 @@ jobs: run: | docker exec provider.yoda sh -c 'set -x ; cat /var/lib/irods/log/rodsLog*' + + - name: Output web server logs + if: failure() + run: | + docker exec portal.yoda sh -c 'set -x ; for log in error.log portal_access.log ; do echo "${log}:" ; cat "/var/log/apache2/$log" ; echo; done' + # Uncomment section below when needed for debugging. # # - name: Setup tmate session for debugging diff --git a/tests/conftest.py b/tests/conftest.py index a13b3b9da..f79a870f6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,6 +6,7 @@ import json import re +import sys import pytest import requests @@ -194,7 +195,12 @@ def login(user, password): # Retrieve the login CSRF token. content = client.get(url, verify=False).content.decode() p = re.compile("tokenValue: '([a-zA-Z0-9._-]*)'") - csrf = p.findall(content)[0] + found_csrf_tokens = p.findall(content) + if len(found_csrf_tokens) == 0: + print(f"Error: could not find login CSRF token in response from server for login of user {user}. Response was:") + print(content) + sys.exit(1) + csrf = found_csrf_tokens[0] # Login as user. if verbose_test: @@ -207,7 +213,12 @@ def login(user, password): # Retrieve the authenticated CSRF token. content = response.content.decode() p = re.compile("tokenValue: '([a-zA-Z0-9._-]*)'") - csrf = p.findall(content)[0] + found_csrf_tokens = p.findall(content) + if len(found_csrf_tokens) == 0: + print(f"Error: could not find authenticated CSRF token in response from server for login of user {user}. Response was:") + print(content) + sys.exit(1) + csrf = found_csrf_tokens[0] # Return CSRF and session cookies. if verbose_test: