-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update AWX collection to use basic authentication #15554
Update AWX collection to use basic authentication #15554
Conversation
4ce2947
to
8e8b94f
Compare
b697078
to
dd58af3
Compare
f390da9
to
4bd34d9
Compare
Update AWX collection to use basic authentication when oauth token not provided, and when username and password provided.
4bd34d9
to
263d82f
Compare
Quality Gate passedIssues Measures |
|
||
|
||
@pytest.mark.parametrize( | ||
"collection_type, env_prefix, controller_host, app_key, endpoint, expected", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pro tip: this can be an interable of strings which typically reads better.
from __future__ import absolute_import, division, print_function | ||
|
||
import os | ||
from unittest import mock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In pytest, it's customary to use the built-in monkeypatch
fixture or mocker
provided by the pytest-mock
plugin.
@@ -0,0 +1,55 @@ | |||
from __future__ import absolute_import, division, print_function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this future import is only useful under python 2
controller_api = controller_api_class(argument_spec={}, direct_params=dict(controller_host=controller_host)) | ||
controller_api._COLLECTION_TYPE = collection_type | ||
if env_prefix: | ||
with mock.patch.dict(os.environ, {"CONTROLLER_OPTIONAL_API_URLPATTERN_PREFIX": env_prefix}): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For conditional CM, there's a from contextlib import nullcontext
which can make this more elegant.
Additionally, the builtin fixture can give you a monkeypatch.setenv()
w/o needing to import anything or integrate third parties.
import pytest | ||
|
||
|
||
@pytest.mark.parametrize( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a matrix of repeated things. It is possible to produce it using several stacked parametrize decorators.
The changes in ansible#15554 will cause a few collection tests to fail, depending on what the test configuration is. This changes the tests to look for a specific warning rather than counting the number of warnings emitted.
SUMMARY
Update AWX collection to use basic authentication when collection_type is awx,
else try to create a token from gateway and controller when failed todo so use basic authentication instead.
ISSUE TYPE
COMPONENT NAME
AWX VERSION
ADDITIONAL INFORMATION
Tested when connected to awx service with _COLLETION_TYPE ="awx"
Tested when connected to proxy with _COLLETION_TYPE ="tower"
Result