ansible/test/integration/targets/iosxr_user/tests/cli/auth.yaml
Kedar Kekan 2bc4c4f156
IOS-XR NetConf and Cliconf plugin work (#33332)
*  - Netconf plugin addition for iosxr
 - Utilities refactoring to support netconf and cliconf
 - iosx_banner refactoring for netconf and cliconf
 - Integration testcases changes to accomodate above changes

* Fix sanity failures, shippable errors and review comments

* fix pep8 issue

* changes run_command method to send specific command args

* - Review comment fixes
- iosxr_command changes to remove ComplexDict based command_spec

* - Move namespaces removal method from utils to netconf plugin

* Minor refactoring in utils and change in deprecation message

* rewrite build_xml logic and import changes for new utils dir structure

* - Review comment changes and minor changes to documentation

* * refactor common code and docs updates
2017-12-06 22:37:31 +05:30

97 lines
3.1 KiB
YAML

---
- block:
- name: Create user with password
iosxr_user:
name: auth_user
state: present
configured_password: pass123
provider: "{{ cli }}"
- name: test login
expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no show version"
responses:
(?i)password: "pass123"
- name: test login with invalid password (should fail)
expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no show version"
responses:
(?i)password: "badpass"
ignore_errors: yes
register: results
- name: check that attempt failed
assert:
that:
- results.failed
- name: create user with private key (contents input)
iosxr_user:
name: auth_user
state: present
public_key_contents: "{{ lookup('file', \"{{ role_path }}/files/public.pub\") }}"
provider: "{{ cli }}"
- name: test login with private key
expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{ role_path }}/files/private show version"
responses:
(?i)password: 'pass123'
- name: remove user and key
iosxr_user:
name: auth_user
provider: "{{ cli }}"
state: absent
- name: test login with private key (should fail, no user)
expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{ role_path }}/files/private show version"
responses:
(?i)password: 'pass123'
ignore_errors: yes
register: results
- name: create user with private key (path input)
iosxr_user:
name: auth_user
state: present
public_key: "{{ role_path }}/files/public.pub"
provider: "{{ cli }}"
- name: test login with private key
expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{ role_path }}/files/private show version"
responses:
(?i)password: 'pass123'
ignore_errors: yes
- name: change private key for user
iosxr_user:
name: auth_user
state: present
public_key_contents: "{{ lookup('file', \"{{ role_path }}/files/public2.pub\") }}"
provider: "{{ cli }}"
# FIXME: pexpect fails with OSError: [Errno 5] Input/output error
- name: test login with invalid private key (should fail)
expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{ role_path }}/files/private show version"
responses:
(?i)password: "pass123"
ignore_errors: yes
register: results
- name: check that attempt failed
assert:
that:
- results.failed
always:
- name: delete user
iosxr_user:
name: auth_user
state: absent
provider: "{{ cli }}"
register: result