mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-06 08:21:50 -05:00
Add support for Insights as an inventory source
This commit is contained in:
5
awx/main/tests/data/inventory/plugins/insights/env.json
Normal file
5
awx/main/tests/data/inventory/plugins/insights/env.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never",
|
||||
"INSIGHTS_USER": "fooo",
|
||||
"INSIGHTS_PASSWORD": "fooo"
|
||||
}
|
||||
@@ -652,6 +652,31 @@ def test_satellite6_create_ok(post, organization, admin):
|
||||
assert decrypt_field(cred, 'password') == 'some_password'
|
||||
|
||||
|
||||
#
|
||||
# RH Insights Credentials
|
||||
#
|
||||
@pytest.mark.django_db
|
||||
def test_insights_create_ok(post, organization, admin):
|
||||
params = {
|
||||
'credential_type': 1,
|
||||
'name': 'Best credential ever',
|
||||
'inputs': {
|
||||
'username': 'some_username',
|
||||
'password': 'some_password',
|
||||
},
|
||||
}
|
||||
sat6 = CredentialType.defaults['insights']()
|
||||
sat6.save()
|
||||
params['organization'] = organization.id
|
||||
response = post(reverse('api:credential_list'), params, admin)
|
||||
assert response.status_code == 201
|
||||
|
||||
assert Credential.objects.count() == 1
|
||||
cred = Credential.objects.all()[:1].get()
|
||||
assert cred.inputs['username'] == 'some_username'
|
||||
assert decrypt_field(cred, 'password') == 'some_password'
|
||||
|
||||
|
||||
#
|
||||
# AWS Credentials
|
||||
#
|
||||
|
||||
@@ -209,6 +209,7 @@ class TestInventorySourceInjectors:
|
||||
('vmware', 'community.vmware.vmware_vm_inventory'),
|
||||
('rhv', 'ovirt.ovirt.ovirt'),
|
||||
('satellite6', 'theforeman.foreman.foreman'),
|
||||
('insights', 'redhatinsights.insights.insights'),
|
||||
('tower', 'awx.awx.tower'),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1746,6 +1746,34 @@ class TestInventoryUpdateCredentials(TestJobExecution):
|
||||
assert env["FOREMAN_PASSWORD"] == "secret"
|
||||
assert safe_env["FOREMAN_PASSWORD"] == tasks.HIDDEN_PASSWORD
|
||||
|
||||
def test_insights_source(self, inventory_update, private_data_dir, mocker):
|
||||
task = tasks.RunInventoryUpdate()
|
||||
task.instance = inventory_update
|
||||
insights = CredentialType.defaults['insights']()
|
||||
inventory_update.source = 'insights'
|
||||
|
||||
def get_cred():
|
||||
cred = Credential(
|
||||
pk=1,
|
||||
credential_type=insights,
|
||||
inputs={
|
||||
'username': 'bob',
|
||||
'password': 'secret',
|
||||
},
|
||||
)
|
||||
cred.inputs['password'] = encrypt_field(cred, 'password')
|
||||
return cred
|
||||
|
||||
inventory_update.get_cloud_credential = get_cred
|
||||
inventory_update.get_extra_credentials = mocker.Mock(return_value=[])
|
||||
|
||||
env = task.build_env(inventory_update, private_data_dir, False)
|
||||
safe_env = build_safe_env(env)
|
||||
|
||||
assert env["INSIGHTS_USER"] == "bob"
|
||||
assert env["INSIGHTS_PASSWORD"] == "secret"
|
||||
assert safe_env['INSIGHTS_PASSWORD'] == tasks.HIDDEN_PASSWORD
|
||||
|
||||
@pytest.mark.parametrize('verify', [True, False])
|
||||
def test_tower_source(self, verify, inventory_update, private_data_dir, mocker):
|
||||
task = tasks.RunInventoryUpdate()
|
||||
|
||||
Reference in New Issue
Block a user