summaryrefslogtreecommitdiff
path: root/tests/integration/targets/vyos_config
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration/targets/vyos_config')
-rw-r--r--tests/integration/targets/vyos_config/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_config/tasks/redirection.yaml16
-rw-r--r--tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml57
3 files changed, 78 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_config/tasks/main.yaml b/tests/integration/targets/vyos_config/tasks/main.yaml
index 8d10ebb..684482c 100644
--- a/tests/integration/targets/vyos_config/tasks/main.yaml
+++ b/tests/integration/targets/vyos_config/tasks/main.yaml
@@ -6,3 +6,8 @@
- include: cli_config.yaml
tags:
- cli_config
+
+- include: redirection.yaml
+ when: ansible_version.full is version('2.10.0', '>=')
+ tags:
+ - redirection
diff --git a/tests/integration/targets/vyos_config/tasks/redirection.yaml b/tests/integration/targets/vyos_config/tasks/redirection.yaml
new file mode 100644
index 0000000..5564a3e
--- /dev/null
+++ b/tests/integration/targets/vyos_config/tasks/redirection.yaml
@@ -0,0 +1,16 @@
+---
+- name: collect all redirection cli test cases
+ find:
+ paths: '{{ role_path }}/tests/redirection/cli'
+ patterns: '{{ testcase }}.yaml'
+ register: shortname_test_cases
+ delegate_to: localhost
+
+- name: set test_items for redirection
+ set_fact: test_items="{{ shortname_test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli'
+ with_items: '{{ test_items }}'
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml b/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml
new file mode 100644
index 0000000..ac84154
--- /dev/null
+++ b/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml
@@ -0,0 +1,57 @@
+---
+- debug: msg="START cli/shortname.yaml on connection={{ ansible_connection }}"
+
+- name: setup- ensure interface is not present
+ vyos.vyos.config:
+ lines: delete interfaces loopback lo
+
+- name: setup- create interface
+ register: result
+ vyos.vyos.config:
+ lines:
+ - interfaces
+ - interfaces loopback lo
+ - interfaces loopback lo description test
+
+- name: Check that multiple duplicate lines collapse into a single commands
+ assert:
+ that:
+ - '{{ result.commands|length }} == 1'
+
+- name: Check that set is correctly prepended
+ assert:
+ that:
+ - result.commands[0] == 'set interfaces loopback lo description test'
+
+- name: configure config_check config command
+ register: result
+ vyos.vyos.config:
+ lines: delete interfaces loopback lo
+
+- assert:
+ that:
+ - result.changed == true
+
+- name: check config_check config command idempontent
+ register: result
+ vyos.vyos.config:
+ lines: delete interfaces loopback lo
+
+- assert:
+ that:
+ - result.changed == false
+
+- name: check multiple line config filter is working
+ register: result
+ vyos.vyos.config:
+ lines:
+ - set system login user esa level admin
+ - set system login user esa authentication encrypted-password '!abc!'
+ - set system login user vyos level admin
+ - set system login user vyos authentication encrypted-password 'abc'
+
+- assert:
+ that:
+ - '{{ result.filtered|length }} == 2'
+
+- debug: msg="END cli/shortname.yaml on connection={{ ansible_connection }}"