mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
iosxr_banner Implementation module (#25744)
* Add iosxr_banner implementation module Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Integration test for iosxr_banner Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Unit test for iosxr_banner Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * remove blank line pep8 Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
@@ -14,3 +14,4 @@
|
||||
- { role: iosxr_template, when: "limit_to in ['*', 'iosxr_template']" }
|
||||
- { role: iosxr_system, when: "limit_to in ['*', 'iosxr_system']" }
|
||||
- { role: iosxr_user, when: "limit_to in ['*', 'iosxr_user']" }
|
||||
- { role: iosxr_banner, when: "limit_to in ['*', 'iosxr_banner']" }
|
||||
|
||||
3
test/integration/targets/iosxr_banner/defaults/main.yaml
Normal file
3
test/integration/targets/iosxr_banner/defaults/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
||||
2
test/integration/targets/iosxr_banner/meta/main.yaml
Normal file
2
test/integration/targets/iosxr_banner/meta/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- prepare_iosxr_tests
|
||||
16
test/integration/targets/iosxr_banner/tasks/cli.yaml
Normal file
16
test/integration/targets/iosxr_banner/tasks/cli.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
- name: collect all cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
delegate_to: localhost
|
||||
|
||||
- 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
|
||||
2
test/integration/targets/iosxr_banner/tasks/main.yaml
Normal file
2
test/integration/targets/iosxr_banner/tasks/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
@@ -0,0 +1,47 @@
|
||||
---
|
||||
- name: setup - remove login
|
||||
iosxr_banner:
|
||||
banner: login
|
||||
state: absent
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: Set login
|
||||
iosxr_banner:
|
||||
banner: login
|
||||
text: |
|
||||
this is my login banner
|
||||
that has a multiline
|
||||
string
|
||||
state: present
|
||||
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"
|
||||
|
||||
- name: Set login again (idempotent)
|
||||
iosxr_banner:
|
||||
banner: login
|
||||
text: |
|
||||
this is my login banner
|
||||
that has a multiline
|
||||
string
|
||||
state: present
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.commands | length == 0"
|
||||
|
||||
|
||||
# FIXME add in tests for everything defined in docs
|
||||
# FIXME Test state:absent + test:
|
||||
# FIXME Without powers ensure "privileged mode required"
|
||||
@@ -0,0 +1,47 @@
|
||||
---
|
||||
- name: setup - remove motd
|
||||
iosxr_banner:
|
||||
banner: motd
|
||||
state: absent
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: Set motd
|
||||
iosxr_banner:
|
||||
banner: motd
|
||||
text: |
|
||||
this is my motd banner
|
||||
that has a multiline
|
||||
string
|
||||
state: present
|
||||
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"
|
||||
|
||||
- name: Set motd again (idempotent)
|
||||
iosxr_banner:
|
||||
banner: motd
|
||||
text: |
|
||||
this is my motd banner
|
||||
that has a multiline
|
||||
string
|
||||
state: present
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.commands | length == 0"
|
||||
|
||||
|
||||
# FIXME add in tests for everything defined in docs
|
||||
# FIXME Test state:absent + test:
|
||||
# FIXME Without powers ensure "privileged mode required"
|
||||
@@ -0,0 +1,41 @@
|
||||
---
|
||||
- name: Setup
|
||||
iosxr_banner:
|
||||
banner: login
|
||||
text: |
|
||||
Junk login banner
|
||||
over multiple lines
|
||||
state: present
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: remove login
|
||||
iosxr_banner:
|
||||
banner: login
|
||||
state: absent
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- debug:
|
||||
msg: "{{ result }}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'no banner login' in result.commands"
|
||||
|
||||
- name: remove login (idempotent)
|
||||
iosxr_banner:
|
||||
banner: login
|
||||
state: absent
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.commands | length == 0"
|
||||
|
||||
|
||||
# FIXME add in tests for everything defined in docs
|
||||
# FIXME Test state:absent + test:
|
||||
# FIXME Without powers ensure "privileged mode required"
|
||||
Reference in New Issue
Block a user