mirror of
https://github.com/ansible/awx.git
synced 2026-03-26 21:35:01 -02:30
move code linting to a stricter pep8-esque auto-formatting tool, black
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
import pytest
|
||||
@@ -17,13 +18,7 @@ def aim_cred_type():
|
||||
@pytest.fixture
|
||||
def source_cred_aim(aim_cred_type):
|
||||
return Credential.objects.create(
|
||||
name='CyberArk AIM Cred',
|
||||
credential_type=aim_cred_type,
|
||||
inputs={
|
||||
"url": "https://cyberark.example.com",
|
||||
"app_id": "myAppID",
|
||||
"verify": "false"
|
||||
}
|
||||
name='CyberArk AIM Cred', credential_type=aim_cred_type, inputs={"url": "https://cyberark.example.com", "app_id": "myAppID", "verify": "false"}
|
||||
)
|
||||
|
||||
|
||||
@@ -31,20 +26,19 @@ def source_cred_aim(aim_cred_type):
|
||||
def test_aim_credential_source(run_module, admin_user, organization, source_cred_aim, silence_deprecation):
|
||||
ct = CredentialType.defaults['ssh']()
|
||||
ct.save()
|
||||
tgt_cred = Credential.objects.create(
|
||||
name='Test Machine Credential',
|
||||
organization=organization,
|
||||
credential_type=ct,
|
||||
inputs={'username': 'bob'}
|
||||
)
|
||||
tgt_cred = Credential.objects.create(name='Test Machine Credential', organization=organization, credential_type=ct, inputs={'username': 'bob'})
|
||||
|
||||
result = run_module('tower_credential_input_source', dict(
|
||||
source_credential=source_cred_aim.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"object_query": "Safe=SUPERSAFE;Object=MyAccount"},
|
||||
state='present'
|
||||
), admin_user)
|
||||
result = run_module(
|
||||
'tower_credential_input_source',
|
||||
dict(
|
||||
source_credential=source_cred_aim.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"object_query": "Safe=SUPERSAFE;Object=MyAccount"},
|
||||
state='present',
|
||||
),
|
||||
admin_user,
|
||||
)
|
||||
|
||||
assert not result.get('failed', False), result.get('msg', result)
|
||||
assert result.get('changed'), result
|
||||
@@ -68,12 +62,7 @@ def source_cred_conjur(organization):
|
||||
return Credential.objects.create(
|
||||
name='CyberArk CONJUR Cred',
|
||||
credential_type=ct,
|
||||
inputs={
|
||||
"url": "https://cyberark.example.com",
|
||||
"api_key": "myApiKey",
|
||||
"account": "account",
|
||||
"username": "username"
|
||||
}
|
||||
inputs={"url": "https://cyberark.example.com", "api_key": "myApiKey", "account": "account", "username": "username"},
|
||||
)
|
||||
|
||||
|
||||
@@ -81,20 +70,19 @@ def source_cred_conjur(organization):
|
||||
def test_conjur_credential_source(run_module, admin_user, organization, source_cred_conjur, silence_deprecation):
|
||||
ct = CredentialType.defaults['ssh']()
|
||||
ct.save()
|
||||
tgt_cred = Credential.objects.create(
|
||||
name='Test Machine Credential',
|
||||
organization=organization,
|
||||
credential_type=ct,
|
||||
inputs={'username': 'bob'}
|
||||
)
|
||||
tgt_cred = Credential.objects.create(name='Test Machine Credential', organization=organization, credential_type=ct, inputs={'username': 'bob'})
|
||||
|
||||
result = run_module('tower_credential_input_source', dict(
|
||||
source_credential=source_cred_conjur.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"secret_path": "/path/to/secret"},
|
||||
state='present'
|
||||
), admin_user)
|
||||
result = run_module(
|
||||
'tower_credential_input_source',
|
||||
dict(
|
||||
source_credential=source_cred_conjur.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"secret_path": "/path/to/secret"},
|
||||
state='present',
|
||||
),
|
||||
admin_user,
|
||||
)
|
||||
|
||||
assert not result.get('failed', False), result.get('msg', result)
|
||||
assert result.get('changed'), result
|
||||
@@ -123,8 +111,8 @@ def source_cred_hashi_secret(organization):
|
||||
"token": "myApiKey",
|
||||
"role_id": "role",
|
||||
"secret_id": "secret",
|
||||
"default_auth_path": "path-to-approle"
|
||||
}
|
||||
"default_auth_path": "path-to-approle",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -132,20 +120,19 @@ def source_cred_hashi_secret(organization):
|
||||
def test_hashi_secret_credential_source(run_module, admin_user, organization, source_cred_hashi_secret, silence_deprecation):
|
||||
ct = CredentialType.defaults['ssh']()
|
||||
ct.save()
|
||||
tgt_cred = Credential.objects.create(
|
||||
name='Test Machine Credential',
|
||||
organization=organization,
|
||||
credential_type=ct,
|
||||
inputs={'username': 'bob'}
|
||||
)
|
||||
tgt_cred = Credential.objects.create(name='Test Machine Credential', organization=organization, credential_type=ct, inputs={'username': 'bob'})
|
||||
|
||||
result = run_module('tower_credential_input_source', dict(
|
||||
source_credential=source_cred_hashi_secret.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"secret_path": "/path/to/secret", "auth_path": "/path/to/auth", "secret_backend": "backend", "secret_key": "a_key"},
|
||||
state='present'
|
||||
), admin_user)
|
||||
result = run_module(
|
||||
'tower_credential_input_source',
|
||||
dict(
|
||||
source_credential=source_cred_hashi_secret.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"secret_path": "/path/to/secret", "auth_path": "/path/to/auth", "secret_backend": "backend", "secret_key": "a_key"},
|
||||
state='present',
|
||||
),
|
||||
admin_user,
|
||||
)
|
||||
|
||||
assert not result.get('failed', False), result.get('msg', result)
|
||||
assert result.get('changed'), result
|
||||
@@ -172,12 +159,7 @@ def source_cred_hashi_ssh(organization):
|
||||
return Credential.objects.create(
|
||||
name='HashiCorp ssh Cred',
|
||||
credential_type=ct,
|
||||
inputs={
|
||||
"url": "https://ssh.hash.example.com",
|
||||
"token": "myApiKey",
|
||||
"role_id": "role",
|
||||
"secret_id": "secret"
|
||||
}
|
||||
inputs={"url": "https://ssh.hash.example.com", "token": "myApiKey", "role_id": "role", "secret_id": "secret"},
|
||||
)
|
||||
|
||||
|
||||
@@ -185,20 +167,19 @@ def source_cred_hashi_ssh(organization):
|
||||
def test_hashi_ssh_credential_source(run_module, admin_user, organization, source_cred_hashi_ssh, silence_deprecation):
|
||||
ct = CredentialType.defaults['ssh']()
|
||||
ct.save()
|
||||
tgt_cred = Credential.objects.create(
|
||||
name='Test Machine Credential',
|
||||
organization=organization,
|
||||
credential_type=ct,
|
||||
inputs={'username': 'bob'}
|
||||
)
|
||||
tgt_cred = Credential.objects.create(name='Test Machine Credential', organization=organization, credential_type=ct, inputs={'username': 'bob'})
|
||||
|
||||
result = run_module('tower_credential_input_source', dict(
|
||||
source_credential=source_cred_hashi_ssh.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"secret_path": "/path/to/secret", "auth_path": "/path/to/auth", "role": "role", "public_key": "a_key", "valid_principals": "some_value"},
|
||||
state='present'
|
||||
), admin_user)
|
||||
result = run_module(
|
||||
'tower_credential_input_source',
|
||||
dict(
|
||||
source_credential=source_cred_hashi_ssh.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"secret_path": "/path/to/secret", "auth_path": "/path/to/auth", "role": "role", "public_key": "a_key", "valid_principals": "some_value"},
|
||||
state='present',
|
||||
),
|
||||
admin_user,
|
||||
)
|
||||
|
||||
assert not result.get('failed', False), result.get('msg', result)
|
||||
assert result.get('changed'), result
|
||||
@@ -232,7 +213,7 @@ def source_cred_azure_kv(organization):
|
||||
"secret": "secret",
|
||||
"tenant": "tenant",
|
||||
"cloud_name": "the_cloud",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -240,20 +221,19 @@ def source_cred_azure_kv(organization):
|
||||
def test_azure_kv_credential_source(run_module, admin_user, organization, source_cred_azure_kv, silence_deprecation):
|
||||
ct = CredentialType.defaults['ssh']()
|
||||
ct.save()
|
||||
tgt_cred = Credential.objects.create(
|
||||
name='Test Machine Credential',
|
||||
organization=organization,
|
||||
credential_type=ct,
|
||||
inputs={'username': 'bob'}
|
||||
)
|
||||
tgt_cred = Credential.objects.create(name='Test Machine Credential', organization=organization, credential_type=ct, inputs={'username': 'bob'})
|
||||
|
||||
result = run_module('tower_credential_input_source', dict(
|
||||
source_credential=source_cred_azure_kv.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"secret_field": "my_pass"},
|
||||
state='present'
|
||||
), admin_user)
|
||||
result = run_module(
|
||||
'tower_credential_input_source',
|
||||
dict(
|
||||
source_credential=source_cred_azure_kv.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"secret_field": "my_pass"},
|
||||
state='present',
|
||||
),
|
||||
admin_user,
|
||||
)
|
||||
|
||||
assert not result.get('failed', False), result.get('msg', result)
|
||||
assert result.get('changed'), result
|
||||
@@ -274,11 +254,7 @@ def source_cred_aim_alt(aim_cred_type):
|
||||
return Credential.objects.create(
|
||||
name='Alternate CyberArk AIM Cred',
|
||||
credential_type=aim_cred_type,
|
||||
inputs={
|
||||
"url": "https://cyberark-alt.example.com",
|
||||
"app_id": "myAltID",
|
||||
"verify": "false"
|
||||
}
|
||||
inputs={"url": "https://cyberark-alt.example.com", "app_id": "myAltID", "verify": "false"},
|
||||
)
|
||||
|
||||
|
||||
@@ -286,41 +262,43 @@ def source_cred_aim_alt(aim_cred_type):
|
||||
def test_aim_credential_source(run_module, admin_user, organization, source_cred_aim, source_cred_aim_alt, silence_deprecation):
|
||||
ct = CredentialType.defaults['ssh']()
|
||||
ct.save()
|
||||
tgt_cred = Credential.objects.create(
|
||||
name='Test Machine Credential',
|
||||
organization=organization,
|
||||
credential_type=ct,
|
||||
inputs={'username': 'bob'}
|
||||
)
|
||||
tgt_cred = Credential.objects.create(name='Test Machine Credential', organization=organization, credential_type=ct, inputs={'username': 'bob'})
|
||||
|
||||
result = run_module('tower_credential_input_source', dict(
|
||||
source_credential=source_cred_aim.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"object_query": "Safe=SUPERSAFE;Object=MyAccount"},
|
||||
state='present'
|
||||
), admin_user)
|
||||
result = run_module(
|
||||
'tower_credential_input_source',
|
||||
dict(
|
||||
source_credential=source_cred_aim.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"object_query": "Safe=SUPERSAFE;Object=MyAccount"},
|
||||
state='present',
|
||||
),
|
||||
admin_user,
|
||||
)
|
||||
|
||||
assert not result.get('failed', False), result.get('msg', result)
|
||||
assert result.get('changed'), result
|
||||
|
||||
unchangedResult = run_module('tower_credential_input_source', dict(
|
||||
source_credential=source_cred_aim.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"object_query": "Safe=SUPERSAFE;Object=MyAccount"},
|
||||
state='present'
|
||||
), admin_user)
|
||||
unchangedResult = run_module(
|
||||
'tower_credential_input_source',
|
||||
dict(
|
||||
source_credential=source_cred_aim.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"object_query": "Safe=SUPERSAFE;Object=MyAccount"},
|
||||
state='present',
|
||||
),
|
||||
admin_user,
|
||||
)
|
||||
|
||||
assert not unchangedResult.get('failed', False), result.get('msg', result)
|
||||
assert not unchangedResult.get('changed'), result
|
||||
|
||||
changedResult = run_module('tower_credential_input_source', dict(
|
||||
source_credential=source_cred_aim_alt.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
state='present'
|
||||
), admin_user)
|
||||
changedResult = run_module(
|
||||
'tower_credential_input_source',
|
||||
dict(source_credential=source_cred_aim_alt.name, target_credential=tgt_cred.name, input_field_name='password', state='present'),
|
||||
admin_user,
|
||||
)
|
||||
|
||||
assert not changedResult.get('failed', False), changedResult.get('msg', result)
|
||||
assert changedResult.get('changed'), result
|
||||
@@ -347,7 +325,7 @@ def source_cred_centrify_secret(organization):
|
||||
"url": "https://tenant_id.my.centrify-dev.net",
|
||||
"client_id": "secretuser@tenant",
|
||||
"client_password": "secretuserpassword",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -355,20 +333,19 @@ def source_cred_centrify_secret(organization):
|
||||
def test_centrify_vault_credential_source(run_module, admin_user, organization, source_cred_centrify_secret, silence_deprecation):
|
||||
ct = CredentialType.defaults['ssh']()
|
||||
ct.save()
|
||||
tgt_cred = Credential.objects.create(
|
||||
name='Test Machine Credential',
|
||||
organization=organization,
|
||||
credential_type=ct,
|
||||
inputs={'username': 'bob'}
|
||||
)
|
||||
tgt_cred = Credential.objects.create(name='Test Machine Credential', organization=organization, credential_type=ct, inputs={'username': 'bob'})
|
||||
|
||||
result = run_module('tower_credential_input_source', dict(
|
||||
source_credential=source_cred_centrify_secret.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"system-name": "systemname", "account-name": "accountname"},
|
||||
state='present'
|
||||
), admin_user)
|
||||
result = run_module(
|
||||
'tower_credential_input_source',
|
||||
dict(
|
||||
source_credential=source_cred_centrify_secret.name,
|
||||
target_credential=tgt_cred.name,
|
||||
input_field_name='password',
|
||||
metadata={"system-name": "systemname", "account-name": "accountname"},
|
||||
state='present',
|
||||
),
|
||||
admin_user,
|
||||
)
|
||||
|
||||
assert not result.get('failed', False), result.get('msg', result)
|
||||
assert result.get('changed'), result
|
||||
|
||||
Reference in New Issue
Block a user