mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
--- Removed reference to tower in InventorySource and InventoryUpdate model --- Added a migration for above change --- Added new CONTROLLER* variables in awx/main/models/credentials/__init__.py --- Migrated awxkit to new CONTROLLER* variables --- Updated the tests to use new CONTROLLER* variables --- Fix some issues with upgrade path, rename more cases
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
import pytest
|
|
from requests.exceptions import ConnectionError
|
|
|
|
from awxkit.cli import CLI
|
|
from awxkit import config
|
|
|
|
|
|
def test_host_from_environment():
|
|
cli = CLI()
|
|
cli.parse_args(['awx'], env={'CONTROLLER_HOST': 'https://xyz.local'})
|
|
with pytest.raises(ConnectionError):
|
|
cli.connect()
|
|
assert config.base_url == 'https://xyz.local'
|
|
|
|
|
|
def test_host_from_argv():
|
|
cli = CLI()
|
|
cli.parse_args(['awx', '--conf.host', 'https://xyz.local'])
|
|
with pytest.raises(ConnectionError):
|
|
cli.connect()
|
|
assert config.base_url == 'https://xyz.local'
|
|
|
|
|
|
def test_username_and_password_from_environment():
|
|
cli = CLI()
|
|
cli.parse_args(['awx'], env={'CONTROLLER_USERNAME': 'mary', 'CONTROLLER_PASSWORD': 'secret'})
|
|
with pytest.raises(ConnectionError):
|
|
cli.connect()
|
|
|
|
assert config.credentials.default.username == 'mary'
|
|
assert config.credentials.default.password == 'secret'
|
|
|
|
|
|
def test_username_and_password_argv():
|
|
cli = CLI()
|
|
cli.parse_args(['awx', '--conf.username', 'mary', '--conf.password', 'secret'])
|
|
with pytest.raises(ConnectionError):
|
|
cli.connect()
|
|
|
|
assert config.credentials.default.username == 'mary'
|
|
assert config.credentials.default.password == 'secret'
|
|
|
|
|
|
def test_config_precedence():
|
|
cli = CLI()
|
|
cli.parse_args(['awx', '--conf.username', 'mary', '--conf.password', 'secret'], env={'CONTROLLER_USERNAME': 'IGNORE', 'CONTROLLER_PASSWORD': 'IGNORE'})
|
|
with pytest.raises(ConnectionError):
|
|
cli.connect()
|
|
|
|
assert config.credentials.default.username == 'mary'
|
|
assert config.credentials.default.password == 'secret'
|