Skip to content

Commit

Permalink
Fix subscription username password setting name (#15493)
Browse files Browse the repository at this point in the history
used in analytic
  • Loading branch information
TheRealHaoLiu authored Sep 5, 2024
1 parent 79684ab commit 3da9e32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions awx/main/analytics/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
16 changes: 8 additions & 8 deletions awx/main/tests/functional/analytics/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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'),
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3da9e32

Please sign in to comment.