mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-09 14:50:02 -07:00
Integrated publickey import and removal in iosxr_user (#32115)
* Integrated publickey import and removal in iosxr_user * Fixed linting issues * Added version added for publickeyfile option * Added quotation marks to version, oops * Added some integration tests, added some checks to prevent aggregate users with public keys. * Added some integration test files * Created mutually exclusive public_key and public_key_contents versions of config * Modified tests to use both methods and test more logins * Added supports for aggregates * Incorporated provider auth * Fixed some lint issues * Fixed a YAML lint issue * Implemented catches for unconfigured providers. * Fixed catches, hopefully * Another test * Added groups support so you can add users to multiple groups * Trailing whitespace
This commit is contained in:
parent
64f9ced750
commit
900abcddb3
5 changed files with 299 additions and 2 deletions
30
test/integration/targets/iosxr_user/files/private
Normal file
30
test/integration/targets/iosxr_user/files/private
Normal file
|
@ -0,0 +1,30 @@
|
|||
-----BEGIN RSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: DES-EDE3-CBC,A823A6B5ED873917
|
||||
|
||||
mLZ1xM1+xwutkRy+K/c9QsstDPQ9F6UWtDpoYyIgs7n9VgMjhIMbWQC9CkTvnFJM
|
||||
ey+iwGdQZZOThwxalm+k3pMibwRjhnF+PNFhiVkzWH8/K8QvXRQiW/vYmE/QB9pY
|
||||
T0IWbMcC7/ktEfQn+6GLXoe/L7yH+aNv/2Flsa2jN2cfSXpzbneUA06/LVVOw6E+
|
||||
C74NKRWUmMPA39Zd4WOeBoWUdS5Kgwl57SOtrKs1LIGh33+TPu+Go8gJ7h/t/kaN
|
||||
kverVSz+0eeX+exKumejfo1UfosplRhcjRG8YgiQ8l7SN3NBF/gXiiSrH3fLwmRJ
|
||||
hbokJ8TmCozrYBs1MNe3LoU2iuIqVnJ5Sd6DJELs6vCuFz+v6J/s80NaaYMlBCbB
|
||||
1lahelYqoyLb4uiDd4zQSpaxzO+Cx/d50Wpee8mFxbAL/YxacOzD3b/VCBgB+AZN
|
||||
TTHr1ayd+ITd8gewXAyERKWyrDcC2beJI0fOil23P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ATOcBO/zaOYIwDGT5ZwMQAV1aQl8HyeyYESNjb0fBXQ3OYObOrTTs8MLyC
|
||||
I4b6wr1vlbN+lMOm+RIXCDgmC3COdlgCHyo3qiIu2YNYQVoNF4NN4A==
|
||||
-----END RSA PRIVATE KEY-----
|
1
test/integration/targets/iosxr_user/files/public.pub
Normal file
1
test/integration/targets/iosxr_user/files/public.pub
Normal file
|
@ -0,0 +1 @@
|
|||
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAkvLTTJdwZ0lg1cUCn13Hi3+ho2+G6/96XuAP7jA7Ghz9NPbC/eqXnjvb27BA8CxtFXYuXR5eZWSq2UN5zFcfrFb57XFxdAg2q21hGEX+FGiTUuRZh8+ByVEh0LUetFTwsEZ1iGv6GZiLBt7IJvClXbyNTJEt3DZncHfGwudyGFviV4dGrzusDAGAcoHqvD/5uXYl4PjMH9oSfraO3sG4Q7soQwxNeiM8qOLf3c1SabHBAtSewwnA0E/jhzpOLD2QUncU5s+Oa9PvEXXhGv5eZo9lp71brsgyWj32m2UuXx/n+EZg78GVJT5mFO7LG239n3gTnwkMVdr6zVBFNX5Mvw== rsa-key-20171025
|
1
test/integration/targets/iosxr_user/files/public2.pub
Normal file
1
test/integration/targets/iosxr_user/files/public2.pub
Normal file
|
@ -0,0 +1 @@
|
|||
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAhTxbibM8hKZn7xDURs15L3gkcsnpDoZ+tNm5zpP9dcboASnIyJzfC7J/RdRCQsO/pDmUY4y/tsTx18uenyfazxtNkyCHdANlp8XVF1fGNv5GM+QbsDqxe54sdG9csASX0/Ljvl538IbcLFVH0zxyKspbDOgkAkUSuKIAH5x+/GhkAoGQO2tOhYjqofNtUxLSvfRsf4Gm1M0WgdWmz3MW4NOdZhsL4S+STgRPU1jy1dKGj7BKY9cpnCWBFHa2wSaOXJEBZEKNaFVxlBBrFs5brjRQA0mVPmE+pz+/+IJeSNEEma9cXur0ONeb6OoXvkManxKfkaswT2ybOChAzJR8dQ== T-MOBILE
|
|
@ -25,6 +25,62 @@
|
|||
that:
|
||||
- results.failed
|
||||
|
||||
- name: create user with private key (contents input)
|
||||
iosxr_user:
|
||||
name: auth_user
|
||||
state: present
|
||||
public_key_contents: "{{ lookup('file', \"{{ output_dir }}/public.pub\") }}"
|
||||
|
||||
- name: test login with private key
|
||||
expect:
|
||||
command: "ssh auth_user@{{ ansible_ssh_host }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{output_dir}}/private show version"
|
||||
responses:
|
||||
(?i)passphrase: 'pass123'
|
||||
|
||||
- name: remove user and key
|
||||
iosxr_user:
|
||||
name: auth_user
|
||||
state: absent
|
||||
|
||||
- name: test login with private key (should fail, no user)
|
||||
expect:
|
||||
command: "ssh auth_user@{{ ansible_ssh_host }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{output_dir}}/private show version"
|
||||
responses:
|
||||
(?i)passphrase: 'pass123'
|
||||
ignore_errors: yes
|
||||
register: results
|
||||
|
||||
- name: create user with private key (path input)
|
||||
iosxr_user:
|
||||
name: auth_user
|
||||
state: present
|
||||
public_key: "{{ output_dir }}/public.pub"
|
||||
|
||||
- name: test login with private key
|
||||
expect:
|
||||
command: "ssh auth_user@{{ ansible_ssh_host }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{output_dir}}/private show version"
|
||||
responses:
|
||||
(?i)passphrase: 'pass123'
|
||||
|
||||
- name: change private key for user
|
||||
iosxr_user:
|
||||
name: auth_user
|
||||
state: present
|
||||
public_key_contents: "{{ lookup('file', \"{{ output_dir }}/public2.pub\") }}"
|
||||
|
||||
- name: test login with invalid private key (should fail)
|
||||
expect:
|
||||
command: "ssh auth_user@{{ ansible_ssh_host }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{output_dir}}/private show version"
|
||||
responses:
|
||||
(?i)passphrase: "pass123"
|
||||
ignore_errors: yes
|
||||
register: results
|
||||
|
||||
- name: check that attempt failed
|
||||
assert:
|
||||
that:
|
||||
- results.failed
|
||||
|
||||
always:
|
||||
- name: delete user
|
||||
iosxr_user:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue