From 4094ab27f2cf2e65b50760f005ff1bae05e76ed6 Mon Sep 17 00:00:00 2001 From: Lee Goolsbee Date: Wed, 17 Sep 2025 11:56:14 -0500 Subject: [PATCH] ITPLT-4531 use ansible-httpget UA when making requests to Marketplace --- .../molecule/bitbucket_latest/tests/test_default.py | 12 +++++++++--- .../molecule/confluence_latest/tests/test_default.py | 12 +++++++++--- .../molecule/crowd_latest/tests/test_default.py | 12 +++++++++--- .../molecule/default/tests/test_default.py | 12 +++++++++--- .../jira_software_latest/tests/test_default.py | 12 +++++++++--- .../molecule/jira_tarball/tests/test_default.py | 12 +++++++++--- .../jira_version_latest/tests/test_default.py | 12 +++++++++--- .../servicedesk_latest/tests/test_default.py | 4 +++- 8 files changed, 66 insertions(+), 22 deletions(-) diff --git a/roles/product_install/molecule/bitbucket_latest/tests/test_default.py b/roles/product_install/molecule/bitbucket_latest/tests/test_default.py index bb5b1d8..1862b41 100644 --- a/roles/product_install/molecule/bitbucket_latest/tests/test_default.py +++ b/roles/product_install/molecule/bitbucket_latest/tests/test_default.py @@ -24,14 +24,18 @@ def test_version_file_is_latest(host): verfile = host.file('/media/atl/bitbucket/shared/bitbucket.version') assert verfile.exists - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/bitbucket/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/bitbucket/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] assert verfile.content.decode("UTF-8").strip() == upstream.strip() def test_latest_is_downloaded(host): - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/bitbucket/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/bitbucket/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] @@ -40,7 +44,9 @@ def test_latest_is_downloaded(host): assert installer.user == 'root' def test_completed_lockfile(host): - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/bitbucket/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/bitbucket/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] diff --git a/roles/product_install/molecule/confluence_latest/tests/test_default.py b/roles/product_install/molecule/confluence_latest/tests/test_default.py index 1b3ef88..8449a66 100644 --- a/roles/product_install/molecule/confluence_latest/tests/test_default.py +++ b/roles/product_install/molecule/confluence_latest/tests/test_default.py @@ -24,14 +24,18 @@ def test_version_file_is_latest(host): verfile = host.file('/media/atl/confluence/shared-home/confluence.version') assert verfile.exists - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/confluence/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/confluence/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] assert verfile.content.decode("UTF-8").strip() == upstream.strip() def test_latest_is_downloaded(host): - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/confluence/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/confluence/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] @@ -40,7 +44,9 @@ def test_latest_is_downloaded(host): assert installer.user == 'root' def test_completed_lockfile(host): - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/confluence/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/confluence/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] diff --git a/roles/product_install/molecule/crowd_latest/tests/test_default.py b/roles/product_install/molecule/crowd_latest/tests/test_default.py index 34ffcbc..0bcb90e 100644 --- a/roles/product_install/molecule/crowd_latest/tests/test_default.py +++ b/roles/product_install/molecule/crowd_latest/tests/test_default.py @@ -24,14 +24,18 @@ def test_version_file_is_latest(host): verfile = host.file('/media/atl/crowd/shared/crowd.version') assert verfile.exists - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/crowd/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/crowd/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] assert verfile.content.decode("UTF-8").strip() == upstream.strip() def test_latest_is_downloaded(host): - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/crowd/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/crowd/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] @@ -40,7 +44,9 @@ def test_latest_is_downloaded(host): assert installer.user == 'root' def test_completed_lockfile(host): - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/crowd/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/crowd/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] diff --git a/roles/product_install/molecule/default/tests/test_default.py b/roles/product_install/molecule/default/tests/test_default.py index d157012..8d86cbe 100644 --- a/roles/product_install/molecule/default/tests/test_default.py +++ b/roles/product_install/molecule/default/tests/test_default.py @@ -12,14 +12,18 @@ def test_version_file_is_latest(host): verfile = host.file('/media/atl/jira/shared/jira-core.version') assert verfile.exists - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] assert verfile.content.decode("UTF-8").strip() == upstream.strip() def test_latest_is_downloaded(host): - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] @@ -28,7 +32,9 @@ def test_latest_is_downloaded(host): assert installer.user == 'root' def test_completed_lockfile(host): - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] diff --git a/roles/product_install/molecule/jira_software_latest/tests/test_default.py b/roles/product_install/molecule/jira_software_latest/tests/test_default.py index 653ece1..f368417 100644 --- a/roles/product_install/molecule/jira_software_latest/tests/test_default.py +++ b/roles/product_install/molecule/jira_software_latest/tests/test_default.py @@ -24,14 +24,18 @@ def test_version_file_is_latest(host): verfile = host.file('/media/atl/jira/shared/jira-software.version') assert verfile.exists - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] assert verfile.content.decode("UTF-8").strip() == upstream.strip() def test_latest_is_downloaded(host): - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] @@ -40,7 +44,9 @@ def test_latest_is_downloaded(host): assert installer.user == 'root' def test_completed_lockfile(host): - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] diff --git a/roles/product_install/molecule/jira_tarball/tests/test_default.py b/roles/product_install/molecule/jira_tarball/tests/test_default.py index 97e4f58..de27c2d 100644 --- a/roles/product_install/molecule/jira_tarball/tests/test_default.py +++ b/roles/product_install/molecule/jira_tarball/tests/test_default.py @@ -12,14 +12,18 @@ def test_version_file_is_latest(host): verfile = host.file('/media/atl/jira/shared/jira-core.version') assert verfile.exists - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] assert verfile.content.decode("UTF-8").strip() == upstream.strip() def test_latest_is_downloaded(host): - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] @@ -28,7 +32,9 @@ def test_latest_is_downloaded(host): assert installer.user == 'root' def test_completed_lockfile(host): - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] diff --git a/roles/product_install/molecule/jira_version_latest/tests/test_default.py b/roles/product_install/molecule/jira_version_latest/tests/test_default.py index 93b81b4..1e4499c 100644 --- a/roles/product_install/molecule/jira_version_latest/tests/test_default.py +++ b/roles/product_install/molecule/jira_version_latest/tests/test_default.py @@ -12,14 +12,18 @@ def test_version_file_is_latest(host): verfile = host.file('/media/atl/jira/shared/jira-core.version') assert verfile.exists - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] assert verfile.content.decode("UTF-8").strip() == upstream.strip() def test_latest_is_downloaded(host): - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] @@ -28,7 +32,9 @@ def test_latest_is_downloaded(host): assert installer.user == 'root' def test_completed_lockfile(host): - upstream_fd = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/jira-software/versions") + req.add_header('User-Agent', 'ansible-httpget') + upstream_fd = urllib.request.urlopen(req) upstream_json = json.load(upstream_fd) upstream = upstream_json['_embedded']['versions'][0]['name'] diff --git a/roles/product_install/molecule/servicedesk_latest/tests/test_default.py b/roles/product_install/molecule/servicedesk_latest/tests/test_default.py index bd4eea8..c490f9f 100644 --- a/roles/product_install/molecule/servicedesk_latest/tests/test_default.py +++ b/roles/product_install/molecule/servicedesk_latest/tests/test_default.py @@ -8,7 +8,9 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') def get_latest(): - data = urllib.request.urlopen("https://marketplace.atlassian.com/rest/2/products/key/jira-servicedesk/versions/latest") + req = urllib.request.Request("https://marketplace.atlassian.com/rest/2/products/key/jira-servicedesk/versions/latest") + req.add_header('User-Agent', 'ansible-httpget') + data = urllib.request.urlopen(req) meta = json.loads(data.read().decode("UTF-8")) servicedesk = meta['name'] jira = meta['compatibilities'][0]['hosting']['server']['max']['version']