mirror of https://github.com/ansible/ansible.git
Test eos_banner (#22201)
* eos_banner docs improvements * run eos_banner tests * basic eos_banner tests * remove trailing newlines * remove hack * Various eos_banner fixes No unicode tests, as the device doesn't support it Correctly set provider result.command should be empty list if no changes * test eos_banner over eapi * revert docs changes, moved to separate PRpull/22496/head
parent
9173a7727c
commit
5dac2ee00c
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
testcase: "*"
|
@ -0,0 +1,2 @@
|
|||||||
|
dependencies:
|
||||||
|
- prepare_eos_tests
|
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
- name: collect all cli test cases
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/tests/cli"
|
||||||
|
patterns: "{{ testcase }}.yaml"
|
||||||
|
register: test_cases
|
||||||
|
|
||||||
|
- name: set test_items
|
||||||
|
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||||
|
|
||||||
|
- name: run test case
|
||||||
|
include: "{{ test_case_to_run }}"
|
||||||
|
with_items: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
- { include: cli.yaml, tags: ['cli'] }
|
||||||
|
- { include: eapi.yaml, tags: ['eapi'] }
|
@ -0,0 +1,55 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: setup - remove login
|
||||||
|
eos_banner:
|
||||||
|
banner: login
|
||||||
|
state: absent
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
|
||||||
|
- name: Set login
|
||||||
|
eos_banner:
|
||||||
|
banner: login
|
||||||
|
text: |
|
||||||
|
this is my login banner
|
||||||
|
that has a multiline
|
||||||
|
string
|
||||||
|
state: present
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- debug:
|
||||||
|
msg: "{{ result }}"
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
- "'this is my login banner' in result.commands"
|
||||||
|
- "'that has a multiline' in result.commands"
|
||||||
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||||
|
- "'ansible_1' in result.session_name"
|
||||||
|
|
||||||
|
- name: Set login again (idempotent)
|
||||||
|
eos_banner:
|
||||||
|
banner: login
|
||||||
|
text: |
|
||||||
|
this is my login banner
|
||||||
|
that has a multiline
|
||||||
|
string
|
||||||
|
state: present
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == false"
|
||||||
|
- "result.commands | length == 0"
|
||||||
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||||
|
- "result.session_name is not defined"
|
||||||
|
|
||||||
|
|
||||||
|
# FIXME add in tests for everything defined in docs
|
||||||
|
# FIXME Test state:absent + test:
|
||||||
|
# FIXME Without powers ensure "privileged mode required"
|
@ -0,0 +1,54 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: setup - remove motd
|
||||||
|
eos_banner:
|
||||||
|
banner: motd
|
||||||
|
state: absent
|
||||||
|
authorize: yes
|
||||||
|
|
||||||
|
- name: Set motd
|
||||||
|
eos_banner:
|
||||||
|
banner: motd
|
||||||
|
text: |
|
||||||
|
this is my motd banner
|
||||||
|
that has a multiline
|
||||||
|
string
|
||||||
|
state: present
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- debug:
|
||||||
|
msg: "{{ result }}"
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
- "'this is my motd banner' in result.commands"
|
||||||
|
- "'that has a multiline' in result.commands"
|
||||||
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||||
|
- "'ansible_1' in result.session_name"
|
||||||
|
|
||||||
|
- name: Set motd again (idempotent)
|
||||||
|
eos_banner:
|
||||||
|
banner: motd
|
||||||
|
text: |
|
||||||
|
this is my motd banner
|
||||||
|
that has a multiline
|
||||||
|
string
|
||||||
|
state: present
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == false"
|
||||||
|
- "result.commands | length == 0"
|
||||||
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||||
|
- "result.session_name is not defined"
|
||||||
|
|
||||||
|
|
||||||
|
# FIXME add in tests for everything defined in docs
|
||||||
|
# FIXME Test state:absent + test:
|
||||||
|
# FIXME Without powers ensure "privileged mode required"
|
@ -0,0 +1,48 @@
|
|||||||
|
---
|
||||||
|
- name: Setup
|
||||||
|
eos_banner:
|
||||||
|
banner: login
|
||||||
|
text: |
|
||||||
|
Junk login banner
|
||||||
|
over multiple lines
|
||||||
|
state: present
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
|
||||||
|
- name: remove login
|
||||||
|
eos_banner:
|
||||||
|
banner: login
|
||||||
|
state: absent
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- debug:
|
||||||
|
msg: "{{ result }}"
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
- "'no banner login' in result.commands" # does this break due to "contains?"
|
||||||
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||||
|
- "'ansible_1' in result.session_name"
|
||||||
|
|
||||||
|
- name: remove login (idempotent)
|
||||||
|
eos_banner:
|
||||||
|
banner: login
|
||||||
|
state: absent
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == false"
|
||||||
|
- "result.commands | length == 0"
|
||||||
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||||
|
- "result.session_name is not defined"
|
||||||
|
|
||||||
|
|
||||||
|
# FIXME add in tests for everything defined in docs
|
||||||
|
# FIXME Test state:absent + test:
|
||||||
|
# FIXME Without powers ensure "privileged mode required"
|
Loading…
Reference in New Issue