1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/eos_user/tests/cli/basic.yaml
Dave Thelen 602a618e60 eos_user: sends user secret first on user creation fixes #31680 (#32162)
* fix command order

* add integration test

* test cleanup

* remove redudant commands
2017-10-26 12:40:58 +05:30

92 lines
2.3 KiB
YAML

---
- name: Set Up
eos_config:
lines:
- no username ansibletest1
- no username ansibletest2
- no username ansibletest3
- no username ansibletest4
provider: "{{ cli }}"
- name: Create user with role
eos_user:
name: ansibletest1
privilege: 15
role: network-operator
state: present
configured_password: test1
authorize: yes
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"username" in result.commands[0]'
- '"secret" in result.commands[0]'
- '"role network-operator" in result.commands[1]'
- '"privilege 15" in result.commands[2]'
- name: Create user with priv level and update_password
eos_user:
name: ansibletest4
privilege: 15
state: present
configured_password: test1
authorize: yes
update_password: on_create
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"username" in result.commands[0]'
- '"secret" in result.commands[0]'
- '"privilege 15" in result.commands[1]'
- name: Collection of users
eos_user:
aggregate:
- { name: ansibletest2, configured_password: test2 }
- { name: ansibletest3, configured_password: test3 }
authorize: yes
state: present
role: network-operator
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"username" in result.commands[0]'
- '"role network-operator" in result.commands[0]'
- '"secret" in result.commands[1]'
- '"username" in result.commands[2]'
- '"role network-operator" in result.commands[2]'
- '"secret" in result.commands[3]'
- name: Add user without password or nopassword arg(Should fail)
eos_user:
name: faileduser1
privilege: 15
state: present
authorize: yes
provider: "{{ cli }}"
ignore_errors: yes
register: result
- assert:
that:
- 'result.changed == false'
- 'result.failed == true'
- 'result.msg == "configured_password, sshkey or nopassword should be provided"'
- name: tearDown
eos_config:
lines:
- no username ansibletest1
- no username ansibletest2
- no username ansibletest3
- no username ansibletest4
provider: "{{ cli }}"