mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-29 06:58:55 +00:00
* Fixed `wifi_sec` option changes are not detected
Also updated `docs` URL and formatting to match that of the `wifi`
option
* Removed extraneous `appends` to `cmd` in `connection_update`
These really should have only been added to `connection_options` whose
return values get `extended` onto `cmd`
(cherry picked from commit 6bfa6e40f4)
Co-authored-by: David Hummel <6109326+hummeltech@users.noreply.github.com>
This commit is contained in:
parent
9e7bcae370
commit
67640e5431
3 changed files with 66 additions and 20 deletions
|
|
@ -491,6 +491,22 @@ TESTCASE_WIRELESS = [
|
|||
}
|
||||
]
|
||||
|
||||
TESTCASE_SECURE_WIRELESS = [
|
||||
{
|
||||
'type': 'wifi',
|
||||
'conn_name': 'non_existent_nw_device',
|
||||
'ifname': 'wireless_non_existant',
|
||||
'ip4': '10.10.10.10/24',
|
||||
'ssid': 'Brittany',
|
||||
'wifi_sec': {
|
||||
'key-mgmt': 'wpa-psk',
|
||||
'psk': 'VERY_SECURE_PASSWORD',
|
||||
},
|
||||
'state': 'present',
|
||||
'_ansible_check_mode': False,
|
||||
}
|
||||
]
|
||||
|
||||
TESTCASE_DUMMY_STATIC = [
|
||||
{
|
||||
'type': 'dummy',
|
||||
|
|
@ -1630,6 +1646,41 @@ def test_create_wireless(mocked_generic_connection_create, capfd):
|
|||
assert results['changed']
|
||||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_SECURE_WIRELESS, indirect=['patch_ansible_module'])
|
||||
def test_create_secure_wireless(mocked_generic_connection_create, capfd):
|
||||
"""
|
||||
Test : Create secure wireless connection
|
||||
"""
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
nmcli.main()
|
||||
|
||||
assert nmcli.Nmcli.execute_command.call_count == 1
|
||||
arg_list = nmcli.Nmcli.execute_command.call_args_list
|
||||
add_args, add_kw = arg_list[0]
|
||||
|
||||
assert add_args[0][0] == '/usr/bin/nmcli'
|
||||
assert add_args[0][1] == 'con'
|
||||
assert add_args[0][2] == 'add'
|
||||
assert add_args[0][3] == 'type'
|
||||
assert add_args[0][4] == 'wifi'
|
||||
assert add_args[0][5] == 'con-name'
|
||||
assert add_args[0][6] == 'non_existent_nw_device'
|
||||
|
||||
add_args_text = list(map(to_text, add_args[0]))
|
||||
for param in ['connection.interface-name', 'wireless_non_existant',
|
||||
'ipv4.addresses', '10.10.10.10/24',
|
||||
'802-11-wireless.ssid', 'Brittany',
|
||||
'802-11-wireless-security.key-mgmt', 'wpa-psk',
|
||||
'802-11-wireless-security.psk', 'VERY_SECURE_PASSWORD']:
|
||||
assert param in add_args_text
|
||||
|
||||
out, err = capfd.readouterr()
|
||||
results = json.loads(out)
|
||||
assert not results.get('failed')
|
||||
assert results['changed']
|
||||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_DUMMY_STATIC, indirect=['patch_ansible_module'])
|
||||
def test_create_dummy_static(mocked_generic_connection_create, capfd):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue