From 89e4226051ecdd933590ce208e2af7a77980686e Mon Sep 17 00:00:00 2001 From: John R Barker Date: Fri, 10 Mar 2017 15:29:36 +0000 Subject: [PATCH] add missing files (#22496) --- .../targets/eos_banner/tasks/eapi.yaml | 33 +++++++++++ .../eos_banner/tests/eapi/basic-login.yaml | 55 +++++++++++++++++++ .../eos_banner/tests/eapi/basic-motd.yaml | 53 ++++++++++++++++++ .../eos_banner/tests/eapi/basic-no-login.yaml | 46 ++++++++++++++++ 4 files changed, 187 insertions(+) create mode 100644 test/integration/targets/eos_banner/tasks/eapi.yaml create mode 100644 test/integration/targets/eos_banner/tests/eapi/basic-login.yaml create mode 100644 test/integration/targets/eos_banner/tests/eapi/basic-motd.yaml create mode 100644 test/integration/targets/eos_banner/tests/eapi/basic-no-login.yaml diff --git a/test/integration/targets/eos_banner/tasks/eapi.yaml b/test/integration/targets/eos_banner/tasks/eapi.yaml new file mode 100644 index 00000000000..994d1a7c7da --- /dev/null +++ b/test/integration/targets/eos_banner/tasks/eapi.yaml @@ -0,0 +1,33 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/eapi" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" #" + +- name: enable eapi + eos_eapi: + enable_http: yes + enable_https: yes + enable_local_http: yes + enable_socket: yes + provider: "{{ cli }}" +# authorize: yes + +- name: run test case + include: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: disable eapi + eos_eapi: + enable_http: no + enable_https: no + enable_local_http: no + enable_socket: no + provider: "{{ cli }}" +# authorize: yes diff --git a/test/integration/targets/eos_banner/tests/eapi/basic-login.yaml b/test/integration/targets/eos_banner/tests/eapi/basic-login.yaml new file mode 100644 index 00000000000..c9cd17931e8 --- /dev/null +++ b/test/integration/targets/eos_banner/tests/eapi/basic-login.yaml @@ -0,0 +1,55 @@ +--- + +- name: setup - remove login + eos_banner: + banner: login + state: absent + authorize: yes + transport: "{{ eapi }}" + +- name: Set login + eos_banner: + banner: login + text: | + this is my login banner + that has a multiline + string + state: present + authorize: yes + transport: "{{ eapi }}" + 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 + transport: "{{ eapi }}" + 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/eapi/basic-motd.yaml b/test/integration/targets/eos_banner/tests/eapi/basic-motd.yaml new file mode 100644 index 00000000000..d0f87ac32de --- /dev/null +++ b/test/integration/targets/eos_banner/tests/eapi/basic-motd.yaml @@ -0,0 +1,53 @@ +--- + +- 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: "{{ eapi }}" + 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: "{{ eapi }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.commands | length == 0" + # Ensure sessions contains epoc. Will fail after 18th May 2033 + - "result.session_name contains 'ansible_1'" + +# 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/eapi/basic-no-login.yaml b/test/integration/targets/eos_banner/tests/eapi/basic-no-login.yaml new file mode 100644 index 00000000000..b9b9bf55ea7 --- /dev/null +++ b/test/integration/targets/eos_banner/tests/eapi/basic-no-login.yaml @@ -0,0 +1,46 @@ +--- +- name: Setup + eos_banner: + banner: login + text: Junk login banner single line + state: present + authorize: yes + provider: "{{ eapi }}" + +- name: remove login + eos_banner: + banner: login + state: absent + authorize: yes + provider: "{{ eapi }}" + 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: "{{ eapi }}" + 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"