1diff --git a/framework/replay/download_utils.py b/framework/replay/download_utils.py 2index 3119a24a2..4e776ca85 100644 3--- a/framework/replay/download_utils.py 4+++ b/framework/replay/download_utils.py 5@@ -31,6 +31,7 @@ import xml.etree.ElementTree as ET 6 from email.utils import formatdate 7 from os import path 8 from time import time 9+from urllib.parse import urlparse 10 import requests 11 from requests.adapters import HTTPAdapter, Retry 12 from requests.utils import requote_uri 13@@ -88,7 +89,7 @@ def get_minio_credentials(url): 14 minio_credentials['SessionToken']) 15 16 17-def get_authorization_headers(url, resource): 18+def get_minio_authorization_headers(url, resource): 19 minio_key, minio_secret, minio_token = get_minio_credentials(url) 20 21 content_type = 'application/octet-stream' 22@@ -106,6 +107,17 @@ def get_authorization_headers(url, resource): 23 return headers 24 25 26+def get_jwt_authorization_headers(url, resource): 27+ date = formatdate(timeval=None, localtime=False, usegmt=True) 28+ jwt = OPTIONS.download['jwt'] 29+ host = urlparse(url).netloc 30+ 31+ headers = {'Host': host, 32+ 'Date': date, 33+ 'Authorization': 'Bearer %s' % (jwt)} 34+ return headers 35+ 36+ 37 def download(url: str, file_path: str, headers, attempts=2) -> None: 38 """Downloads a URL content into a file 39 40@@ -174,7 +186,9 @@ def ensure_file(file_path): 41 assert OPTIONS.download['minio_bucket'] 42 assert OPTIONS.download['role_session_name'] 43 assert OPTIONS.download['jwt'] 44- headers = get_authorization_headers(url, file_path) 45+ headers = get_minio_authorization_headers(url, file_path) 46+ elif OPTIONS.download['jwt']: 47+ headers = get_jwt_authorization_headers(url, file_path) 48 else: 49 headers = None 50 51diff --git a/unittests/framework/replay/test_download_utils.py b/unittests/framework/replay/test_download_utils.py 52index 1e78b26e7..749c5d835 100644 53--- a/unittests/framework/replay/test_download_utils.py 54+++ b/unittests/framework/replay/test_download_utils.py 55@@ -195,3 +195,17 @@ class TestDownloadUtils(object): 56 get_request = requests_mock.request_history[1] 57 assert(get_request.method == 'GET') 58 assert(requests_mock.request_history[1].headers['Authorization'].startswith('AWS Key')) 59+ 60+ def test_jwt_authorization(self, requests_mock): 61+ """download_utils.ensure_file: Check we send the authentication headers to the server""" 62+ # reset minio_host from previous tests 63+ OPTIONS.download['minio_host'] = '' 64+ OPTIONS.download['jwt'] = 'jwt' 65+ 66+ assert not self.trace_file.check() 67+ download_utils.ensure_file(self.trace_path) 68+ TestDownloadUtils.check_same_file(self.trace_file, "remote") 69+ 70+ get_request = requests_mock.request_history[0] 71+ assert(get_request.method == 'GET') 72+ assert(requests_mock.request_history[0].headers['Authorization'].startswith('Bearer')) 73