|
|
@ -25,7 +25,6 @@ class TestConnectionWinRM(object):
|
|
|
|
OPTIONS_DATA = (
|
|
|
|
OPTIONS_DATA = (
|
|
|
|
# default options
|
|
|
|
# default options
|
|
|
|
(
|
|
|
|
(
|
|
|
|
{},
|
|
|
|
|
|
|
|
{'_extras': {}},
|
|
|
|
{'_extras': {}},
|
|
|
|
{},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -33,8 +32,8 @@ class TestConnectionWinRM(object):
|
|
|
|
'_kinit_cmd': 'kinit',
|
|
|
|
'_kinit_cmd': 'kinit',
|
|
|
|
'_winrm_connection_timeout': None,
|
|
|
|
'_winrm_connection_timeout': None,
|
|
|
|
'_winrm_host': 'inventory_hostname',
|
|
|
|
'_winrm_host': 'inventory_hostname',
|
|
|
|
'_winrm_kwargs': {'username': None, 'password': ''},
|
|
|
|
'_winrm_kwargs': {'username': None, 'password': None},
|
|
|
|
'_winrm_pass': '',
|
|
|
|
'_winrm_pass': None,
|
|
|
|
'_winrm_path': '/wsman',
|
|
|
|
'_winrm_path': '/wsman',
|
|
|
|
'_winrm_port': 5986,
|
|
|
|
'_winrm_port': 5986,
|
|
|
|
'_winrm_scheme': 'https',
|
|
|
|
'_winrm_scheme': 'https',
|
|
|
@ -45,11 +44,10 @@ class TestConnectionWinRM(object):
|
|
|
|
),
|
|
|
|
),
|
|
|
|
# http through port
|
|
|
|
# http through port
|
|
|
|
(
|
|
|
|
(
|
|
|
|
{},
|
|
|
|
|
|
|
|
{'_extras': {}, 'ansible_port': 5985},
|
|
|
|
{'_extras': {}, 'ansible_port': 5985},
|
|
|
|
{},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'_winrm_kwargs': {'username': None, 'password': ''},
|
|
|
|
'_winrm_kwargs': {'username': None, 'password': None},
|
|
|
|
'_winrm_port': 5985,
|
|
|
|
'_winrm_port': 5985,
|
|
|
|
'_winrm_scheme': 'http',
|
|
|
|
'_winrm_scheme': 'http',
|
|
|
|
'_winrm_transport': ['plaintext'],
|
|
|
|
'_winrm_transport': ['plaintext'],
|
|
|
@ -58,15 +56,14 @@ class TestConnectionWinRM(object):
|
|
|
|
),
|
|
|
|
),
|
|
|
|
# kerberos user with kerb present
|
|
|
|
# kerberos user with kerb present
|
|
|
|
(
|
|
|
|
(
|
|
|
|
{},
|
|
|
|
|
|
|
|
{'_extras': {}, 'ansible_user': 'user@domain.com'},
|
|
|
|
{'_extras': {}, 'ansible_user': 'user@domain.com'},
|
|
|
|
{},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'_kerb_managed': False,
|
|
|
|
'_kerb_managed': False,
|
|
|
|
'_kinit_cmd': 'kinit',
|
|
|
|
'_kinit_cmd': 'kinit',
|
|
|
|
'_winrm_kwargs': {'username': 'user@domain.com',
|
|
|
|
'_winrm_kwargs': {'username': 'user@domain.com',
|
|
|
|
'password': ''},
|
|
|
|
'password': None},
|
|
|
|
'_winrm_pass': '',
|
|
|
|
'_winrm_pass': None,
|
|
|
|
'_winrm_transport': ['kerberos', 'ssl'],
|
|
|
|
'_winrm_transport': ['kerberos', 'ssl'],
|
|
|
|
'_winrm_user': 'user@domain.com'
|
|
|
|
'_winrm_user': 'user@domain.com'
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -74,15 +71,14 @@ class TestConnectionWinRM(object):
|
|
|
|
),
|
|
|
|
),
|
|
|
|
# kerberos user without kerb present
|
|
|
|
# kerberos user without kerb present
|
|
|
|
(
|
|
|
|
(
|
|
|
|
{},
|
|
|
|
|
|
|
|
{'_extras': {}, 'ansible_user': 'user@domain.com'},
|
|
|
|
{'_extras': {}, 'ansible_user': 'user@domain.com'},
|
|
|
|
{},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'_kerb_managed': False,
|
|
|
|
'_kerb_managed': False,
|
|
|
|
'_kinit_cmd': 'kinit',
|
|
|
|
'_kinit_cmd': 'kinit',
|
|
|
|
'_winrm_kwargs': {'username': 'user@domain.com',
|
|
|
|
'_winrm_kwargs': {'username': 'user@domain.com',
|
|
|
|
'password': ''},
|
|
|
|
'password': None},
|
|
|
|
'_winrm_pass': '',
|
|
|
|
'_winrm_pass': None,
|
|
|
|
'_winrm_transport': ['ssl'],
|
|
|
|
'_winrm_transport': ['ssl'],
|
|
|
|
'_winrm_user': 'user@domain.com'
|
|
|
|
'_winrm_user': 'user@domain.com'
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -90,9 +86,8 @@ class TestConnectionWinRM(object):
|
|
|
|
),
|
|
|
|
),
|
|
|
|
# kerberos user with managed ticket (implicit)
|
|
|
|
# kerberos user with managed ticket (implicit)
|
|
|
|
(
|
|
|
|
(
|
|
|
|
{'password': 'pass'},
|
|
|
|
|
|
|
|
{'_extras': {}, 'ansible_user': 'user@domain.com'},
|
|
|
|
{'_extras': {}, 'ansible_user': 'user@domain.com'},
|
|
|
|
{},
|
|
|
|
{'remote_password': 'pass'},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'_kerb_managed': True,
|
|
|
|
'_kerb_managed': True,
|
|
|
|
'_kinit_cmd': 'kinit',
|
|
|
|
'_kinit_cmd': 'kinit',
|
|
|
@ -106,10 +101,9 @@ class TestConnectionWinRM(object):
|
|
|
|
),
|
|
|
|
),
|
|
|
|
# kerb with managed ticket (explicit)
|
|
|
|
# kerb with managed ticket (explicit)
|
|
|
|
(
|
|
|
|
(
|
|
|
|
{'password': 'pass'},
|
|
|
|
|
|
|
|
{'_extras': {}, 'ansible_user': 'user@domain.com',
|
|
|
|
{'_extras': {}, 'ansible_user': 'user@domain.com',
|
|
|
|
'ansible_winrm_kinit_mode': 'managed'},
|
|
|
|
'ansible_winrm_kinit_mode': 'managed'},
|
|
|
|
{},
|
|
|
|
{'password': 'pass'},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'_kerb_managed': True,
|
|
|
|
'_kerb_managed': True,
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -117,10 +111,9 @@ class TestConnectionWinRM(object):
|
|
|
|
),
|
|
|
|
),
|
|
|
|
# kerb with unmanaged ticket (explicit))
|
|
|
|
# kerb with unmanaged ticket (explicit))
|
|
|
|
(
|
|
|
|
(
|
|
|
|
{'password': 'pass'},
|
|
|
|
|
|
|
|
{'_extras': {}, 'ansible_user': 'user@domain.com',
|
|
|
|
{'_extras': {}, 'ansible_user': 'user@domain.com',
|
|
|
|
'ansible_winrm_kinit_mode': 'manual'},
|
|
|
|
'ansible_winrm_kinit_mode': 'manual'},
|
|
|
|
{},
|
|
|
|
{'password': 'pass'},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'_kerb_managed': False,
|
|
|
|
'_kerb_managed': False,
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -128,40 +121,37 @@ class TestConnectionWinRM(object):
|
|
|
|
),
|
|
|
|
),
|
|
|
|
# transport override (single)
|
|
|
|
# transport override (single)
|
|
|
|
(
|
|
|
|
(
|
|
|
|
{},
|
|
|
|
|
|
|
|
{'_extras': {}, 'ansible_user': 'user@domain.com',
|
|
|
|
{'_extras': {}, 'ansible_user': 'user@domain.com',
|
|
|
|
'ansible_winrm_transport': 'ntlm'},
|
|
|
|
'ansible_winrm_transport': 'ntlm'},
|
|
|
|
{},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'_winrm_kwargs': {'username': 'user@domain.com',
|
|
|
|
'_winrm_kwargs': {'username': 'user@domain.com',
|
|
|
|
'password': ''},
|
|
|
|
'password': None},
|
|
|
|
'_winrm_pass': '',
|
|
|
|
'_winrm_pass': None,
|
|
|
|
'_winrm_transport': ['ntlm'],
|
|
|
|
'_winrm_transport': ['ntlm'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
False
|
|
|
|
False
|
|
|
|
),
|
|
|
|
),
|
|
|
|
# transport override (list)
|
|
|
|
# transport override (list)
|
|
|
|
(
|
|
|
|
(
|
|
|
|
{},
|
|
|
|
|
|
|
|
{'_extras': {}, 'ansible_user': 'user@domain.com',
|
|
|
|
{'_extras': {}, 'ansible_user': 'user@domain.com',
|
|
|
|
'ansible_winrm_transport': ['ntlm', 'certificate']},
|
|
|
|
'ansible_winrm_transport': ['ntlm', 'certificate']},
|
|
|
|
{},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'_winrm_kwargs': {'username': 'user@domain.com',
|
|
|
|
'_winrm_kwargs': {'username': 'user@domain.com',
|
|
|
|
'password': ''},
|
|
|
|
'password': None},
|
|
|
|
'_winrm_pass': '',
|
|
|
|
'_winrm_pass': None,
|
|
|
|
'_winrm_transport': ['ntlm', 'certificate'],
|
|
|
|
'_winrm_transport': ['ntlm', 'certificate'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
False
|
|
|
|
False
|
|
|
|
),
|
|
|
|
),
|
|
|
|
# winrm extras
|
|
|
|
# winrm extras
|
|
|
|
(
|
|
|
|
(
|
|
|
|
{},
|
|
|
|
|
|
|
|
{'_extras': {'ansible_winrm_server_cert_validation': 'ignore',
|
|
|
|
{'_extras': {'ansible_winrm_server_cert_validation': 'ignore',
|
|
|
|
'ansible_winrm_service': 'WSMAN'}},
|
|
|
|
'ansible_winrm_service': 'WSMAN'}},
|
|
|
|
{},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'_winrm_kwargs': {'username': None, 'password': '',
|
|
|
|
'_winrm_kwargs': {'username': None, 'password': None,
|
|
|
|
'server_cert_validation': 'ignore',
|
|
|
|
'server_cert_validation': 'ignore',
|
|
|
|
'service': 'WSMAN'},
|
|
|
|
'service': 'WSMAN'},
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -169,7 +159,6 @@ class TestConnectionWinRM(object):
|
|
|
|
),
|
|
|
|
),
|
|
|
|
# direct override
|
|
|
|
# direct override
|
|
|
|
(
|
|
|
|
(
|
|
|
|
{},
|
|
|
|
|
|
|
|
{'_extras': {}, 'ansible_winrm_connection_timeout': 5},
|
|
|
|
{'_extras': {}, 'ansible_winrm_connection_timeout': 5},
|
|
|
|
{'connection_timeout': 10},
|
|
|
|
{'connection_timeout': 10},
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -177,29 +166,47 @@ class TestConnectionWinRM(object):
|
|
|
|
},
|
|
|
|
},
|
|
|
|
False
|
|
|
|
False
|
|
|
|
),
|
|
|
|
),
|
|
|
|
# user comes from option not play context
|
|
|
|
# password as ansible_password
|
|
|
|
(
|
|
|
|
(
|
|
|
|
{'username': 'user1'},
|
|
|
|
{'_extras': {}, 'ansible_password': 'pass'},
|
|
|
|
{'_extras': {}, 'ansible_user': 'user2'},
|
|
|
|
|
|
|
|
{},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'_winrm_user': 'user2',
|
|
|
|
'_winrm_pass': 'pass',
|
|
|
|
'_winrm_kwargs': {'username': 'user2', 'password': ''}
|
|
|
|
'_winrm_kwargs': {'username': None, 'password': 'pass'}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
False
|
|
|
|
False
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
|
|
|
# password as ansible_winrm_pass
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
{'_extras': {}, 'ansible_winrm_pass': 'pass'},
|
|
|
|
|
|
|
|
{},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
'_winrm_pass': 'pass',
|
|
|
|
|
|
|
|
'_winrm_kwargs': {'username': None, 'password': 'pass'}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
False
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# password as ansible_winrm_password
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
{'_extras': {}, 'ansible_winrm_password': 'pass'},
|
|
|
|
|
|
|
|
{},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
'_winrm_pass': 'pass',
|
|
|
|
|
|
|
|
'_winrm_kwargs': {'username': None, 'password': 'pass'}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
False
|
|
|
|
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# pylint bug: https://github.com/PyCQA/pylint/issues/511
|
|
|
|
# pylint bug: https://github.com/PyCQA/pylint/issues/511
|
|
|
|
# pylint: disable=undefined-variable
|
|
|
|
# pylint: disable=undefined-variable
|
|
|
|
@pytest.mark.parametrize('play, options, direct, expected, kerb',
|
|
|
|
@pytest.mark.parametrize('options, direct, expected, kerb',
|
|
|
|
((p, o, d, e, k) for p, o, d, e, k in OPTIONS_DATA))
|
|
|
|
((o, d, e, k) for o, d, e, k in OPTIONS_DATA))
|
|
|
|
def test_set_options(self, play, options, direct, expected, kerb):
|
|
|
|
def test_set_options(self, options, direct, expected, kerb):
|
|
|
|
winrm.HAVE_KERBEROS = kerb
|
|
|
|
winrm.HAVE_KERBEROS = kerb
|
|
|
|
|
|
|
|
|
|
|
|
pc = PlayContext()
|
|
|
|
pc = PlayContext()
|
|
|
|
for attr, value in play.items():
|
|
|
|
|
|
|
|
setattr(pc, attr, value)
|
|
|
|
|
|
|
|
new_stdin = StringIO()
|
|
|
|
new_stdin = StringIO()
|
|
|
|
|
|
|
|
|
|
|
|
conn = connection_loader.get('winrm', pc, new_stdin)
|
|
|
|
conn = connection_loader.get('winrm', pc, new_stdin)
|
|
|
|