diff options
author | John R Barker <john@johnrbarker.com> | 2017-03-10 15:20:09 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-10 15:20:09 +0000 |
commit | 5dac2ee00cb04cd55667dcb266a76fafbacc60d5 (patch) | |
tree | 00021f10e17d35be3ea150973926f9237b18e13b /test/integration/targets/eos_banner | |
parent | 9173a7727cc60c7679fa42e7e02a46f37094c38b (diff) | |
download | ansible-5dac2ee00cb04cd55667dcb266a76fafbacc60d5.tar.gz |
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 PR
Diffstat (limited to 'test/integration/targets/eos_banner')
7 files changed, 179 insertions, 0 deletions
diff --git a/test/integration/targets/eos_banner/defaults/main.yaml b/test/integration/targets/eos_banner/defaults/main.yaml new file mode 100644 index 0000000000..5f709c5aac --- /dev/null +++ b/test/integration/targets/eos_banner/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/eos_banner/meta/main.yml b/test/integration/targets/eos_banner/meta/main.yml new file mode 100644 index 0000000000..e5c8cd02f0 --- /dev/null +++ b/test/integration/targets/eos_banner/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_eos_tests diff --git a/test/integration/targets/eos_banner/tasks/cli.yaml b/test/integration/targets/eos_banner/tasks/cli.yaml new file mode 100644 index 0000000000..d675462dd0 --- /dev/null +++ b/test/integration/targets/eos_banner/tasks/cli.yaml @@ -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 diff --git a/test/integration/targets/eos_banner/tasks/main.yaml b/test/integration/targets/eos_banner/tasks/main.yaml new file mode 100644 index 0000000000..970e74171e --- /dev/null +++ b/test/integration/targets/eos_banner/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_banner/tests/cli/basic-login.yaml b/test/integration/targets/eos_banner/tests/cli/basic-login.yaml new file mode 100644 index 0000000000..670e09574b --- /dev/null +++ b/test/integration/targets/eos_banner/tests/cli/basic-login.yaml @@ -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" diff --git a/test/integration/targets/eos_banner/tests/cli/basic-motd.yaml b/test/integration/targets/eos_banner/tests/cli/basic-motd.yaml new file mode 100644 index 0000000000..fab2d26ff6 --- /dev/null +++ b/test/integration/targets/eos_banner/tests/cli/basic-motd.yaml @@ -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" diff --git a/test/integration/targets/eos_banner/tests/cli/basic-no-login.yaml b/test/integration/targets/eos_banner/tests/cli/basic-no-login.yaml new file mode 100644 index 0000000000..c34afb7d9d --- /dev/null +++ b/test/integration/targets/eos_banner/tests/cli/basic-no-login.yaml @@ -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" |