summaryrefslogtreecommitdiff
path: root/test/integration
diff options
context:
space:
mode:
authorTrishna Guha <trishnaguha17@gmail.com>2017-06-16 11:56:47 +0530
committerGitHub <noreply@github.com>2017-06-16 11:56:47 +0530
commit98269888a98fe8193345f78ce0e1616384764c86 (patch)
treece921b1f2dd1c37728f24e11cc6d54c3d4ca38c8 /test/integration
parentc5b8196ff1b9569b2921cffc6479829d552be4d1 (diff)
downloadansible-98269888a98fe8193345f78ce0e1616384764c86.tar.gz
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>
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/iosxr.yaml1
-rw-r--r--test/integration/targets/iosxr_banner/defaults/main.yaml3
-rw-r--r--test/integration/targets/iosxr_banner/meta/main.yaml2
-rw-r--r--test/integration/targets/iosxr_banner/tasks/cli.yaml16
-rw-r--r--test/integration/targets/iosxr_banner/tasks/main.yaml2
-rw-r--r--test/integration/targets/iosxr_banner/tests/cli/basic-login.yaml47
-rw-r--r--test/integration/targets/iosxr_banner/tests/cli/basic-motd.yaml47
-rw-r--r--test/integration/targets/iosxr_banner/tests/cli/basic-no-login.yaml41
8 files changed, 159 insertions, 0 deletions
diff --git a/test/integration/iosxr.yaml b/test/integration/iosxr.yaml
index d3e2aade6c..8b9f968b22 100644
--- a/test/integration/iosxr.yaml
+++ b/test/integration/iosxr.yaml
@@ -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']" }
diff --git a/test/integration/targets/iosxr_banner/defaults/main.yaml b/test/integration/targets/iosxr_banner/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/iosxr_banner/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/iosxr_banner/meta/main.yaml b/test/integration/targets/iosxr_banner/meta/main.yaml
new file mode 100644
index 0000000000..d4da833dd5
--- /dev/null
+++ b/test/integration/targets/iosxr_banner/meta/main.yaml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_iosxr_tests
diff --git a/test/integration/targets/iosxr_banner/tasks/cli.yaml b/test/integration/targets/iosxr_banner/tasks/cli.yaml
new file mode 100644
index 0000000000..46d86dd698
--- /dev/null
+++ b/test/integration/targets/iosxr_banner/tasks/cli.yaml
@@ -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
diff --git a/test/integration/targets/iosxr_banner/tasks/main.yaml b/test/integration/targets/iosxr_banner/tasks/main.yaml
new file mode 100644
index 0000000000..415c99d8b1
--- /dev/null
+++ b/test/integration/targets/iosxr_banner/tasks/main.yaml
@@ -0,0 +1,2 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
diff --git a/test/integration/targets/iosxr_banner/tests/cli/basic-login.yaml b/test/integration/targets/iosxr_banner/tests/cli/basic-login.yaml
new file mode 100644
index 0000000000..9e87a5d5ad
--- /dev/null
+++ b/test/integration/targets/iosxr_banner/tests/cli/basic-login.yaml
@@ -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"
diff --git a/test/integration/targets/iosxr_banner/tests/cli/basic-motd.yaml b/test/integration/targets/iosxr_banner/tests/cli/basic-motd.yaml
new file mode 100644
index 0000000000..da7b78c17e
--- /dev/null
+++ b/test/integration/targets/iosxr_banner/tests/cli/basic-motd.yaml
@@ -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"
diff --git a/test/integration/targets/iosxr_banner/tests/cli/basic-no-login.yaml b/test/integration/targets/iosxr_banner/tests/cli/basic-no-login.yaml
new file mode 100644
index 0000000000..7590b6b2fa
--- /dev/null
+++ b/test/integration/targets/iosxr_banner/tests/cli/basic-no-login.yaml
@@ -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"