From 3da9e322b7f9cb5d1de14526d1d6496215852c4d Mon Sep 17 00:00:00 2001 From: Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:59:45 -0400 Subject: [PATCH] Fix subscription username password setting name (#15493) used in analytic --- awx/main/analytics/core.py | 8 ++++---- awx/main/tests/functional/analytics/test_core.py | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/awx/main/analytics/core.py b/awx/main/analytics/core.py index d99ad511c0d7..8ad6bb1d9025 100644 --- a/awx/main/analytics/core.py +++ b/awx/main/analytics/core.py @@ -183,7 +183,7 @@ def gather(dest=None, module=None, subset=None, since=None, until=None, collecti if not ( settings.AUTOMATION_ANALYTICS_URL - and ((settings.REDHAT_USERNAME and settings.REDHAT_PASSWORD) or (settings.SUBSCRIPTION_USERNAME and settings.SUBSCRIPTION_PASSWORD)) + and ((settings.REDHAT_USERNAME and settings.REDHAT_PASSWORD) or (settings.SUBSCRIPTIONS_USERNAME and settings.SUBSCRIPTIONS_PASSWORD)) ): logger.log(log_level, "Not gathering analytics, configuration is invalid. Use --dry-run to gather locally without sending.") return None @@ -369,9 +369,9 @@ def ship(path): rh_password = getattr(settings, 'REDHAT_PASSWORD', None) if rh_user is None or rh_password is None: - logger.info('REDHAT_USERNAME and REDHAT_PASSWORD are not set, using SUBSCRIPTION_USERNAME and SUBSCRIPTION_PASSWORD') - rh_user = getattr(settings, 'SUBSCRIPTION_USERNAME', None) - rh_password = getattr(settings, 'SUBSCRIPTION_PASSWORD', None) + logger.info('REDHAT_USERNAME and REDHAT_PASSWORD are not set, using SUBSCRIPTIONS_USERNAME and SUBSCRIPTIONS_PASSWORD') + rh_user = getattr(settings, 'SUBSCRIPTIONS_USERNAME', None) + rh_password = getattr(settings, 'SUBSCRIPTIONS_PASSWORD', None) if not rh_user: logger.error('REDHAT_USERNAME and SUBSCRIPTIONS_USERNAME are not set') diff --git a/awx/main/tests/functional/analytics/test_core.py b/awx/main/tests/functional/analytics/test_core.py index dc1ae95867fc..d9c87ceab92c 100644 --- a/awx/main/tests/functional/analytics/test_core.py +++ b/awx/main/tests/functional/analytics/test_core.py @@ -87,8 +87,8 @@ def mock_analytic_post(): { 'REDHAT_USERNAME': 'redhat_user', 'REDHAT_PASSWORD': 'redhat_pass', # NOSONAR - 'SUBSCRIPTION_USERNAME': None, - 'SUBSCRIPTION_PASSWORD': None, + 'SUBSCRIPTIONS_USERNAME': None, + 'SUBSCRIPTIONS_PASSWORD': None, }, True, ('redhat_user', 'redhat_pass'), @@ -98,8 +98,8 @@ def mock_analytic_post(): { 'REDHAT_USERNAME': None, 'REDHAT_PASSWORD': None, - 'SUBSCRIPTION_USERNAME': 'subs_user', - 'SUBSCRIPTION_PASSWORD': 'subs_pass', # NOSONAR + 'SUBSCRIPTIONS_USERNAME': 'subs_user', + 'SUBSCRIPTIONS_PASSWORD': 'subs_pass', # NOSONAR }, True, ('subs_user', 'subs_pass'), @@ -109,8 +109,8 @@ def mock_analytic_post(): { 'REDHAT_USERNAME': None, 'REDHAT_PASSWORD': None, - 'SUBSCRIPTION_USERNAME': None, - 'SUBSCRIPTION_PASSWORD': None, + 'SUBSCRIPTIONS_USERNAME': None, + 'SUBSCRIPTIONS_PASSWORD': None, }, False, None, # No request should be made @@ -120,8 +120,8 @@ def mock_analytic_post(): { 'REDHAT_USERNAME': None, 'REDHAT_PASSWORD': 'redhat_pass', # NOSONAR - 'SUBSCRIPTION_USERNAME': 'subs_user', - 'SUBSCRIPTION_PASSWORD': None, + 'SUBSCRIPTIONS_USERNAME': 'subs_user', + 'SUBSCRIPTIONS_PASSWORD': None, }, False, None, # Invalid, no request should be made