diff options
Diffstat (limited to 'test')
274 files changed, 0 insertions, 12027 deletions
diff --git a/test/integration/targets/vyos_banner/aliases b/test/integration/targets/vyos_banner/aliases deleted file mode 100644 index 8071e1f75b..0000000000 --- a/test/integration/targets/vyos_banner/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/vyos/group1 diff --git a/test/integration/targets/vyos_banner/defaults/main.yaml b/test/integration/targets/vyos_banner/defaults/main.yaml deleted file mode 100644 index 9ef5ba5165..0000000000 --- a/test/integration/targets/vyos_banner/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_banner/tasks/cli.yaml b/test/integration/targets/vyos_banner/tasks/cli.yaml deleted file mode 100644 index 890d3acf3e..0000000000 --- a/test/integration/targets/vyos_banner/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_banner/tasks/main.yaml b/test/integration/targets/vyos_banner/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_banner/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml b/test/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml deleted file mode 100644 index d513d2e184..0000000000 --- a/test/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml +++ /dev/null @@ -1,41 +0,0 @@ ---- -- debug: - msg: "cli/basic-no-login.yaml on connection={{ ansible_connection }}" - -- name: Setup - vyos_banner: - banner: pre-login - text: | - Junk pre-login banner - over multiple lines - state: present - -- name: remove pre-login - vyos_banner: - banner: pre-login - state: absent - register: result - -- debug: - msg: "{{ result }}" - -- assert: - that: - - "result.changed == true" - - "'delete system login banner pre-login' in result.commands" - -- name: remove pre-login (idempotent) - vyos_banner: - banner: pre-login - state: absent - 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/vyos_banner/tests/cli/basic-post-login.yaml b/test/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml deleted file mode 100644 index bda84a8c8b..0000000000 --- a/test/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- debug: - msg: "cli/basic-post-login.yaml on connection={{ ansible_connection }}" - -- name: setup - remove post-login - vyos_banner: - banner: post-login - state: absent - -- name: Set post-login - vyos_banner: - banner: post-login - text: | - this is my post-login banner - that has a multiline - string - state: present - register: result - -- debug: - msg: "{{ result }}" - -- assert: - that: - - "result.changed == true" - - "'this is my post-login banner' in result.commands[0]" - - "'that has a multiline' in result.commands[0]" - -- name: Set post-login again (idempotent) - vyos_banner: - banner: post-login - text: | - this is my post-login banner - that has a multiline - string - state: present - 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/vyos_banner/tests/cli/basic-pre-login.yaml b/test/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml deleted file mode 100644 index eb66a73b44..0000000000 --- a/test/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- debug: - msg: "cli/basic-pre-login.yaml on connection={{ ansible_connection }}" - -- name: setup - remove pre-login - vyos_banner: - banner: pre-login - state: absent - -- name: Set pre-login - vyos_banner: - banner: pre-login - text: | - this is my pre-login banner - that has a multiline - string - state: present - register: result - -- debug: - msg: "{{ result }}" - -- assert: - that: - - "result.changed == true" - - "'this is my pre-login banner' in result.commands[0]" - - "'that has a multiline' in result.commands[0]" - -- name: Set pre-login again (idempotent) - vyos_banner: - banner: pre-login - text: | - this is my pre-login banner - that has a multiline - string - state: present - 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/vyos_command/aliases b/test/integration/targets/vyos_command/aliases deleted file mode 100644 index 8071e1f75b..0000000000 --- a/test/integration/targets/vyos_command/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/vyos/group1 diff --git a/test/integration/targets/vyos_command/defaults/main.yaml b/test/integration/targets/vyos_command/defaults/main.yaml deleted file mode 100644 index 9ef5ba5165..0000000000 --- a/test/integration/targets/vyos_command/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_command/tasks/cli.yaml b/test/integration/targets/vyos_command/tasks/cli.yaml deleted file mode 100644 index 890d3acf3e..0000000000 --- a/test/integration/targets/vyos_command/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_command/tasks/main.yaml b/test/integration/targets/vyos_command/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_command/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml b/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml deleted file mode 100644 index 4e199bcc4e..0000000000 --- a/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- debug: msg="START cli/bad_operator.yaml on connection={{ ansible_connection }}" - -- name: test bad operator - vyos_command: - commands: - - show version - - show interfaces - wait_for: - - result[0] is 'VyOS' - register: result - ignore_errors: true - -- assert: - that: - - result.failed == true - - result.msg is defined - -- debug: msg="END cli/bad_operator.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/tests/cli/cli_command.yaml b/test/integration/targets/vyos_command/tests/cli/cli_command.yaml deleted file mode 100644 index 12e3394376..0000000000 --- a/test/integration/targets/vyos_command/tests/cli/cli_command.yaml +++ /dev/null @@ -1,41 +0,0 @@ ---- -- debug: - msg: "START cli/cli_command.yaml on connection={{ ansible_connection }}" - -- block: - - name: get output for single command - cli_command: - command: show version - register: result - - - assert: - that: - - "result.changed == false" - - "result.stdout is defined" - - - name: send invalid command - cli_command: - command: 'show foo' - register: result - ignore_errors: true - - - assert: - that: - - "result.failed == true" - - "result.msg is defined" - when: "ansible_connection == 'network_cli'" - -- block: - - name: test failure for local connection - cli_command: - command: show version - register: result - ignore_errors: true - - - assert: - that: - - 'result.failed == true' - - "'Connection type local is not valid for this module' in result.msg" - when: "ansible_connection == 'local'" - -- debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/tests/cli/contains.yaml b/test/integration/targets/vyos_command/tests/cli/contains.yaml deleted file mode 100644 index 85c6e86a18..0000000000 --- a/test/integration/targets/vyos_command/tests/cli/contains.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -- debug: msg="START cli/contains.yaml on connection={{ ansible_connection }}" - -- name: test contains operator - vyos_command: - commands: - - show version - - show interface - wait_for: - - result[0] contains VyOS - - result[1] contains eth0 - register: result - -- assert: - that: - - result.changed == false - - result.stdout is defined - - result.stdout_lines is defined - -- debug: msg="END cli/contains.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/tests/cli/invalid.yaml b/test/integration/targets/vyos_command/tests/cli/invalid.yaml deleted file mode 100644 index 24c1dea78c..0000000000 --- a/test/integration/targets/vyos_command/tests/cli/invalid.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- debug: msg="START cli/invalid.yaml on connection={{ ansible_connection }}" - -- name: run invalid command - vyos_command: - commands: show foo - register: result - ignore_errors: true - -- assert: {that: result.failed} - -- name: run commands that include invalid command - vyos_command: - commands: - - show version - - show foo - register: result - ignore_errors: true - -- assert: {that: result.failed} - -- debug: msg="END cli/invalid.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/tests/cli/output.yaml b/test/integration/targets/vyos_command/tests/cli/output.yaml deleted file mode 100644 index 8be8709776..0000000000 --- a/test/integration/targets/vyos_command/tests/cli/output.yaml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- debug: msg="START cli/output.yaml on connection={{ ansible_connection }}" - -- name: get output for single command - vyos_command: - commands: show version - register: result - -- assert: - that: - - result.changed == false - - result.stdout is defined - - result.stdout_lines is defined - -- name: get output for multiple commands - vyos_command: - commands: - - show version - - show interfaces - register: result - -- assert: - that: - - result.changed == false - - result.stdout is defined - - result.stdout | length == 2 - -- name: Get output for multiple commands that call less explicitly - vyos_command: - commands: - # NOTE: We only test show commands that will output <ANSIBLE_VYOS_TERMINAL_LENGTH - # Otherwise you will get ": "command timeout triggered" - - show hardware cpu detail - - show hardware mem - - show license - register: result - -- assert: - that: - - result.changed == false - - result.stdout_lines is defined - - result.stdout_lines[2] | length >= 20 - -- debug: msg="END cli/output.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/tests/cli/timeout.yaml b/test/integration/targets/vyos_command/tests/cli/timeout.yaml deleted file mode 100644 index e1da173dc4..0000000000 --- a/test/integration/targets/vyos_command/tests/cli/timeout.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -- debug: msg="START cli/timeout.yaml on connection={{ ansible_connection }}" - -- name: test bad condition - vyos_command: - commands: - - show version - wait_for: - - result[0] contains bad_value_string - register: result - ignore_errors: true - -- assert: - that: - - result.failed == true - - result.msg is defined - -- debug: msg="END cli/timeout.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/aliases b/test/integration/targets/vyos_config/aliases deleted file mode 100644 index 8071e1f75b..0000000000 --- a/test/integration/targets/vyos_config/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/vyos/group1 diff --git a/test/integration/targets/vyos_config/defaults/main.yaml b/test/integration/targets/vyos_config/defaults/main.yaml deleted file mode 100644 index 9ef5ba5165..0000000000 --- a/test/integration/targets/vyos_config/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_config/tasks/cli.yaml b/test/integration/targets/vyos_config/tasks/cli.yaml deleted file mode 100644 index 890d3acf3e..0000000000 --- a/test/integration/targets/vyos_config/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_config/tasks/cli_config.yaml b/test/integration/targets/vyos_config/tasks/cli_config.yaml deleted file mode 100644 index f5d5b551fb..0000000000 --- a/test/integration/targets/vyos_config/tasks/cli_config.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -- name: collect all cli_config test cases - find: - paths: "{{ role_path }}/tests/cli_config" - 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_config/tasks/main.yaml b/test/integration/targets/vyos_config/tasks/main.yaml deleted file mode 100644 index 13977a44b1..0000000000 --- a/test/integration/targets/vyos_config/tasks/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} -- {include: cli_config.yaml, tags: ['cli_config']} diff --git a/test/integration/targets/vyos_config/tests/cli/backup.yaml b/test/integration/targets/vyos_config/tests/cli/backup.yaml deleted file mode 100644 index cdf41b1f12..0000000000 --- a/test/integration/targets/vyos_config/tests/cli/backup.yaml +++ /dev/null @@ -1,113 +0,0 @@ ---- -- debug: msg="START vyos/backup.yaml on connection={{ ansible_connection }}" - -- name: collect any backup files - find: - paths: "{{ role_path }}/backup" - pattern: "{{ inventory_hostname_short }}_config*" - register: backup_files - connection: local - -- name: delete backup files - file: - path: "{{ item.path }}" - state: absent - with_items: "{{backup_files.files|default([])}}" - -- name: take configure backup - vyos_config: - backup: true - register: result - -- assert: - that: - - "result.changed == true" - -- name: collect any backup files - find: - paths: "{{ role_path }}/backup" - pattern: "{{ inventory_hostname_short }}_config*" - register: backup_files - connection: local - -- assert: - that: - - "backup_files.files is defined" - -- name: delete configurable backup file path - file: - path: "{{ item }}" - state: absent - with_items: - - "{{ role_path }}/backup_test_dir/" - - "{{ role_path }}/backup/backup.cfg" - -- name: take configuration backup in custom filename and directory path - vyos_config: - backup: true - backup_options: - filename: backup.cfg - dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" - become: true - register: result - -- assert: - that: - - "result.changed == true" - -- name: check if the backup file-1 exist - find: - paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg" - register: backup_file - connection: local - -- assert: - that: - - "backup_file.files is defined" - -- name: take configuration backup in custom filename - vyos_config: - backup: true - backup_options: - filename: backup.cfg - become: true - register: result - -- assert: - that: - - "result.changed == true" - -- name: check if the backup file-2 exist - find: - paths: "{{ role_path }}/backup/backup.cfg" - register: backup_file - connection: local - -- assert: - that: - - "backup_file.files is defined" - -- name: take configuration backup in custom path and default filename - vyos_config: - backup: true - backup_options: - dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" - become: true - register: result - -- assert: - that: - - "result.changed == true" - -- name: check if the backup file-3 exist - find: - paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" - pattern: "{{ inventory_hostname_short }}_config*" - register: backup_file - connection: local - -- assert: - that: - - "backup_file.files is defined" - -- debug: msg="END vyos/backup.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli/check_config.yaml b/test/integration/targets/vyos_config/tests/cli/check_config.yaml deleted file mode 100644 index 1924049362..0000000000 --- a/test/integration/targets/vyos_config/tests/cli/check_config.yaml +++ /dev/null @@ -1,63 +0,0 @@ ---- -- debug: msg="START cli/config_check.yaml on connection={{ ansible_connection }}" - -- name: setup- ensure interface is not present - vyos_config: - lines: delete interfaces loopback lo - -- name: setup- create interface - vyos_config: - lines: - - interfaces - - interfaces loopback lo - - interfaces loopback lo description test - register: result - -# note collapsing the duplicate lines doesn't work if -# lines: -# - interfaces loopback lo description test -# - interfaces loopback lo -# - interfaces - -- 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 - vyos_config: - lines: delete interfaces loopback lo - register: result - -- assert: - that: - - "result.changed == true" - -- name: check config_check config command idempontent - vyos_config: - lines: delete interfaces loopback lo - register: result - -- assert: - that: - - "result.changed == false" - -- name: check multiple line config filter is working - 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' - register: result - -- assert: - that: - - "{{ result.filtered|length }} == 2" - -- debug: msg="END cli/config_check.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli/comment.yaml b/test/integration/targets/vyos_config/tests/cli/comment.yaml deleted file mode 100644 index 3c71dfc64d..0000000000 --- a/test/integration/targets/vyos_config/tests/cli/comment.yaml +++ /dev/null @@ -1,34 +0,0 @@ ---- -- debug: msg="START cli/comment.yaml on connection={{ ansible_connection }}" - -- name: setup - vyos_config: - lines: set system host-name {{ inventory_hostname_short }} - match: none - -- name: configure using comment - vyos_config: - lines: set system host-name foo - comment: this is a test - register: result - -- assert: - that: - - "result.changed == true" - - "'set system host-name foo' in result.commands" - -- name: collect system commits - vyos_command: - commands: show system commit - register: result - -- assert: - that: - - "'this is a test' in result.stdout_lines[0][1]" - -- name: teardown - vyos_config: - lines: set system host-name {{ inventory_hostname_short }} - match: none - -- debug: msg="END cli/comment.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli/config.cfg b/test/integration/targets/vyos_config/tests/cli/config.cfg deleted file mode 100644 index 36c98f19aa..0000000000 --- a/test/integration/targets/vyos_config/tests/cli/config.cfg +++ /dev/null @@ -1,3 +0,0 @@ - set service lldp - set protocols static - diff --git a/test/integration/targets/vyos_config/tests/cli/save.yaml b/test/integration/targets/vyos_config/tests/cli/save.yaml deleted file mode 100644 index 7b058a7be3..0000000000 --- a/test/integration/targets/vyos_config/tests/cli/save.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -- debug: msg="START cli/save.yaml on connection={{ ansible_connection }}" - -- name: setup - vyos_config: - lines: set system host-name {{ inventory_hostname_short }} - match: none - -- name: configure hostaname and save - vyos_config: - lines: set system host-name foo - save: true - register: result - -- assert: - that: - - "result.changed == true" - - "'set system host-name foo' in result.commands" - -- name: configure hostaname and don't save - vyos_config: - lines: set system host-name bar - register: result - -- assert: - that: - - "result.changed == true" - - "'set system host-name bar' in result.commands" - -- name: save config - vyos_config: - save: true - register: result - -- assert: - that: - - "result.changed == true" - -- name: save config again - vyos_config: - save: true - register: result - -- assert: - that: - - "result.changed == false" - -- name: teardown - vyos_config: - lines: set system host-name {{ inventory_hostname_short }} - match: none - save: true - -- debug: msg="END cli/simple.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli/simple.yaml b/test/integration/targets/vyos_config/tests/cli/simple.yaml deleted file mode 100644 index d9185affa8..0000000000 --- a/test/integration/targets/vyos_config/tests/cli/simple.yaml +++ /dev/null @@ -1,53 +0,0 @@ ---- -- debug: msg="START cli/simple.yaml on connection={{ ansible_connection }}" - -- name: setup - vyos_config: - lines: set system host-name {{ inventory_hostname_short }} - match: none - -- name: configure simple config command - vyos_config: - lines: set system host-name foo - register: result - -- assert: - that: - - "result.changed == true" - - "'set system host-name foo' in result.commands" - -- name: check simple config command idempontent - vyos_config: - lines: set system host-name foo - register: result - -- assert: - that: - - "result.changed == false" - -- name: Delete services - vyos_config: &del - lines: - - delete service lldp - - delete protocols static - -- name: Configuring when commands starts with whitespaces - vyos_config: - src: "{{ role_path }}/tests/cli/config.cfg" - register: result - -- assert: - that: - - "result.changed == true" - - '"set service lldp" in result.commands' - - '"set protocols static" in result.commands' - -- name: Delete services - vyos_config: *del - -- name: teardown - vyos_config: - lines: set system host-name {{ inventory_hostname_short }} - match: none - -- debug: msg="END cli/simple.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml b/test/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml deleted file mode 100644 index 9bce0d8d80..0000000000 --- a/test/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml +++ /dev/null @@ -1,114 +0,0 @@ ---- -- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}" - -- name: delete configurable backup file path - file: - path: "{{ item }}" - state: absent - with_items: - - "{{ role_path }}/backup_test_dir/" - - "{{ role_path }}/backup/backup.cfg" - -- name: collect any backup files - find: - paths: "{{ role_path }}/backup" - pattern: "{{ inventory_hostname_short }}_config*" - register: backup_files - connection: local - -- name: delete backup files - file: - path: "{{ item.path }}" - state: absent - with_items: "{{backup_files.files|default([])}}" - -- name: take config backup - cli_config: - backup: true - become: true - register: result - -- assert: - that: - - "result.changed == true" - -- name: collect any backup files - find: - paths: "{{ role_path }}/backup" - pattern: "{{ inventory_hostname_short }}_config*" - register: backup_files - connection: local - -- assert: - that: - - "backup_files.files is defined" - -- name: take configuration backup in custom filename and directory path - cli_config: - backup: true - backup_options: - filename: backup.cfg - dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" - become: true - register: result - -- assert: - that: - - "result.changed == true" - -- name: check if the backup file-1 exist - find: - paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg" - register: backup_file - connection: local - -- assert: - that: - - "backup_file.files is defined" - -- name: take configuration backup in custom filename - cli_config: - backup: true - backup_options: - filename: backup.cfg - become: true - register: result - -- assert: - that: - - "result.changed == true" - -- name: check if the backup file-2 exist - find: - paths: "{{ role_path }}/backup/backup.cfg" - register: backup_file - connection: local - -- assert: - that: - - "backup_file.files is defined" - -- name: take configuration backup in custom path and default filename - cli_config: - backup: true - backup_options: - dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" - become: true - register: result - -- assert: - that: - - "result.changed == true" - -- name: check if the backup file-3 exist - find: - paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" - pattern: "{{ inventory_hostname_short }}_config*" - register: backup_file - connection: local - -- assert: - that: - - "backup_file.files is defined" - -- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml b/test/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml deleted file mode 100644 index e83db1ea84..0000000000 --- a/test/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- debug: msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection }}" - -- name: setup - remove interface description - cli_config: &rm - config: delete interfaces loopback lo description - -- name: configure device with config - cli_config: &conf - config: set interfaces loopback lo description 'this is a test' - register: result - -- assert: - that: - - "result.changed == true" - -- name: Idempotence - cli_config: *conf - register: result - -- assert: - that: - - "result.changed == false" - -- name: teardown - cli_config: *rm - -- debug: msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml b/test/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml deleted file mode 100644 index 163f05ee41..0000000000 --- a/test/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml +++ /dev/null @@ -1,30 +0,0 @@ ---- -- debug: msg="START cli_config/cli_comment.yaml on connection={{ ansible_connection }}" - -- name: setup - cli_config: &rm - config: set system host-name {{ inventory_hostname_short }} - -- name: configure using comment - cli_config: - config: set system host-name foo - commit_comment: this is a test - register: result - -- assert: - that: - - "result.changed == true" - -- name: collect system commits - vyos_command: - commands: show system commit - register: result - -- assert: - that: - - "'this is a test' in result.stdout_lines[0][1]" - -- name: teardown - cli_config: *rm - -- debug: msg="END cli_config/cli_comment.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_facts/aliases b/test/integration/targets/vyos_facts/aliases deleted file mode 100644 index 8071e1f75b..0000000000 --- a/test/integration/targets/vyos_facts/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/vyos/group1 diff --git a/test/integration/targets/vyos_facts/defaults/main.yaml b/test/integration/targets/vyos_facts/defaults/main.yaml deleted file mode 100644 index 9ef5ba5165..0000000000 --- a/test/integration/targets/vyos_facts/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_facts/tasks/cli.yaml b/test/integration/targets/vyos_facts/tasks/cli.yaml deleted file mode 100644 index 890d3acf3e..0000000000 --- a/test/integration/targets/vyos_facts/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_facts/tasks/main.yaml b/test/integration/targets/vyos_facts/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_facts/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_facts/tests/cli/basic_facts.yaml b/test/integration/targets/vyos_facts/tests/cli/basic_facts.yaml deleted file mode 100644 index 322ec033d1..0000000000 --- a/test/integration/targets/vyos_facts/tests/cli/basic_facts.yaml +++ /dev/null @@ -1,46 +0,0 @@ ---- -- name: get host name - vyos_command: - commands: - - show host name - register: vyos_host - -- name: get version info - vyos_command: - commands: - - show version - register: vyos_version - -- name: collect all facts from the device - vyos_facts: - gather_subset: all - register: result - -- name: "check that hostname is present" - assert: - that: - # hostname - - result.ansible_facts.ansible_net_hostname == vyos_host.stdout[0] - -- name: "check that subsets are present" - assert: - that: - # subsets - - "'neighbors' in result.ansible_facts.ansible_net_gather_subset" - - "'default' in result.ansible_facts.ansible_net_gather_subset" - - "'config' in result.ansible_facts.ansible_net_gather_subset" - -- name: "check that version info is present" - assert: - that: - # version info - - result.ansible_facts.ansible_net_version in vyos_version.stdout_lines[0][0] - - result.ansible_facts.ansible_net_model in vyos_version.stdout_lines[0][9] - - result.ansible_facts.ansible_net_serialnum in vyos_version.stdout_lines[0][10] - -- name: "check that config info is present" - assert: - that: - # config info - - result.ansible_facts.ansible_net_commits is defined - - result.ansible_facts.ansible_net_config is defined diff --git a/test/integration/targets/vyos_firewall_global/defaults/main.yaml b/test/integration/targets/vyos_firewall_global/defaults/main.yaml deleted file mode 100644 index 164afead28..0000000000 --- a/test/integration/targets/vyos_firewall_global/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "[^_].*" -test_items: [] diff --git a/test/integration/targets/vyos_firewall_global/meta/main.yaml b/test/integration/targets/vyos_firewall_global/meta/main.yaml deleted file mode 100644 index f88bce5567..0000000000 --- a/test/integration/targets/vyos_firewall_global/meta/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - prepare_vyos_tests diff --git a/test/integration/targets/vyos_firewall_global/tasks/cli.yaml b/test/integration/targets/vyos_firewall_global/tasks/cli.yaml deleted file mode 100644 index 655e51ee63..0000000000 --- a/test/integration/targets/vyos_firewall_global/tasks/cli.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- name: Collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - use_regex: true - 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 (connection=network_cli) - include: "{{ test_case_to_run }}" - vars: - ansible_connection: network_cli - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_firewall_global/tasks/main.yaml b/test/integration/targets/vyos_firewall_global/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_firewall_global/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_firewall_global/tests/cli/_parsed_config.cfg b/test/integration/targets/vyos_firewall_global/tests/cli/_parsed_config.cfg deleted file mode 100644 index 45446bdb08..0000000000 --- a/test/integration/targets/vyos_firewall_global/tests/cli/_parsed_config.cfg +++ /dev/null @@ -1,19 +0,0 @@ -set firewall all-ping 'enable' -set firewall broadcast-ping 'enable' -set firewall config-trap 'enable' -set firewall group address-group MGMT-HOSTS address '192.0.1.1' -set firewall group address-group MGMT-HOSTS address '192.0.1.3' -set firewall group address-group MGMT-HOSTS address '192.0.1.5' -set firewall group address-group MGMT-HOSTS description 'This group has the Management hosts address list' -set firewall group network-group MGMT description 'This group has the Management network addresses' -set firewall group network-group MGMT network '192.0.1.0/24' -set firewall ip-src-route 'enable' -set firewall log-martians 'enable' -set firewall receive-redirects 'disable' -set firewall send-redirects 'enable' -set firewall source-validation 'strict' -set firewall state-policy established action 'accept' -set firewall state-policy established log 'enable' -set firewall state-policy invalid action 'reject' -set firewall syn-cookies 'enable' -set firewall twa-hazards-protection 'enable' diff --git a/test/integration/targets/vyos_firewall_global/tests/cli/_populate.yaml b/test/integration/targets/vyos_firewall_global/tests/cli/_populate.yaml deleted file mode 100644 index 5417bad9ac..0000000000 --- a/test/integration/targets/vyos_firewall_global/tests/cli/_populate.yaml +++ /dev/null @@ -1,25 +0,0 @@ ---- -- name: Setup - cli_config: - config: "{{ lines }}" - vars: - lines: | - set firewall all-ping 'enable' - set firewall broadcast-ping 'enable' - set firewall config-trap 'enable' - set firewall group address-group MGMT-HOSTS address '192.0.1.1' - set firewall group address-group MGMT-HOSTS address '192.0.1.3' - set firewall group address-group MGMT-HOSTS address '192.0.1.5' - set firewall group address-group MGMT-HOSTS description 'This group has the Management hosts address list' - set firewall group network-group MGMT description 'This group has the Management network addresses' - set firewall group network-group MGMT network '192.0.1.0/24' - set firewall ip-src-route 'enable' - set firewall log-martians 'enable' - set firewall receive-redirects 'disable' - set firewall send-redirects 'enable' - set firewall source-validation 'strict' - set firewall state-policy established action 'accept' - set firewall state-policy established log 'enable' - set firewall state-policy invalid action 'reject' - set firewall syn-cookies 'enable' - set firewall twa-hazards-protection 'enable' diff --git a/test/integration/targets/vyos_firewall_global/tests/cli/_remove_config.yaml b/test/integration/targets/vyos_firewall_global/tests/cli/_remove_config.yaml deleted file mode 100644 index e56093b389..0000000000 --- a/test/integration/targets/vyos_firewall_global/tests/cli/_remove_config.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Remove Config - cli_config: - config: "{{ lines }}" - vars: - lines: | - delete firewall diff --git a/test/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml b/test/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml deleted file mode 100644 index 8cce6c94d9..0000000000 --- a/test/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- debug: - msg: "Start vyos_firewall_global deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate.yaml - -- block: - - name: Delete attributes of firewall. - vyos_firewall_global: &deleted - config: - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate == result['before'] }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted['after'] == result['after'] }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_firewall_global: *deleted - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - "result.commands|length == 0" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted['after'] == result['before'] }}" - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_global/tests/cli/empty_config.yaml b/test/integration/targets/vyos_firewall_global/tests/cli/empty_config.yaml deleted file mode 100644 index 0edd88083e..0000000000 --- a/test/integration/targets/vyos_firewall_global/tests/cli/empty_config.yaml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_global empty_config integration tests on connection={{ ansible_connection }}" - -- name: Merged with empty config should give appropriate error message - vyos_firewall_global: - config: - state: merged - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state merged' - -- name: Replaced with empty config should give appropriate error message - vyos_firewall_global: - config: - state: replaced - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state replaced' - -- name: Parsed with empty running_config should give appropriate error message - vyos_firewall_global: - running_config: - state: parsed - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of running_config parameter must not be empty for state parsed' - -- name: Rendered with empty config should give appropriate error message - vyos_firewall_global: - config: - state: rendered - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/test/integration/targets/vyos_firewall_global/tests/cli/gathered.yaml b/test/integration/targets/vyos_firewall_global/tests/cli/gathered.yaml deleted file mode 100644 index 0aca48bbed..0000000000 --- a/test/integration/targets/vyos_firewall_global/tests/cli/gathered.yaml +++ /dev/null @@ -1,31 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_global gathered integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Merge the provided configuration with the exisiting running configuration - vyos_firewall_global: &gathered - config: - state: gathered - register: result - - - name: Assert that gathered dicts was correctly generated - assert: - that: - - "{{ populate == result['gathered'] }}" - - - name: Gather the existing running configuration (IDEMPOTENT) - vyos_firewall_global: *gathered - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_global/tests/cli/merged.yaml b/test/integration/targets/vyos_firewall_global/tests/cli/merged.yaml deleted file mode 100644 index 3bd433aae0..0000000000 --- a/test/integration/targets/vyos_firewall_global/tests/cli/merged.yaml +++ /dev/null @@ -1,76 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_global merged integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- block: - - name: Merge the provided configuration with the exisiting running configuration - vyos_firewall_global: &merged - config: - validation: strict - config_trap: True - log_martians: True - syn_cookies: True - twa_hazards_protection: True - ping: - all: True - broadcast: True - state_policy: - - connection_type: 'established' - action: 'accept' - log: True - - connection_type: 'invalid' - action: 'reject' - route_redirects: - - afi: 'ipv4' - ip_src_route: True - icmp_redirects: - send: True - receive: False - group: - address_group: - - name: 'MGMT-HOSTS' - description: 'This group has the Management hosts address list' - members: - - address: 192.0.1.1 - - address: 192.0.1.3 - - address: 192.0.1.5 - network_group: - - name: 'MGMT' - description: 'This group has the Management network addresses' - members: - - address: 192.0.1.0/24 - state: merged - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: "{{ merged['before'] == result['before'] }}" - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts was correctly generated - assert: - that: - - "{{ merged['after'] == result['after'] }}" - - - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) - vyos_firewall_global: *merged - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ merged['after'] == result['before'] }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_global/tests/cli/parsed.yaml b/test/integration/targets/vyos_firewall_global/tests/cli/parsed.yaml deleted file mode 100644 index 24e77fa7ca..0000000000 --- a/test/integration/targets/vyos_firewall_global/tests/cli/parsed.yaml +++ /dev/null @@ -1,39 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_global parsed integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Gather firewall_global facts - vyos_facts: - gather_subset: - - default - gather_network_resources: - - firewall_global - register: firewall_global_facts - - - name: Provide the running configuration for parsing (config to be parsed) - vyos_firewall_global: &parsed - running_config: - "{{ lookup('file', '_parsed_config.cfg') }}" - state: parsed - register: result - - - name: Assert that correct parsing done - assert: - that: "{{ ansible_facts['network_resources']['firewall_global'] == result['parsed'] }}" - - - name: Gather the existing running configuration (IDEMPOTENT) - vyos_firewall_global: *parsed - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_global/tests/cli/rendered.yaml b/test/integration/targets/vyos_firewall_global/tests/cli/rendered.yaml deleted file mode 100644 index 7a92bb314c..0000000000 --- a/test/integration/targets/vyos_firewall_global/tests/cli/rendered.yaml +++ /dev/null @@ -1,69 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_global rendered integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Structure provided configuration into device specific commands - vyos_firewall_global: &rendered - config: - validation: strict - config_trap: True - log_martians: True - syn_cookies: True - twa_hazards_protection: True - ping: - all: True - broadcast: True - state_policy: - - connection_type: 'established' - action: 'accept' - log: True - - connection_type: 'invalid' - action: 'reject' - route_redirects: - - afi: 'ipv4' - ip_src_route: True - icmp_redirects: - send: True - receive: False - group: - address_group: - - name: 'SALES-HOSTS' - description: 'Sales office hosts address list' - members: - - address: 192.0.2.1 - - address: 192.0.2.2 - - address: 192.0.2.3 - - name: 'ENG-HOSTS' - description: 'Sales office hosts address list' - members: - - address: 192.0.3.1 - - address: 192.0.3.2 - network_group: - - name: 'MGMT' - description: 'This group has the Management network addresses' - members: - - address: 192.0.1.0/24 - state: rendered - register: result - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" - - - name: Structure provided configuration into device specific commands (IDEMPOTENT) - vyos_firewall_global: *rendered - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml b/test/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml deleted file mode 100644 index 57a4f71b3a..0000000000 --- a/test/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml +++ /dev/null @@ -1,84 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_global replaced integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Replace device configurations of listed firewall with provided configurations - vyos_firewall_global: &replaced - config: - validation: strict - config_trap: True - log_martians: True - syn_cookies: True - twa_hazards_protection: True - ping: - all: True - broadcast: True - state_policy: - - connection_type: 'established' - action: 'accept' - log: True - - connection_type: 'invalid' - action: 'reject' - route_redirects: - - afi: 'ipv4' - ip_src_route: True - icmp_redirects: - send: True - receive: False - group: - address_group: - - name: 'SALES-HOSTS' - description: 'Sales office hosts address list' - members: - - address: 192.0.2.1 - - address: 192.0.2.2 - - address: 192.0.2.3 - - name: 'ENG-HOSTS' - description: 'Sales office hosts address list' - members: - - address: 192.0.3.1 - - address: 192.0.3.2 - network_group: - - name: 'MGMT' - description: 'This group has the Management network addresses' - members: - - address: 192.0.1.0/24 - state: replaced - register: result - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that before dicts are correctly generated - assert: - that: - - "{{ populate == result['before'] }}" - - - name: Assert that after dict is correctly generated - assert: - that: - - "{{ replaced['after'] == result['after'] }}" - - - name: Replace device configurations of listed firewall with provided configurarions (IDEMPOTENT) - vyos_firewall_global: *replaced - register: result - - - name: Assert that task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dict is correctly generated - assert: - that: - - "{{ replaced['after'] == result['before'] }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_global/tests/cli/rtt.yaml b/test/integration/targets/vyos_firewall_global/tests/cli/rtt.yaml deleted file mode 100644 index e092afd784..0000000000 --- a/test/integration/targets/vyos_firewall_global/tests/cli/rtt.yaml +++ /dev/null @@ -1,83 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_global round trip integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- block: - - name: Apply the provided configuration (base config) - vyos_firewall_global: - config: - validation: strict - config_trap: True - log_martians: True - syn_cookies: True - twa_hazards_protection: True - ping: - all: True - broadcast: True - state_policy: - - connection_type: 'established' - action: 'accept' - log: True - - connection_type: 'invalid' - action: 'reject' - route_redirects: - - afi: 'ipv4' - ip_src_route: True - icmp_redirects: - send: True - receive: False - group: - address_group: - - name: 'MGMT-HOSTS' - description: 'This group has the Management hosts address list' - members: - - address: 192.0.1.1 - - address: 192.0.1.3 - - address: 192.0.1.5 - network_group: - - name: 'MGMT' - description: 'This group has the Management network addresses' - members: - - address: 192.0.1.0/24 - state: merged - register: base_config - - - name: Gather firewall_global facts - vyos_facts: - gather_subset: - - default - gather_network_resources: - - firewall_global - - - name: Apply the provided configuration (config to be reverted) - vyos_firewall_global: - config: - validation: strict - config_trap: False - log_martians: False - syn_cookies: False - twa_hazards_protection: False - ping: - all: False - broadcast: False - state: merged - register: result - - - name: Assert that changes were applied - assert: - that: "{{ round_trip['after'] == result['after'] }}" - - - name: Revert back to base config using facts round trip - vyos_firewall_global: - config: "{{ ansible_facts['network_resources']['firewall_global'] }}" - state: replaced - register: revert - - - name: Assert that config was reverted - assert: - that: "{{ base_config['after'] == revert['after']}}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_global/vars/main.yaml b/test/integration/targets/vyos_firewall_global/vars/main.yaml deleted file mode 100644 index 409104ebcb..0000000000 --- a/test/integration/targets/vyos_firewall_global/vars/main.yaml +++ /dev/null @@ -1,218 +0,0 @@ ---- -merged: - before: [] - - - commands: - - "set firewall group address-group MGMT-HOSTS address 192.0.1.1" - - "set firewall group address-group MGMT-HOSTS address 192.0.1.3" - - "set firewall group address-group MGMT-HOSTS address 192.0.1.5" - - "set firewall group address-group MGMT-HOSTS description 'This group has the Management hosts address list'" - - "set firewall group address-group MGMT-HOSTS" - - "set firewall group network-group MGMT network 192.0.1.0/24" - - "set firewall group network-group MGMT description 'This group has the Management network addresses'" - - "set firewall group network-group MGMT" - - "set firewall ip-src-route 'enable'" - - "set firewall receive-redirects 'disable'" - - "set firewall send-redirects 'enable'" - - "set firewall config-trap 'enable'" - - "set firewall state-policy established action 'accept'" - - "set firewall state-policy established log 'enable'" - - "set firewall state-policy invalid action 'reject'" - - "set firewall broadcast-ping 'enable'" - - "set firewall all-ping 'enable'" - - "set firewall log-martians 'enable'" - - "set firewall twa-hazards-protection 'enable'" - - "set firewall syn-cookies 'enable'" - - "set firewall source-validation 'strict'" - - after: - config_trap: true - group: - address_group: - - members: - - address: 192.0.1.1 - - address: 192.0.1.3 - - address: 192.0.1.5 - description: This group has the Management hosts address list - name: MGMT-HOSTS - network_group: - - members: - - address: 192.0.1.0/24 - description: This group has the Management network addresses - name: MGMT - log_martians: true - ping: - all: true - broadcast: true - route_redirects: - - afi: ipv4 - icmp_redirects: - receive: false - send: true - ip_src_route: true - syn_cookies: true - state_policy: - - action: accept - connection_type: established - log: true - - action: reject - connection_type: invalid - twa_hazards_protection: true - validation: strict - -populate: - validation: strict - config_trap: True - log_martians: True - syn_cookies: True - twa_hazards_protection: True - ping: - all: True - broadcast: True - state_policy: - - connection_type: 'established' - action: 'accept' - log: True - - connection_type: 'invalid' - action: 'reject' - route_redirects: - - afi: 'ipv4' - ip_src_route: True - icmp_redirects: - send: True - receive: False - group: - address_group: - - name: 'MGMT-HOSTS' - description: 'This group has the Management hosts address list' - members: - - address: 192.0.1.1 - - address: 192.0.1.3 - - address: 192.0.1.5 - network_group: - - name: 'MGMT' - description: 'This group has the Management network addresses' - members: - - address: 192.0.1.0/24 - -replaced: - commands: - - "delete firewall group address-group MGMT-HOSTS" - - "set firewall group address-group SALES-HOSTS address 192.0.2.1" - - "set firewall group address-group SALES-HOSTS address 192.0.2.2" - - "set firewall group address-group SALES-HOSTS address 192.0.2.3" - - "set firewall group address-group SALES-HOSTS description 'Sales office hosts address list'" - - "set firewall group address-group SALES-HOSTS" - - "set firewall group address-group ENG-HOSTS address 192.0.3.1" - - "set firewall group address-group ENG-HOSTS address 192.0.3.2" - - "set firewall group address-group ENG-HOSTS description 'Sales office hosts address list'" - - "set firewall group address-group ENG-HOSTS" - - after: - config_trap: true - group: - address_group: - - members: - - address: 192.0.3.1 - - address: 192.0.3.2 - description: 'Sales office hosts address list' - name: 'ENG-HOSTS' - - members: - - address: 192.0.2.1 - - address: 192.0.2.2 - - address: 192.0.2.3 - description: 'Sales office hosts address list' - name: 'SALES-HOSTS' - network_group: - - members: - - address: 192.0.1.0/24 - description: 'This group has the Management network addresses' - name: 'MGMT' - log_martians: true - ping: - all: true - broadcast: true - route_redirects: - - afi: 'ipv4' - icmp_redirects: - receive: false - send: true - ip_src_route: true - state_policy: - - action: 'accept' - connection_type: 'established' - log: true - - action: 'reject' - connection_type: 'invalid' - syn_cookies: true - twa_hazards_protection: true - validation: strict -rendered: - commands: - - set firewall group address-group SALES-HOSTS address 192.0.2.1 - - set firewall group address-group SALES-HOSTS address 192.0.2.2 - - set firewall group address-group SALES-HOSTS address 192.0.2.3 - - set firewall group address-group SALES-HOSTS description 'Sales office hosts address list' - - set firewall group address-group SALES-HOSTS - - set firewall group address-group ENG-HOSTS address 192.0.3.1 - - set firewall group address-group ENG-HOSTS address 192.0.3.2 - - set firewall group address-group ENG-HOSTS description 'Sales office hosts address list' - - set firewall group address-group ENG-HOSTS - - set firewall group network-group MGMT network 192.0.1.0/24 - - set firewall group network-group MGMT description 'This group has the Management network addresses' - - set firewall group network-group MGMT - - set firewall ip-src-route 'enable' - - set firewall receive-redirects 'disable' - - set firewall send-redirects 'enable' - - set firewall config-trap 'enable' - - set firewall state-policy established action 'accept' - - set firewall state-policy established log 'enable' - - set firewall state-policy invalid action 'reject' - - set firewall broadcast-ping 'enable' - - set firewall all-ping 'enable' - - set firewall log-martians 'enable' - - set firewall twa-hazards-protection 'enable' - - set firewall syn-cookies 'enable' - - set firewall source-validation 'strict' -deleted: - commands: - - "delete firewall " - - after: [] - -round_trip: - after: - validation: strict - config_trap: False - log_martians: False - syn_cookies: False - twa_hazards_protection: False - ping: - all: False - broadcast: False - state_policy: - - connection_type: 'established' - action: 'accept' - log: True - - connection_type: 'invalid' - action: 'reject' - route_redirects: - - afi: 'ipv4' - ip_src_route: True - icmp_redirects: - send: True - receive: False - group: - address_group: - - name: 'MGMT-HOSTS' - description: 'This group has the Management hosts address list' - members: - - address: 192.0.1.1 - - address: 192.0.1.3 - - address: 192.0.1.5 - network_group: - - name: 'MGMT' - description: 'This group has the Management network addresses' - members: - - address: 192.0.1.0/24 diff --git a/test/integration/targets/vyos_firewall_interfaces/1 b/test/integration/targets/vyos_firewall_interfaces/1 deleted file mode 100644 index 70ae90f3e6..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/1 +++ /dev/null @@ -1,120 +0,0 @@ ---- -merged: - before: [] - - - commands: - - "set interfaces ethernet eth1 firewall in name 'INBOUND'" - - "set interfaces ethernet eth1 firewall out name 'OUTBOUND'" - - "set interfaces ethernet eth1 firewall local name 'LOCAL'" - - "set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL'" - - "set interfaces ethernet eth3 firewall in name 'INBOUND'" - - "set interfaces ethernet eth3 firewall out name 'OUTBOUND'" - - "set interfaces ethernet eth3 firewall local name 'LOCAL'" - - "set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL'" - - after: - - name: 'eth1' - access_rules: - - afi: 'ipv4' - rules: - - name: 'INBOUND' - direction: 'in' - - name: 'OUBOUND' - direction: 'out' - - afi: 'ipv6' - rules: - - name: 'V6-LOCAL' - direction: 'local' - -populate: - - name: 'eth1' - access_rules: - - afi: 'ipv4' - rules: - - name: 'INBOUND' - direction: 'in' - - name: 'OUBOUND' - direction: 'out' - - afi: 'ipv6' - rules: - - name: 'LOCAL' - direction: 'local' - -replaced: - commands: - - "delete service lldp interface eth2 location" - - "set service lldp interface eth2 'disable'" - - "set service lldp interface eth2 location civic-based country-code 'US'" - - "set service lldp interface eth2 location civic-based ca-type 0 ca-value 'ENGLISH'" - - "delete service lldp interface eth1 location" - - "set service lldp interface eth1 'disable'" - - "set service lldp interface eth1 location coordinate-based latitude '33.524449N'" - - "set service lldp interface eth1 location coordinate-based altitude '2200'" - - "set service lldp interface eth1 location coordinate-based datum 'WGS84'" - - "set service lldp interface eth1 location coordinate-based longitude '222.267255W'" - - after: - - name: 'eth2' - enable: false - location: - civic_based: - country_code: 'US' - ca_info: - - ca_type: 0 - ca_value: 'ENGLISH' - - - name: 'eth1' - enable: false - location: - coordinate_based: - altitude: 2200 - datum: 'WGS84' - longitude: '222.267255W' - latitude: '33.524449N' - -populate_intf: - - name: 'eth2' - enable: false - location: - civic_based: - country_code: 'US' - ca_info: - - ca_type: 0 - ca_value: 'ENGLISH' - -overridden: - commands: - - "delete service lldp interface eth2 location" - - "delete service lldp interface eth2 'disable'" - - "set service lldp interface eth2 location elin '0000000911'" - - after: - - name: 'eth2' - location: - elin: 0000000911 - -deleted: - commands: - - "delete service lldp interface eth1" - - "delete service lldp interface eth2" - - after: [] - -round_trip: - after: - - name: 'eth1' - location: - civic_based: - country_code: 'US' - ca_info: - - ca_type: 0 - ca_value: 'ENGLISH' - - - name: 'eth2' - location: - coordinate_based: - altitude: 2200 - datum: 'WGS84' - longitude: '222.267255W' - latitude: '33.524449N' diff --git a/test/integration/targets/vyos_firewall_interfaces/defaults/main.yaml b/test/integration/targets/vyos_firewall_interfaces/defaults/main.yaml deleted file mode 100644 index 164afead28..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "[^_].*" -test_items: [] diff --git a/test/integration/targets/vyos_firewall_interfaces/meta/main.yaml b/test/integration/targets/vyos_firewall_interfaces/meta/main.yaml deleted file mode 100644 index 7413320e48..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/meta/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_vyos_tests diff --git a/test/integration/targets/vyos_firewall_interfaces/tasks/cli.yaml b/test/integration/targets/vyos_firewall_interfaces/tasks/cli.yaml deleted file mode 100644 index 655e51ee63..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tasks/cli.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- name: Collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - use_regex: true - 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 (connection=network_cli) - include: "{{ test_case_to_run }}" - vars: - ansible_connection: network_cli - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_firewall_interfaces/tasks/main.yaml b/test/integration/targets/vyos_firewall_interfaces/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/_parsed_config.cfg b/test/integration/targets/vyos_firewall_interfaces/tests/cli/_parsed_config.cfg deleted file mode 100644 index 54696e8d4e..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/_parsed_config.cfg +++ /dev/null @@ -1,10 +0,0 @@ -set interfaces ethernet eth1 firewall in name 'INBOUND' -set interfaces ethernet eth1 firewall out name 'OUTBOUND' -set interfaces ethernet eth1 firewall local name 'LOCAL' -set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' -set interfaces ethernet eth2 firewall in name 'INBOUND' -set interfaces ethernet eth2 firewall out name 'OUTBOUND' -set interfaces ethernet eth2 firewall local name 'LOCAL' -set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL' -set interfaces ethernet eth0 - diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/_populate.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/_populate.yaml deleted file mode 100644 index 99abf94d5d..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/_populate.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -- name: Setup - cli_config: - config: "{{ lines }}" - vars: - lines: | - set interfaces ethernet eth1 firewall in name 'INBOUND' - set interfaces ethernet eth1 firewall out name 'OUTBOUND' - set interfaces ethernet eth1 firewall local name 'LOCAL' - set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' - set interfaces ethernet eth2 firewall in name 'INBOUND' - set interfaces ethernet eth2 firewall out name 'OUTBOUND' - set interfaces ethernet eth2 firewall local name 'LOCAL' - set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL' - diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/_populate_rule_sets.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/_populate_rule_sets.yaml deleted file mode 100644 index e5d15fe008..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/_populate_rule_sets.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Setup - cli_config: - config: "{{ lines }}" - vars: - lines: | - set firewall name 'INBOUND' - set firewall name 'OUTBOUND' - set firewall name 'LOCAL' - set firewall ipv6-name 'V6-LOCAL' diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_config.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_config.yaml deleted file mode 100644 index 843ce31234..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_config.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- name: Remove Config - cli_config: - config: "{{ lines }}" - vars: - lines: | - delete interfaces ethernet eth1 firewall - delete interfaces ethernet eth2 firewall diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_firewall_config.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_firewall_config.yaml deleted file mode 100644 index 7755d9fe7f..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_firewall_config.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Remove Config - cli_config: - config: "{{ lines }}" - vars: - lines: | - delete firewall name INBOUND - delete firewall name OUTBOUND - delete firewall name LOCAL - delete firewall ipv6-name V6-LOCAL diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/deleted.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/deleted.yaml deleted file mode 100644 index c9c464ab3c..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/deleted.yaml +++ /dev/null @@ -1,50 +0,0 @@ ---- -- debug: - msg: "Start vyos_firewall_interfaces deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate_rule_sets.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Delete attributes of given firewall rules. - vyos_firewall_interfaces: &deleted - config: - - name: 'eth1' - - name: 'eth2' - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_firewall_interfaces: *deleted - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - "result.commands|length == 0" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}" - always: - - include_tasks: _remove_config.yaml - - - include_tasks: _remove_firewall_config.yaml diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_afi.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_afi.yaml deleted file mode 100644 index 175a59f83b..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_afi.yaml +++ /dev/null @@ -1,56 +0,0 @@ ---- -- debug: - msg: "Start vyos_firewall_interfaces deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate_rule_sets.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Delete firewall interfaces based on IP address type provided. - vyos_firewall_interfaces: &deleted_afi - config: - - name: 'eth1' - access_rules: - - afi: 'ipv4' - - afi: 'ipv6' - - name: 'eth2' - access_rules: - - afi: 'ipv4' - - afi: 'ipv6' - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted_afi['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted_afi['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_firewall_interfaces: *deleted_afi - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - "result.commands|length == 0" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted_afi['after'] | symmetric_difference(result['before']) |length == 0 }}" - always: - - include_tasks: _remove_config.yaml - - - include_tasks: _remove_firewall_config.yaml diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_all.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_all.yaml deleted file mode 100644 index 38495d4839..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_all.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -- debug: - msg: "Start vyos_firewall_interfaces deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate_rule_sets.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Delete all the firewall interfaces. - vyos_firewall_interfaces: &deleted_all - config: - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_firewall_interfaces: *deleted_all - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - "result.commands|length == 0" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}" - always: - - include_tasks: _remove_config.yaml - - - include_tasks: _remove_firewall_config.yaml diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_single.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_single.yaml deleted file mode 100644 index 70c58fc255..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_single.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -- debug: - msg: "Start vyos_firewall_interfaces deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate_rule_sets.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Delete firewall interface. - vyos_firewall_interfaces: &deleted_single - config: - - name: 'eth1' - access_rules: - - afi: 'ipv4' - rules: - - direction: 'in' - name: 'INBOUND' - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted_single['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted_single['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_firewall_interfaces: *deleted_single - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - "result.commands|length == 0" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted_single['after'] | symmetric_difference(result['before']) |length == 0 }}" - always: - - include_tasks: _remove_config.yaml - - - include_tasks: _remove_firewall_config.yaml diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/empty_config.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/empty_config.yaml deleted file mode 100644 index 0881d5f8bc..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/empty_config.yaml +++ /dev/null @@ -1,58 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_interfaces empty_config integration tests on connection={{ ansible_connection }}" - -- name: Merged with empty config should give appropriate error message - vyos_firewall_interfaces: - config: - state: merged - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state merged' - -- name: Replaced with empty config should give appropriate error message - vyos_firewall_interfaces: - config: - state: replaced - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state replaced' - -- name: Overridden with empty config should give appropriate error message - vyos_firewall_interfaces: - config: - state: overridden - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state overridden' - -- name: Parsed with empty running_config should give appropriate error message - vyos_firewall_interfaces: - running_config: - state: parsed - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of running_config parameter must not be empty for state parsed' - -- name: Rendered with empty config should give appropriate error message - vyos_firewall_interfaces: - config: - state: rendered - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/gathered.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/gathered.yaml deleted file mode 100644 index 2536476b8f..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/gathered.yaml +++ /dev/null @@ -1,37 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_interfaces gathered integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _remove_firewall_config.yaml - -- include_tasks: _populate_rule_sets.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Merge the provided configuration with the exisiting running configuration - vyos_firewall_interfaces: &gathered - config: - state: gathered - register: result - - - name: Assert that gathered dicts was correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['gathered']) |length == 0 }}" - - - name: Gather the existing running configuration (IDEMPOTENT) - vyos_firewall_interfaces: *gathered - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - always: - - include_tasks: _remove_config.yaml - - - include_tasks: _remove_firewall_config.yaml diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/merged.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/merged.yaml deleted file mode 100644 index fb0733809b..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/merged.yaml +++ /dev/null @@ -1,75 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_interfaces merged integration tests on connection={{ ansible_connection }}" - -- include_tasks: _populate_rule_sets.yaml - -- include_tasks: _remove_config.yaml - -- block: - - name: Merge the provided configuration with the exisiting running configuration - vyos_firewall_interfaces: &merged - config: - - name: 'eth1' - access_rules: - - afi: 'ipv4' - rules: - - direction: 'in' - name: 'INBOUND' - - direction: 'local' - name: 'LOCAL' - - direction: 'out' - name: 'OUTBOUND' - - afi: 'ipv6' - rules: - - direction: 'local' - name: 'V6-LOCAL' - - name: 'eth2' - access_rules: - - afi: 'ipv4' - rules: - - direction: 'in' - name: 'INBOUND' - - direction: 'local' - name: 'LOCAL' - - direction: 'out' - name: 'OUTBOUND' - - afi: 'ipv6' - rules: - - direction: 'local' - name: 'V6-LOCAL' - state: merged - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts was correctly generated - assert: - that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) - vyos_firewall_interfaces: *merged - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml - - - include_tasks: _remove_firewall_config.yaml diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/merged_edit.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/merged_edit.yaml deleted file mode 100644 index 1393a5b10d..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/merged_edit.yaml +++ /dev/null @@ -1,59 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_interfaces merged integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _remove_firewall_config.yaml - -- include_tasks: _populate_rule_sets.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Merge the provided configuration with the exisiting running configuration - vyos_firewall_interfaces: &merged_edit - config: - - name: 'eth1' - access_rules: - - afi: 'ipv4' - rules: - - direction: 'in' - name: 'OUTBOUND' - - direction: 'out' - name: 'INBOUND' - state: merged - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ merged_edit['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts was correctly generated - assert: - that: - - "{{ merged_edit['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) - vyos_firewall_interfaces: *merged_edit - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ merged_edit['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml - - - include_tasks: _remove_firewall_config.yaml diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/overridden.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/overridden.yaml deleted file mode 100644 index daf3414518..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/overridden.yaml +++ /dev/null @@ -1,58 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_interfaces overridden integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _remove_firewall_config.yaml - -- include_tasks: _populate_rule_sets.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Overrides all device configuration with provided configuration - vyos_firewall_interfaces: &overridden - config: - - name: 'eth2' - access_rules: - - afi: 'ipv4' - rules: - - name: 'INBOUND' - direction: 'out' - state: overridden - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that correct commands were generated - assert: - that: - - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts were correctly generated - assert: - that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Overrides all device configuration with provided configurations (IDEMPOTENT) - vyos_firewall_interfaces: *overridden - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml - - - include_tasks: _remove_firewall_config.yaml diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/parsed.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/parsed.yaml deleted file mode 100644 index 646af8b847..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/parsed.yaml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_interfaces parsed integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _remove_firewall_config.yaml - -- include_tasks: _populate_rule_sets.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Gather firewall_interfaces facts - vyos_facts: - gather_subset: - - default - gather_network_resources: - - firewall_interfaces - register: firewall_interfaces_facts - - - name: Provide the running configuration for parsing (config to be parsed) - vyos_firewall_interfaces: &parsed - running_config: - "{{ lookup('file', '_parsed_config.cfg') }}" - state: parsed - register: result - - - name: Assert that correct parsing done - assert: - that: "{{ ansible_facts['network_resources']['firewall_interfaces'] | symmetric_difference(result['parsed']) |length == 0 }}" - - - name: Gather the existing running configuration (IDEMPOTENT) - vyos_firewall_interfaces: *parsed - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - always: - - include_tasks: _remove_config.yaml - - - include_tasks: _remove_firewall_config.yaml diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/rendered.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/rendered.yaml deleted file mode 100644 index ff969ede61..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/rendered.yaml +++ /dev/null @@ -1,55 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_interfaces rendered integration tests on connection={{ ansible_connection }}" - -- block: - - name: Structure provided configuration into device specific commands - vyos_firewall_interfaces: &rendered - config: - - name: 'eth1' - access_rules: - - afi: 'ipv4' - rules: - - name: 'INBOUND' - direction: 'in' - - name: 'OUTBOUND' - direction: 'out' - - name: 'LOCAL' - direction: 'local' - - afi: 'ipv6' - rules: - - name: 'V6-LOCAL' - direction: 'local' - - name: 'eth2' - access_rules: - - afi: 'ipv4' - rules: - - name: 'INBOUND' - direction: 'in' - - name: 'OUTBOUND' - direction: 'out' - - name: 'LOCAL' - direction: 'local' - - afi: 'ipv6' - rules: - - name: 'V6-LOCAL' - direction: 'local' - state: rendered - register: result - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" - - - name: Structure provided configuration into device specific commands (IDEMPOTENT) - vyos_firewall_interfaces: *rendered - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/replaced.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/replaced.yaml deleted file mode 100644 index cd349ae239..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/replaced.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_interfaces replaced integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _remove_firewall_config.yaml - -- include_tasks: _populate_rule_sets.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Replace device configurations of listed firewall rules with provided configurations - vyos_firewall_interfaces: &replaced - config: - - name: 'eth1' - access_rules: - - afi: 'ipv4' - rules: - - name: 'OUTBOUND' - direction: 'out' - - afi: 'ipv6' - rules: - - name: 'V6-LOCAL' - direction: 'local' - - name: 'eth2' - access_rules: - - afi: 'ipv4' - rules: - - name: 'INBOUND' - direction: 'in' - state: replaced - register: result - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that before dicts are correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that after dict is correctly generated - assert: - that: - - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Replace device configurations of listed firewall rules with provided configurarions (IDEMPOTENT) - vyos_firewall_interfaces: *replaced - register: result - - - name: Assert that task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dict is correctly generated - assert: - that: - - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml - - - include_tasks: _remove_firewall_config.yaml diff --git a/test/integration/targets/vyos_firewall_interfaces/tests/cli/rtt.yaml b/test/integration/targets/vyos_firewall_interfaces/tests/cli/rtt.yaml deleted file mode 100644 index 0d06069fb5..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/tests/cli/rtt.yaml +++ /dev/null @@ -1,76 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_interfaces round trip integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _remove_firewall_config.yaml - -- include_tasks: _populate_rule_sets.yaml - -- block: - - name: Apply the provided configuration (base config) - vyos_firewall_interfaces: - config: - - name: 'eth1' - access_rules: - - afi: 'ipv4' - rules: - - name: 'INBOUND' - direction: 'in' - - name: 'OUTBOUND' - direction: 'out' - - name: 'LOCAL' - direction: 'local' - - afi: 'ipv6' - rules: - - name: 'V6-LOCAL' - direction: 'local' - state: merged - register: base_config - - - name: Gather firewall_interfaces facts - vyos_facts: - gather_subset: - - default - gather_network_resources: - - firewall_interfaces - - - name: Apply the provided configuration (config to be reverted) - vyos_firewall_interfaces: - config: - - name: 'eth2' - access_rules: - - afi: 'ipv4' - rules: - - name: 'INBOUND' - direction: 'in' - - name: 'OUTBOUND' - direction: 'out' - - name: 'LOCAL' - direction: 'local' - - afi: 'ipv6' - rules: - - name: 'V6-LOCAL' - direction: 'local' - state: merged - register: result - - - name: Assert that changes were applied - assert: - that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Revert back to base config using facts round trip - vyos_firewall_interfaces: - config: "{{ ansible_facts['network_resources']['firewall_interfaces'] }}" - state: overridden - register: revert - - - name: Assert that config was reverted - assert: - that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml - - - include_tasks: _remove_firewall_config.yaml diff --git a/test/integration/targets/vyos_firewall_interfaces/vars/main.yaml b/test/integration/targets/vyos_firewall_interfaces/vars/main.yaml deleted file mode 100644 index fa21a500fe..0000000000 --- a/test/integration/targets/vyos_firewall_interfaces/vars/main.yaml +++ /dev/null @@ -1,294 +0,0 @@ ---- -merged: - before: - - name: eth0 - - name: eth1 - - name: eth2 - - commands: - - "set interfaces ethernet eth1 firewall in name 'INBOUND'" - - "set interfaces ethernet eth1 firewall out name 'OUTBOUND'" - - "set interfaces ethernet eth1 firewall local name 'LOCAL'" - - "set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL'" - - "set interfaces ethernet eth2 firewall in name 'INBOUND'" - - "set interfaces ethernet eth2 firewall out name 'OUTBOUND'" - - "set interfaces ethernet eth2 firewall local name 'LOCAL'" - - "set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL'" - - after: - - name: eth0 - - access_rules: - - afi: ipv4 - rules: - - direction: in - name: INBOUND - - direction: local - name: LOCAL - - direction: out - name: OUTBOUND - - afi: ipv6 - rules: - - direction: local - name: V6-LOCAL - name: eth1 - - access_rules: - - afi: ipv4 - rules: - - direction: in - name: INBOUND - - direction: local - name: LOCAL - - direction: out - name: OUTBOUND - - afi: ipv6 - rules: - - direction: local - name: V6-LOCAL - name: eth2 - -populate: - - name: eth0 - - access_rules: - - afi: ipv4 - rules: - - direction: in - name: INBOUND - - direction: local - name: LOCAL - - direction: out - name: OUTBOUND - - afi: ipv6 - rules: - - direction: local - name: V6-LOCAL - name: eth1 - - access_rules: - - afi: ipv4 - rules: - - direction: in - name: INBOUND - - direction: local - name: LOCAL - - direction: out - name: OUTBOUND - - afi: ipv6 - rules: - - direction: local - name: V6-LOCAL - name: eth2 - -merged_edit: - commands: - - "set interfaces ethernet eth1 firewall in name 'OUTBOUND'" - - "set interfaces ethernet eth1 firewall out name 'INBOUND'" - - after: - - name: eth0 - - access_rules: - - afi: ipv4 - rules: - - direction: in - name: OUTBOUND - - direction: local - name: LOCAL - - direction: out - name: INBOUND - - afi: ipv6 - rules: - - direction: local - name: V6-LOCAL - name: eth1 - - access_rules: - - afi: ipv4 - rules: - - direction: in - name: INBOUND - - direction: local - name: LOCAL - - direction: out - name: OUTBOUND - - afi: ipv6 - rules: - - direction: local - name: V6-LOCAL - name: eth2 -replaced: - commands: - - "delete interfaces ethernet eth2 firewall out name" - - "delete interfaces ethernet eth2 firewall local name" - - "delete interfaces ethernet eth2 firewall local ipv6-name" - - "delete interfaces ethernet eth1 firewall local name" - - "delete interfaces ethernet eth1 firewall in name" - - after: - - name: eth0 - - access_rules: - - afi: ipv4 - rules: - - direction: out - name: OUTBOUND - - afi: ipv6 - rules: - - direction: local - name: V6-LOCAL - name: eth1 - - access_rules: - - afi: ipv4 - rules: - - direction: in - name: INBOUND - name: eth2 - -overridden: - before: - - access_rules: - - afi: ipv4 - rules: - - direction: in - name: INBOUND - - direction: local - name: LOCAL - - direction: out - name: OUTBOUND - - afi: ipv6 - rules: - - direction: local - name: V6-LOCAL - name: eth1 - - access_rules: - - afi: ipv4 - rules: - - name: INBOUND - direction: in - - name: LOCAL - direction: local - - name: OUTBOUND - direction: out - - afi: ipv6 - rules: - - name: V6-LOCAL - direction: local - name: eth2 - commands: - - "delete interfaces ethernet eth1 firewall" - - "delete interfaces ethernet eth2 firewall in name" - - "delete interfaces ethernet eth2 firewall local name" - - "delete interfaces ethernet eth2 firewall local ipv6-name" - - "set interfaces ethernet eth2 firewall out name 'INBOUND'" - - after: - - name: eth0 - - name: eth1 - - access_rules: - - afi: ipv4 - rules: - - name: INBOUND - direction: out - name: eth2 - -deleted: - commands: - - "delete interfaces ethernet eth1 firewall" - - "delete interfaces ethernet eth2 firewall" - - after: - - name: eth0 - - name: eth1 - - name: eth2 - -deleted_afi: - commands: - - "delete interfaces ethernet eth1 firewall in name" - - "delete interfaces ethernet eth1 firewall local name" - - "delete interfaces ethernet eth1 firewall out name" - - "delete interfaces ethernet eth1 firewall local ipv6-name" - - "delete interfaces ethernet eth2 firewall in name" - - "delete interfaces ethernet eth2 firewall local name" - - "delete interfaces ethernet eth2 firewall out name" - - "delete interfaces ethernet eth2 firewall local ipv6-name" - - after: - - name: eth0 - - access_rules: - - afi: ipv4 - - afi: ipv6 - name: eth1 - - access_rules: - - afi: ipv4 - - afi: ipv6 - name: eth2 - -deleted_single: - commands: - - "delete interfaces ethernet eth1 firewall in name 'INBOUND'" - after: - - name: eth0 - - access_rules: - - afi: ipv4 - rules: - - direction: local - name: LOCAL - - direction: out - name: OUTBOUND - - afi: ipv6 - rules: - - direction: local - name: V6-LOCAL - name: eth1 - - access_rules: - - afi: ipv4 - rules: - - direction: in - name: INBOUND - - direction: local - name: LOCAL - - direction: out - name: OUTBOUND - - afi: ipv6 - rules: - - direction: local - name: V6-LOCAL - name: eth2 - -rendered: - commands: - - "set interfaces ethernet eth1 firewall in name 'INBOUND'" - - "set interfaces ethernet eth1 firewall out name 'OUTBOUND'" - - "set interfaces ethernet eth1 firewall local name 'LOCAL'" - - "set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL'" - - "set interfaces ethernet eth2 firewall in name 'INBOUND'" - - "set interfaces ethernet eth2 firewall out name 'OUTBOUND'" - - "set interfaces ethernet eth2 firewall local name 'LOCAL'" - - "set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL'" - -round_trip: - after: - - name: eth0 - - access_rules: - - afi: ipv4 - rules: - - direction: in - name: INBOUND - - direction: local - name: LOCAL - - direction: out - name: OUTBOUND - - afi: ipv6 - rules: - - direction: local - name: V6-LOCAL - name: eth1 - - name: eth2 - access_rules: - - afi: ipv4 - rules: - - direction: in - name: INBOUND - - direction: local - name: LOCAL - - direction: out - name: OUTBOUND - - afi: ipv6 - rules: - - direction: local - name: V6-LOCAL diff --git a/test/integration/targets/vyos_firewall_rules/aliases b/test/integration/targets/vyos_firewall_rules/aliases deleted file mode 100644 index 8071e1f75b..0000000000 --- a/test/integration/targets/vyos_firewall_rules/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/vyos/group1 diff --git a/test/integration/targets/vyos_firewall_rules/defaults/main.yaml b/test/integration/targets/vyos_firewall_rules/defaults/main.yaml deleted file mode 100644 index 164afead28..0000000000 --- a/test/integration/targets/vyos_firewall_rules/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "[^_].*" -test_items: [] diff --git a/test/integration/targets/vyos_firewall_rules/meta/main.yaml b/test/integration/targets/vyos_firewall_rules/meta/main.yaml deleted file mode 100644 index 7413320e48..0000000000 --- a/test/integration/targets/vyos_firewall_rules/meta/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_vyos_tests diff --git a/test/integration/targets/vyos_firewall_rules/tasks/cli.yaml b/test/integration/targets/vyos_firewall_rules/tasks/cli.yaml deleted file mode 100644 index 655e51ee63..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tasks/cli.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- name: Collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - use_regex: true - 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 (connection=network_cli) - include: "{{ test_case_to_run }}" - vars: - ansible_connection: network_cli - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_firewall_rules/tasks/main.yaml b/test/integration/targets/vyos_firewall_rules/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_firewall_rules/tests/cli/_parsed_config.cfg b/test/integration/targets/vyos_firewall_rules/tests/cli/_parsed_config.cfg deleted file mode 100644 index b54c10948c..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tests/cli/_parsed_config.cfg +++ /dev/null @@ -1,25 +0,0 @@ -set firewall group address-group 'inbound' -set firewall ipv6-name UPLINK default-action 'accept' -set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' -set firewall ipv6-name UPLINK rule 1 action 'accept' -set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' -set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' -set firewall ipv6-name UPLINK rule 2 action 'accept' -set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' -set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' -set firewall name INBOUND default-action 'accept' -set firewall name INBOUND description 'IPv4 INBOUND rule set' -set firewall name INBOUND rule 101 action 'accept' -set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' -set firewall name INBOUND rule 101 ipsec 'match-ipsec' -set firewall name INBOUND rule 102 action 'reject' -set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible' -set firewall name INBOUND rule 102 ipsec 'match-ipsec' -set firewall name INBOUND rule 103 action 'accept' -set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible' -set firewall name INBOUND rule 103 destination group address-group 'inbound' -set firewall name INBOUND rule 103 source address '192.0.2.0' -set firewall name INBOUND rule 103 state established 'enable' -set firewall name INBOUND rule 103 state invalid 'disable' -set firewall name INBOUND rule 103 state new 'disable' -set firewall name INBOUND rule 103 state related 'enable' diff --git a/test/integration/targets/vyos_firewall_rules/tests/cli/_populate.yaml b/test/integration/targets/vyos_firewall_rules/tests/cli/_populate.yaml deleted file mode 100644 index ae6e17a188..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tests/cli/_populate.yaml +++ /dev/null @@ -1,31 +0,0 @@ ---- -- name: Setup - cli_config: - config: "{{ lines }}" - vars: - lines: | - set firewall group address-group 'inbound' - set firewall ipv6-name UPLINK default-action 'accept' - set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' - set firewall ipv6-name UPLINK rule 1 action 'accept' - set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' - set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' - set firewall ipv6-name UPLINK rule 2 action 'accept' - set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' - set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' - set firewall name INBOUND default-action 'accept' - set firewall name INBOUND description 'IPv4 INBOUND rule set' - set firewall name INBOUND rule 101 action 'accept' - set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' - set firewall name INBOUND rule 101 ipsec 'match-ipsec' - set firewall name INBOUND rule 102 action 'reject' - set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible' - set firewall name INBOUND rule 102 ipsec 'match-ipsec' - set firewall name INBOUND rule 103 action 'accept' - set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible' - set firewall name INBOUND rule 103 destination group address-group 'inbound' - set firewall name INBOUND rule 103 source address '192.0.2.0' - set firewall name INBOUND rule 103 state established 'enable' - set firewall name INBOUND rule 103 state invalid 'disable' - set firewall name INBOUND rule 103 state new 'disable' - set firewall name INBOUND rule 103 state related 'enable' diff --git a/test/integration/targets/vyos_firewall_rules/tests/cli/_remove_config.yaml b/test/integration/targets/vyos_firewall_rules/tests/cli/_remove_config.yaml deleted file mode 100644 index 9a9aff9103..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tests/cli/_remove_config.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- name: Remove Config - cli_config: - config: "{{ lines }}" - vars: - lines: | - delete firewall ipv6-name - delete firewall name diff --git a/test/integration/targets/vyos_firewall_rules/tests/cli/deleted.yaml b/test/integration/targets/vyos_firewall_rules/tests/cli/deleted.yaml deleted file mode 100644 index 881c19349b..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tests/cli/deleted.yaml +++ /dev/null @@ -1,50 +0,0 @@ ---- -- debug: - msg: "Start vyos_firewall_rules deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate.yaml - -- block: - - name: Delete firewall rule set. - vyos_firewall_rules: &deleted_rs - config: - - afi: 'ipv6' - rule_sets: - - name: 'UPLINK' - - afi: 'ipv4' - rule_sets: - - name: 'INBOUND' - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted_rs['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted_rs['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_firewall_rules: *deleted_rs - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - "result.commands|length == 0" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted_rs['after'] | symmetric_difference(result['before']) |length == 0 }}" - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_rules/tests/cli/deleted_afi.yaml b/test/integration/targets/vyos_firewall_rules/tests/cli/deleted_afi.yaml deleted file mode 100644 index 1502e86bf4..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tests/cli/deleted_afi.yaml +++ /dev/null @@ -1,46 +0,0 @@ ---- -- debug: - msg: "Start vyos_firewall_rules deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate.yaml - -- block: - - name: Delete firewall rule. - vyos_firewall_rules: &deleted_afi - config: - - afi: 'ipv6' - - afi: 'ipv4' - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_firewall_rules: *deleted_afi - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - "result.commands|length == 0" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['before']) |length == 0 }}" - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_rules/tests/cli/deleted_all.yaml b/test/integration/targets/vyos_firewall_rules/tests/cli/deleted_all.yaml deleted file mode 100644 index 60c7a67284..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tests/cli/deleted_all.yaml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- debug: - msg: "Start vyos_firewall_rules deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate.yaml - -- block: - - name: Delete all the firewall rules. - vyos_firewall_rules: &deleted_all - config: - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_firewall_rules: *deleted_all - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - "result.commands|length == 0" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['before']) |length == 0 }}" - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_rules/tests/cli/deleted_rule.yaml b/test/integration/targets/vyos_firewall_rules/tests/cli/deleted_rule.yaml deleted file mode 100644 index 7ecdcb380c..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tests/cli/deleted_rule.yaml +++ /dev/null @@ -1,49 +0,0 @@ ---- -- debug: - msg: "Start vyos_firewall_rules deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate.yaml - -- block: - - name: Delete firewall rule. - vyos_firewall_rules: &deleted_r - config: - - afi: 'ipv6' - rule_sets: - - name: 'UPLINK' - rules: - - number: 1 - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted_r['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted_r['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_firewall_rules: *deleted_r - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - "result.commands|length == 0" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted_r['after'] | symmetric_difference(result['before']) |length == 0 }}" - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_rules/tests/cli/empty_config.yaml b/test/integration/targets/vyos_firewall_rules/tests/cli/empty_config.yaml deleted file mode 100644 index 262b3059e5..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tests/cli/empty_config.yaml +++ /dev/null @@ -1,58 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_rules empty_config integration tests on connection={{ ansible_connection }}" - -- name: Merged with empty config should give appropriate error message - vyos_firewall_rules: - config: - state: merged - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state merged' - -- name: Replaced with empty config should give appropriate error message - vyos_firewall_rules: - config: - state: replaced - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state replaced' - -- name: Overridden with empty config should give appropriate error message - vyos_firewall_rules: - config: - state: overridden - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state overridden' - -- name: Parsed with empty running_config should give appropriate error message - vyos_firewall_rules: - running_config: - state: parsed - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of running_config parameter must not be empty for state parsed' - -- name: Rendered with empty config should give appropriate error message - vyos_firewall_rules: - config: - state: rendered - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/test/integration/targets/vyos_firewall_rules/tests/cli/gathered.yaml b/test/integration/targets/vyos_firewall_rules/tests/cli/gathered.yaml deleted file mode 100644 index 5a0bac753b..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tests/cli/gathered.yaml +++ /dev/null @@ -1,31 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_rules gathered integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Merge the provided configuration with the exisiting running configuration - vyos_firewall_rules: &gathered - config: - state: gathered - register: result - - - name: Assert that gathered dicts was correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['gathered']) |length == 0 }}" - - - name: Gather the existing running configuration (IDEMPOTENT) - vyos_firewall_rules: *gathered - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_rules/tests/cli/merged.yaml b/test/integration/targets/vyos_firewall_rules/tests/cli/merged.yaml deleted file mode 100644 index 596f4a143d..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tests/cli/merged.yaml +++ /dev/null @@ -1,87 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_rules merged integration tests on connection={{ ansible_connection }}" - -- include_tasks: _populate.yaml - -- include_tasks: _remove_config.yaml - -- block: - - name: Merge the provided configuration with the exisiting running configuration - vyos_firewall_rules: &merged - config: - - afi: 'ipv6' - rule_sets: - - name: 'UPLINK' - description: 'This is ipv6 specific rule-set' - default_action: 'accept' - rules: - - number: 1 - action: 'accept' - description: 'Fwipv6-Rule 1 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 2 - action: 'accept' - description: 'Fwipv6-Rule 2 is configured by Ansible' - ipsec: 'match-ipsec' - - - afi: 'ipv4' - rule_sets: - - name: 'INBOUND' - description: 'IPv4 INBOUND rule set' - default_action: 'accept' - rules: - - number: 101 - action: 'accept' - description: 'Rule 101 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 102 - action: 'reject' - description: 'Rule 102 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 103 - action: 'accept' - description: 'Rule 103 is configured by Ansible' - destination: - group: - address_group: 'inbound' - source: - address: '192.0.2.0' - state: - established: true - new: false - invalid: false - related: true - state: merged - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts was correctly generated - assert: - that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) - vyos_firewall_rules: *merged - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_rules/tests/cli/overridden.yaml b/test/integration/targets/vyos_firewall_rules/tests/cli/overridden.yaml deleted file mode 100644 index d902f4791e..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tests/cli/overridden.yaml +++ /dev/null @@ -1,60 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_rules overridden integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Overrides all device configuration with provided configuration - vyos_firewall_rules: &overridden - config: - - afi: 'ipv4' - rule_sets: - - name: 'Downlink' - description: 'IPv4 INBOUND rule set' - default_action: 'accept' - rules: - - number: 501 - action: 'accept' - description: 'Rule 501 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 502 - action: 'reject' - description: 'Rule 502 is configured by Ansible' - ipsec: 'match-ipsec' - state: overridden - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that correct commands were generated - assert: - that: - - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts were correctly generated - assert: - that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Overrides all device configuration with provided configurations (IDEMPOTENT) - vyos_firewall_rules: *overridden - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_rules/tests/cli/parsed.yaml b/test/integration/targets/vyos_firewall_rules/tests/cli/parsed.yaml deleted file mode 100644 index 7fb066da00..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tests/cli/parsed.yaml +++ /dev/null @@ -1,39 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_rules parsed integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Gather firewall_rules facts - vyos_facts: - gather_subset: - - default - gather_network_resources: - - firewall_rules - register: firewall_rules_facts - - - name: Provide the running configuration for parsing (config to be parsed) - vyos_firewall_rules: &parsed - running_config: - "{{ lookup('file', '_parsed_config.cfg') }}" - state: parsed - register: result - - - name: Assert that correct parsing done - assert: - that: "{{ ansible_facts['network_resources']['firewall_rules'] | symmetric_difference(result['parsed']) |length == 0 }}" - - - name: Gather the existing running configuration (IDEMPOTENT) - vyos_firewall_rules: *parsed - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_rules/tests/cli/rendered.yaml b/test/integration/targets/vyos_firewall_rules/tests/cli/rendered.yaml deleted file mode 100644 index 958550e211..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tests/cli/rendered.yaml +++ /dev/null @@ -1,63 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_rules rendered integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Structure provided configuration into device specific commands - vyos_firewall_rules: &rendered - config: - - afi: 'ipv6' - rule_sets: - - name: 'UPLINK' - description: 'This is ipv6 specific rule-set' - default_action: 'accept' - - afi: 'ipv4' - rule_sets: - - name: 'INBOUND' - description: 'IPv4 INBOUND rule set' - default_action: 'accept' - rules: - - number: 101 - action: 'accept' - description: 'Rule 101 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 102 - action: 'reject' - description: 'Rule 102 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 103 - action: 'accept' - description: 'Rule 103 is configured by Ansible' - destination: - group: - address_group: 'inbound' - source: - address: '192.0.2.0' - state: - established: true - new: false - invalid: false - related: true - state: rendered - register: result - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" - - - name: Structure provided configuration into device specific commands (IDEMPOTENT) - vyos_firewall_rules: *rendered - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_rules/tests/cli/replaced.yaml b/test/integration/targets/vyos_firewall_rules/tests/cli/replaced.yaml deleted file mode 100644 index 164ff18707..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tests/cli/replaced.yaml +++ /dev/null @@ -1,65 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_rules replaced integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Replace device configurations of listed firewall rules with provided configurations - vyos_firewall_rules: &replaced - config: - - afi: 'ipv6' - rule_sets: - - name: 'UPLINK' - description: 'This is ipv6 specific rule-set' - default_action: 'accept' - - afi: 'ipv4' - rule_sets: - - name: 'INBOUND' - description: 'IPv4 INBOUND rule set' - default_action: 'accept' - rules: - - number: 101 - action: 'accept' - description: 'Rule 101 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 104 - action: 'reject' - description: 'Rule 104 is configured by Ansible' - ipsec: 'match-none' - state: replaced - register: result - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that before dicts are correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that after dict is correctly generated - assert: - that: - - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Replace device configurations of listed firewall rules with provided configurarions (IDEMPOTENT) - vyos_firewall_rules: *replaced - register: result - - - name: Assert that task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dict is correctly generated - assert: - that: - - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_rules/tests/cli/rtt.yaml b/test/integration/targets/vyos_firewall_rules/tests/cli/rtt.yaml deleted file mode 100644 index 921defb9d6..0000000000 --- a/test/integration/targets/vyos_firewall_rules/tests/cli/rtt.yaml +++ /dev/null @@ -1,87 +0,0 @@ ---- -- debug: - msg: "START vyos_firewall_rules round trip integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- block: - - name: Apply the provided configuration (base config) - vyos_firewall_rules: - config: - - afi: 'ipv6' - rule_sets: - - name: 'UPLINK' - description: 'This is ipv6 specific rule-set' - default_action: 'accept' - rules: - - number: 1 - action: 'accept' - description: 'Fwipv6-Rule 1 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 2 - action: 'accept' - description: 'Fwipv6-Rule 2 is configured by Ansible' - ipsec: 'match-ipsec' - - - afi: 'ipv4' - rule_sets: - - name: 'INBOUND' - description: 'IPv4 INBOUND rule set' - default_action: 'accept' - rules: - - number: 101 - action: 'accept' - description: 'Rule 101 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 102 - action: 'reject' - description: 'Rule 102 is configured by Ansible' - ipsec: 'match-ipsec' - state: merged - register: base_config - - - name: Gather firewall_rules facts - vyos_facts: - gather_subset: - - default - gather_network_resources: - - firewall_rules - - - name: Apply the provided configuration (config to be reverted) - vyos_firewall_rules: - config: - - afi: 'ipv4' - rule_sets: - - name: 'INBOUND' - description: 'IPv4 INBOUND rule set' - default_action: 'accept' - rules: - - number: 103 - action: 'accept' - description: 'Rule 103 is configured by Ansible' - source: - address: '192.0.2.0' - state: - established: true - new: false - invalid: false - related: true - state: merged - register: result - - - name: Assert that changes were applied - assert: - that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Revert back to base config using facts round trip - vyos_firewall_rules: - config: "{{ ansible_facts['network_resources']['firewall_rules'] }}" - state: overridden - register: revert - - - name: Assert that config was reverted - assert: - that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_firewall_rules/vars/main.yaml b/test/integration/targets/vyos_firewall_rules/vars/main.yaml deleted file mode 100644 index 64032cd307..0000000000 --- a/test/integration/targets/vyos_firewall_rules/vars/main.yaml +++ /dev/null @@ -1,327 +0,0 @@ ---- -merged: - before: [] - - - commands: - - "set firewall ipv6-name UPLINK default-action 'accept'" - - "set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set'" - - "set firewall ipv6-name UPLINK rule 1 action 'accept'" - - "set firewall ipv6-name UPLINK rule 1" - - "set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible'" - - "set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec'" - - "set firewall ipv6-name UPLINK rule 2 action 'accept'" - - "set firewall ipv6-name UPLINK rule 2" - - "set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible'" - - "set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec'" - - "set firewall name INBOUND default-action 'accept'" - - "set firewall name INBOUND description 'IPv4 INBOUND rule set'" - - "set firewall name INBOUND rule 101 action 'accept'" - - "set firewall name INBOUND rule 101" - - "set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible'" - - "set firewall name INBOUND rule 101 ipsec 'match-ipsec'" - - "set firewall name INBOUND rule 102 action 'reject'" - - "set firewall name INBOUND rule 102" - - "set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible'" - - "set firewall name INBOUND rule 102 ipsec 'match-ipsec'" - - "set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible'" - - "set firewall name INBOUND rule 103 destination group address-group inbound" - - "set firewall name INBOUND rule 103" - - "set firewall name INBOUND rule 103 source address 192.0.2.0" - - "set firewall name INBOUND rule 103 state established enable" - - "set firewall name INBOUND rule 103 state related enable" - - "set firewall name INBOUND rule 103 state invalid disable" - - "set firewall name INBOUND rule 103 state new disable" - - "set firewall name INBOUND rule 103 action 'accept'" - - after: - - afi: 'ipv6' - rule_sets: - - name: 'UPLINK' - description: 'This is ipv6 specific rule-set' - default_action: 'accept' - rules: - - number: 1 - action: 'accept' - description: 'Fwipv6-Rule 1 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 2 - action: 'accept' - description: 'Fwipv6-Rule 2 is configured by Ansible' - ipsec: 'match-ipsec' - - - afi: 'ipv4' - rule_sets: - - name: 'INBOUND' - description: 'IPv4 INBOUND rule set' - default_action: 'accept' - rules: - - number: 101 - action: 'accept' - description: 'Rule 101 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 102 - action: 'reject' - description: 'Rule 102 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 103 - action: 'accept' - description: 'Rule 103 is configured by Ansible' - destination: - group: - address_group: 'inbound' - source: - address: '192.0.2.0' - state: - established: true - new: false - invalid: false - related: true - -populate: - - afi: 'ipv6' - rule_sets: - - name: 'UPLINK' - description: 'This is ipv6 specific rule-set' - default_action: 'accept' - rules: - - number: 1 - action: 'accept' - description: 'Fwipv6-Rule 1 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 2 - action: 'accept' - description: 'Fwipv6-Rule 2 is configured by Ansible' - ipsec: 'match-ipsec' - - - afi: 'ipv4' - rule_sets: - - name: 'INBOUND' - description: 'IPv4 INBOUND rule set' - default_action: 'accept' - rules: - - number: 101 - action: 'accept' - description: 'Rule 101 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 102 - action: 'reject' - description: 'Rule 102 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 103 - action: 'accept' - description: 'Rule 103 is configured by Ansible' - destination: - group: - address_group: 'inbound' - source: - address: '192.0.2.0' - state: - established: true - new: false - invalid: false - related: true - -replaced: - commands: - - "delete firewall ipv6-name UPLINK rule 1" - - "delete firewall ipv6-name UPLINK rule 2" - - "delete firewall name INBOUND rule 102" - - "delete firewall name INBOUND rule 103" - - "set firewall name INBOUND rule 104 action 'reject'" - - "set firewall name INBOUND rule 104 description 'Rule 104 is configured by Ansible'" - - "set firewall name INBOUND rule 104" - - "set firewall name INBOUND rule 104 ipsec 'match-none'" - - after: - - afi: 'ipv6' - rule_sets: - - name: 'UPLINK' - description: 'This is ipv6 specific rule-set' - default_action: 'accept' - - afi: 'ipv4' - rule_sets: - - name: 'INBOUND' - description: 'IPv4 INBOUND rule set' - default_action: 'accept' - rules: - - number: 101 - action: 'accept' - description: 'Rule 101 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 104 - action: 'reject' - description: 'Rule 104 is configured by Ansible' - ipsec: 'match-none' -overridden: - before: - - afi: 'ipv6' - rule_sets: - - name: 'UPLINK' - description: 'This is ipv6 specific rule-set' - default_action: 'accept' - - afi: 'ipv4' - rule_sets: - - name: 'INBOUND' - description: 'IPv4 INBOUND rule set' - default_action: 'accept' - rules: - - number: 101 - action: 'accept' - description: 'Rule 101 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 104 - action: 'reject' - description: 'Rule 104 is configured by Ansible' - ipsec: 'match-none' - commands: - - "delete firewall ipv6-name UPLINK" - - "delete firewall name INBOUND" - - "set firewall name Downlink default-action 'accept'" - - "set firewall name Downlink description 'IPv4 INBOUND rule set'" - - "set firewall name Downlink rule 501 action 'accept'" - - "set firewall name Downlink rule 501" - - "set firewall name Downlink rule 501 description 'Rule 501 is configured by Ansible'" - - "set firewall name Downlink rule 501 ipsec 'match-ipsec'" - - "set firewall name Downlink rule 502 action 'reject'" - - "set firewall name Downlink rule 502" - - "set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible'" - - "set firewall name Downlink rule 502 ipsec 'match-ipsec'" - - after: - - afi: 'ipv4' - rule_sets: - - name: 'Downlink' - description: 'IPv4 INBOUND rule set' - default_action: 'accept' - rules: - - number: 501 - action: 'accept' - description: 'Rule 501 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 502 - action: 'reject' - description: 'Rule 502 is configured by Ansible' - ipsec: 'match-ipsec' -rendered: - commands: - - "set firewall ipv6-name UPLINK default-action 'accept'" - - "set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set'" - - "set firewall name INBOUND default-action 'accept'" - - "set firewall name INBOUND description 'IPv4 INBOUND rule set'" - - "set firewall name INBOUND rule 101 action 'accept'" - - "set firewall name INBOUND rule 101" - - "set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible'" - - "set firewall name INBOUND rule 101 ipsec 'match-ipsec'" - - "set firewall name INBOUND rule 102 action 'reject'" - - "set firewall name INBOUND rule 102" - - "set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible'" - - "set firewall name INBOUND rule 102 ipsec 'match-ipsec'" - - "set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible'" - - "set firewall name INBOUND rule 103 destination group address-group inbound" - - "set firewall name INBOUND rule 103" - - "set firewall name INBOUND rule 103 source address 192.0.2.0" - - "set firewall name INBOUND rule 103 state established enable" - - "set firewall name INBOUND rule 103 state related enable" - - "set firewall name INBOUND rule 103 state invalid disable" - - "set firewall name INBOUND rule 103 state new disable" - - "set firewall name INBOUND rule 103 action 'accept'" - -deleted_rs: - commands: - - "delete firewall ipv6-name UPLINK" - - "delete firewall name INBOUND" - - after: [] - -deleted_afi_all: - commands: - - "delete firewall ipv6-name" - - "delete firewall name" - - after: [] - -deleted_r: - commands: - - "delete firewall ipv6-name UPLINK rule 1" - - after: - - afi: 'ipv6' - rule_sets: - - name: 'UPLINK' - description: 'This is ipv6 specific rule-set' - default_action: 'accept' - rules: - - number: 2 - action: 'accept' - description: 'Fwipv6-Rule 2 is configured by Ansible' - ipsec: 'match-ipsec' - - - afi: 'ipv4' - rule_sets: - - name: 'INBOUND' - description: 'IPv4 INBOUND rule set' - default_action: 'accept' - rules: - - number: 101 - action: 'accept' - description: 'Rule 101 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 102 - action: 'reject' - description: 'Rule 102 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 103 - action: 'accept' - description: 'Rule 103 is configured by Ansible' - destination: - group: - address_group: 'inbound' - source: - address: '192.0.2.0' - state: - established: true - new: false - invalid: false - related: true - -round_trip: - after: - - afi: 'ipv6' - rule_sets: - - name: 'UPLINK' - description: 'This is ipv6 specific rule-set' - default_action: 'accept' - rules: - - number: 1 - action: 'accept' - description: 'Fwipv6-Rule 1 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 2 - action: 'accept' - description: 'Fwipv6-Rule 2 is configured by Ansible' - ipsec: 'match-ipsec' - - afi: 'ipv4' - rule_sets: - - name: 'INBOUND' - description: 'IPv4 INBOUND rule set' - default_action: 'accept' - rules: - - number: 101 - action: 'accept' - description: 'Rule 101 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 102 - action: 'reject' - description: 'Rule 102 is configured by Ansible' - ipsec: 'match-ipsec' - - number: 103 - action: 'accept' - description: 'Rule 103 is configured by Ansible' - source: - address: '192.0.2.0' - state: - established: true - new: false - invalid: false - related: true diff --git a/test/integration/targets/vyos_interface/defaults/main.yaml b/test/integration/targets/vyos_interface/defaults/main.yaml deleted file mode 100644 index 9ef5ba5165..0000000000 --- a/test/integration/targets/vyos_interface/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_interface/tasks/cli.yaml b/test/integration/targets/vyos_interface/tasks/cli.yaml deleted file mode 100644 index 890d3acf3e..0000000000 --- a/test/integration/targets/vyos_interface/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_interface/tasks/main.yaml b/test/integration/targets/vyos_interface/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_interface/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_interface/tests/cli/basic.yaml b/test/integration/targets/vyos_interface/tests/cli/basic.yaml deleted file mode 100644 index 9e1f9dc68a..0000000000 --- a/test/integration/targets/vyos_interface/tests/cli/basic.yaml +++ /dev/null @@ -1,220 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: Run vyos lsmod command - vyos_command: - commands: - - lsmod - register: lsmod_out - -- name: Set up - delete interface - vyos_interface: - name: eth1 - state: absent - -- name: Set up - Create interface - vyos_interface: - name: eth1 - state: present - description: test-interface - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1" in result.commands' - - '"set interfaces ethernet eth1 description ''test-interface''" in result.commands' - -- name: Configure interface params - vyos_interface: - name: eth1 - state: present - description: test-interface-1 - speed: 100 - duplex: half - mtu: 256 - when: "'virtio_net' not in lsmod_out.stdout[0]" - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 description ''test-interface-1''" in result.commands' - - '"set interfaces ethernet eth1 speed 100" in result.commands' - - '"set interfaces ethernet eth1 duplex half" in result.commands' - - '"set interfaces ethernet eth1 mtu 256" in result.commands' - when: "'virtio_net' not in lsmod_out.stdout[0]" - -- name: Configure interface params (idempotent) - vyos_interface: - name: eth1 - state: present - description: test-interface-1 - speed: 100 - duplex: half - mtu: 256 - register: result - when: "'virtio_net' not in lsmod_out.stdout[0]" - -- assert: - that: - - 'result.changed == false' - when: "'virtio' not in lsmod_out.stdout[0]" - -- name: Change interface params - vyos_interface: - name: eth1 - state: present - description: test-interface-2 - speed: 1000 - duplex: full - mtu: 512 - register: result - when: "'virtio_net' not in lsmod_out.stdout[0]" - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 description ''test-interface-2''" in result.commands' - - '"set interfaces ethernet eth1 speed 1000" in result.commands' - - '"set interfaces ethernet eth1 duplex full" in result.commands' - - '"set interfaces ethernet eth1 mtu 512" in result.commands' - when: "'virtio_net' not in lsmod_out.stdout[0]" - -- name: Disable interface - vyos_interface: - name: eth1 - enabled: false - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 disable" in result.commands' - -- name: Enable interface - vyos_interface: - name: eth1 - enabled: true - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1 disable" in result.commands' - -- name: Delete interface - vyos_interface: - name: eth1 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1" in result.commands' - -- name: Delete interface (idempotent) - vyos_interface: - name: eth1 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Aggregate setup- delete interface - vyos_interface: - name: eth2 - state: absent - register: result - -- name: Set interface on aggregate - vyos_interface: - aggregate: - - {name: eth1, description: test-interface-1, speed: 100, duplex: half, mtu: 512} - - {name: eth2, description: test-interface-2, speed: 1000, duplex: full, mtu: 256} - register: result - when: "'virtio_net' not in lsmod_out.stdout[0]" - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 description ''test-interface-1''" in result.commands' - - '"set interfaces ethernet eth1 speed 100" in result.commands' - - '"set interfaces ethernet eth1 duplex half" in result.commands' - - '"set interfaces ethernet eth1 mtu 512" in result.commands' - - '"set interfaces ethernet eth2 description ''test-interface-2''" in result.commands' - - '"set interfaces ethernet eth2 speed 1000" in result.commands' - - '"set interfaces ethernet eth2 duplex full" in result.commands' - - '"set interfaces ethernet eth2 mtu 256" in result.commands' - when: "'virtio_net' not in lsmod_out.stdout[0]" - -- name: Set interface on aggregate (idempotent) - vyos_interface: - aggregate: - - {name: eth1, description: test-interface-1, speed: 100, duplex: half, mtu: 512} - - {name: eth2, description: test-interface-2, speed: 1000, duplex: full, mtu: 256} - register: result - when: "'virtio_net' not in lsmod_out.stdout[0]" - -- assert: - that: - - 'result.changed == false' - when: "'virtio_net' not in lsmod_out.stdout[0]" - -- name: Disable interface on aggregate - vyos_interface: - aggregate: - - name: eth1 - - name: eth2 - description: test-interface - enabled: false - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 disable" in result.commands' - - '"set interfaces ethernet eth2 disable" in result.commands' - -- name: Enable interface on aggregate - vyos_interface: - aggregate: - - name: eth1 - - name: eth2 - enabled: true - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1 disable" in result.commands' - - '"delete interfaces ethernet eth2 disable" in result.commands' - -- name: Delete interface aggregate - vyos_interface: - aggregate: - - name: eth1 - - name: eth2 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1" in result.commands' - - '"delete interfaces ethernet eth2" in result.commands' - -- name: Delete interface aggregate (idempotent) - vyos_interface: - aggregate: - - name: eth1 - - name: eth2 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' diff --git a/test/integration/targets/vyos_interface/tests/cli/intent.yaml b/test/integration/targets/vyos_interface/tests/cli/intent.yaml deleted file mode 100644 index f355255931..0000000000 --- a/test/integration/targets/vyos_interface/tests/cli/intent.yaml +++ /dev/null @@ -1,157 +0,0 @@ ---- -- debug: msg="START cli/intent.yaml on connection={{ ansible_connection }}" - -# To be able to run the lldp test we need to have a neighbor configured to talk to -# In DCI & Zuul we (currently) only spin up a single network VM, so we can't configure a neighbor -# In the future when we have multi-network-nodes running we can run these tests again -# https://github.com/ansible/ansible/issues/39667 - -- name: Detect if we have existing lldp neighbors configured - vyos_command: - commands: - - show lldp neighbors detail - register: neighbors_out - -- name: Should we run lldp tests? - set_fact: - run_lldp_tests: "'PortDescr: eth0' in neighbors_out.stdout[0]" - -- name: Enable LLDP service - vyos_lldp: - state: present - when: run_lldp_tests - -- name: Create LLDP configuration - vyos_lldp_interface: - name: eth1 - state: present - when: run_lldp_tests - -- name: Setup (interface is up) - vyos_interface: - name: eth1 - enabled: true - state: present - register: result - -- name: Check intent arguments - vyos_interface: - name: eth1 - state: up - register: result - -- assert: - that: - - "result.failed == false" - -- name: Check lldp neighbors intent arguments - vyos_interface: - name: eth0 - neighbors: - - port: eth0 - when: run_lldp_tests - register: result - -- assert: - that: - - "result.failed == false" - when: run_lldp_tests - -- name: Check intent arguments (failed condition) - vyos_interface: - name: eth1 - state: down - ignore_errors: true - register: result - -- assert: - that: - - "result.failed == true" - - "'state eq(down)' in result.failed_conditions" - -- name: Check lldp neighbors intent arguments (failed) - vyos_interface: - name: eth0 - neighbors: - - port: dummy_port - host: dummy_host - ignore_errors: true - when: run_lldp_tests - register: result - -- assert: - that: - - "result.failed == true" - - "'host dummy_host' in result.failed_conditions" - - "'port dummy_port' in result.failed_conditions" - when: run_lldp_tests - -- name: Config + intent - vyos_interface: - name: eth1 - enabled: false - state: down - register: result - -- assert: - that: - - "result.failed == false" - -- name: Config + intent (fail) - vyos_interface: - name: eth1 - enabled: false - state: up - ignore_errors: true - register: result - -- assert: - that: - - "result.failed == true" - - "'state eq(up)' in result.failed_conditions" - -- name: Aggregate config + intent (pass) - vyos_interface: - aggregate: - - name: eth1 - enabled: true - state: up - ignore_errors: true - register: result - -- assert: - that: - - "result.failed == false" - -- name: Check lldp neighbors intent aggregate arguments - vyos_interface: - aggregate: - - name: eth0 - neighbors: - - port: eth0 - when: run_lldp_tests - register: result - -- assert: - that: - - "result.failed == false" - when: run_lldp_tests - -- name: Check lldp neighbors intent aggregate arguments (failed) - vyos_interface: - aggregate: - - name: eth0 - neighbors: - - port: eth0 - - port: dummy_port - host: dummy_host - ignore_errors: true - when: run_lldp_tests - register: result - -- assert: - that: - - "result.failed == true" - - "'host dummy_host' in result.failed_conditions" - - "'port dummy_port' in result.failed_conditions" - when: run_lldp_tests diff --git a/test/integration/targets/vyos_interface/tests/cli/net_interface.yaml b/test/integration/targets/vyos_interface/tests/cli/net_interface.yaml deleted file mode 100644 index ced273d5f5..0000000000 --- a/test/integration/targets/vyos_interface/tests/cli/net_interface.yaml +++ /dev/null @@ -1,56 +0,0 @@ ---- -- debug: msg="START vyos cli/net_interface.yaml on connection={{ ansible_connection }}" - -# Add minimal testcase to check args are passed correctly to -# implementation module and module run is successful. - -- name: Run vyos lsmod command - vyos_command: - commands: - - lsmod - register: lsmod_out - -- name: Set up - delete interface - net_interface: - name: eth1 - state: absent - -- name: Create interface using platform agnostic module - net_interface: - name: eth1 - state: present - description: test-interface - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1" in result.commands' - - '"set interfaces ethernet eth1 description ''test-interface''" in result.commands' - -- name: Configure interface params using platform agnostic module - net_interface: - name: eth1 - state: present - description: test-interface-1 - speed: 100 - duplex: half - mtu: 256 - when: "'virtio_net' not in lsmod_out.stdout[0]" - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 description ''test-interface-1''" in result.commands' - - '"set interfaces ethernet eth1 speed 100" in result.commands' - - '"set interfaces ethernet eth1 duplex half" in result.commands' - - '"set interfaces ethernet eth1 mtu 256" in result.commands' - when: "'virtio_net' not in lsmod_out.stdout[0]" - -- name: teardown - delete interface - net_interface: - name: eth1 - state: absent - -- debug: msg="END vyos cli/net_interface.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_interfaces/defaults/main.yaml b/test/integration/targets/vyos_interfaces/defaults/main.yaml deleted file mode 100644 index 164afead28..0000000000 --- a/test/integration/targets/vyos_interfaces/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "[^_].*" -test_items: [] diff --git a/test/integration/targets/vyos_interfaces/meta/main.yaml b/test/integration/targets/vyos_interfaces/meta/main.yaml deleted file mode 100644 index 7413320e48..0000000000 --- a/test/integration/targets/vyos_interfaces/meta/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_vyos_tests diff --git a/test/integration/targets/vyos_interfaces/tasks/cli.yaml b/test/integration/targets/vyos_interfaces/tasks/cli.yaml deleted file mode 100644 index 655e51ee63..0000000000 --- a/test/integration/targets/vyos_interfaces/tasks/cli.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- name: Collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - use_regex: true - 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 (connection=network_cli) - include: "{{ test_case_to_run }}" - vars: - ansible_connection: network_cli - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_interfaces/tasks/main.yaml b/test/integration/targets/vyos_interfaces/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_interfaces/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_interfaces/tests/cli/_populate.yaml b/test/integration/targets/vyos_interfaces/tests/cli/_populate.yaml deleted file mode 100644 index 7dcab364a7..0000000000 --- a/test/integration/targets/vyos_interfaces/tests/cli/_populate.yaml +++ /dev/null @@ -1,17 +0,0 @@ ---- -- name: Setup - cli_config: - config: "{{ lines }}" - vars: - lines: | - set interfaces ethernet "{{ intf }}" description 'Configured by Ansible' - set interfaces ethernet "{{ intf }}" speed 'auto' - set interfaces ethernet "{{ intf }}" duplex 'auto' - set interfaces ethernet "{{ intf }}" mtu '1500' - set interfaces ethernet "{{ intf }}" vif 200 - set interfaces ethernet "{{ intf }}" vif 200 description 'VIF - 200' - loop: - - eth1 - - eth2 - loop_control: - loop_var: intf diff --git a/test/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml b/test/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml deleted file mode 100644 index c9329c0df5..0000000000 --- a/test/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml +++ /dev/null @@ -1,17 +0,0 @@ ---- -- name: Remove Config - cli_config: - config: "{{ lines }}" - vars: - lines: | - delete interfaces ethernet "{{ intf }}" description - delete interfaces ethernet "{{ intf }}" speed - delete interfaces ethernet "{{ intf }}" duplex - delete interfaces ethernet "{{ intf }}" mtu - delete interfaces ethernet "{{ intf }}" disable - delete interfaces ethernet "{{ intf }}" vif - loop: - - eth1 - - eth2 - loop_control: - loop_var: intf diff --git a/test/integration/targets/vyos_interfaces/tests/cli/deleted.yaml b/test/integration/targets/vyos_interfaces/tests/cli/deleted.yaml deleted file mode 100644 index 69e8705476..0000000000 --- a/test/integration/targets/vyos_interfaces/tests/cli/deleted.yaml +++ /dev/null @@ -1,46 +0,0 @@ ---- -- debug: - msg: "Start vyos_interfaces deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate.yaml - -- block: - - name: Delete attributes of given interfaces - vyos_interfaces: &deleted - config: - - name: eth1 - - name: eth2 - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_interfaces: *deleted - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml b/test/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml deleted file mode 100644 index ae9b5acf23..0000000000 --- a/test/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml +++ /dev/null @@ -1,36 +0,0 @@ ---- -- debug: - msg: "START vyos_interfaces empty_config integration tests on connection={{ ansible_connection }}" - -- name: Merged with empty config should give appropriate error message - vyos_interfaces: - config: - state: merged - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state merged' - -- name: Replaced with empty config should give appropriate error message - vyos_interfaces: - config: - state: replaced - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state replaced' - -- name: Overridden with empty config should give appropriate error message - vyos_interfaces: - config: - state: overridden - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state overridden' diff --git a/test/integration/targets/vyos_interfaces/tests/cli/merged.yaml b/test/integration/targets/vyos_interfaces/tests/cli/merged.yaml deleted file mode 100644 index 5b2dd81a0c..0000000000 --- a/test/integration/targets/vyos_interfaces/tests/cli/merged.yaml +++ /dev/null @@ -1,59 +0,0 @@ ---- -- debug: - msg: "START vyos_interfaces merged integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- block: - - name: Merge the provided configuration with the exisiting running configuration - vyos_interfaces: &merged - config: - - name: eth1 - description: "Configured by Ansible - Interface 1" - mtu: 1500 - speed: auto - duplex: auto - vifs: - - vlan_id: 100 - description: "Eth1 - VIF 100" - mtu: 400 - - - vlan_id: 101 - description: "Eth1 - VIF 101" - - - name: eth2 - description: "Configured by Ansible - Interface 2 (ADMIN DOWN)" - mtu: 600 - enabled: false - state: merged - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts was correctly generated - assert: - that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) - vyos_interfaces: *merged - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_interfaces/tests/cli/overridden.yaml b/test/integration/targets/vyos_interfaces/tests/cli/overridden.yaml deleted file mode 100644 index e79ff8ed57..0000000000 --- a/test/integration/targets/vyos_interfaces/tests/cli/overridden.yaml +++ /dev/null @@ -1,52 +0,0 @@ ---- -- debug: - msg: "START vyos_interfaces overridden integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Overrides all device configuration with provided configuration - vyos_interfaces: &overridden - config: - - name: eth0 - speed: "auto" - duplex: "auto" - - name: eth2 - description: "Overridden by Ansible" - mtu: 1200 - state: overridden - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that correct commands were generated - assert: - that: - - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts were correctly generated - assert: - that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Overrides all device configuration with provided configurations (IDEMPOTENT) - vyos_interfaces: *overridden - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_interfaces/tests/cli/replaced.yaml b/test/integration/targets/vyos_interfaces/tests/cli/replaced.yaml deleted file mode 100644 index d38e6b6b8d..0000000000 --- a/test/integration/targets/vyos_interfaces/tests/cli/replaced.yaml +++ /dev/null @@ -1,55 +0,0 @@ ---- -- debug: - msg: "START vyos_interfaces replaced integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Replace device configurations of listed interfaces with provided configurations - vyos_interfaces: &replaced - config: - - name: eth1 - description: "Replaced by Ansible" - vifs: - - vlan_id: 100 - description: "VIF 100 - Replaced by Ansible" - - - name: eth2 - mtu: 1400 - description: "Replaced by Ansible" - state: replaced - register: result - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that before dicts are correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that after dict is correctly generated - assert: - that: - - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Replace device configurations of listed interfaces with provided configurarions (IDEMPOTENT) - vyos_interfaces: *replaced - register: result - - - name: Assert that task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dict is correctly generated - assert: - that: - - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_interfaces/tests/cli/rtt.yaml b/test/integration/targets/vyos_interfaces/tests/cli/rtt.yaml deleted file mode 100644 index 2b5ee9de8d..0000000000 --- a/test/integration/targets/vyos_interfaces/tests/cli/rtt.yaml +++ /dev/null @@ -1,78 +0,0 @@ ---- -- debug: - msg: "START vyos_interfaces round trip integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- block: - - name: Apply the provided configuration (base config) - vyos_interfaces: - config: - - name: eth0 - enabled: true - duplex: "auto" - speed: "auto" - - - name: eth1 - description: "Interface - 1" - mtu: 1500 - vifs: - - vlan_id: 100 - description: "Eth1 - VIF 100" - mtu: 200 - - - vlan_id: 101 - enabled: false - - - name: eth2 - description: "Interface - 2" - enabled: true - mtu: 900 - state: merged - register: base_config - - - name: Gather interfaces facts - vyos_facts: - gather_subset: - - default - gather_network_resources: - - interfaces - - - name: Apply the provided configuration (config to be reverted) - vyos_interfaces: - config: - - name: eth1 - description: "Interface 1 - Description (WILL BE REVERTED)" - mtu: 1200 - vifs: - - vlan_id: 100 - description: "Eth1 - VIF 100 (WILL BE REVERTED)" - mtu: 400 - - - vlan_id: 101 - description: "Eth1 - VIF 101 (WILL BE REMOVED)" - enabled: true - - - name: eth2 - description: "Interface 2 (ADMIN DOWN) (WILL BE REVERTED)" - mtu: 600 - enabled: false - state: merged - register: result - - - name: Assert that changes were applied - assert: - that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Revert back to base config using facts round trip - vyos_interfaces: - config: "{{ ansible_facts['network_resources']['interfaces'] }}" - state: replaced - register: revert - - - name: Assert that config was reverted - assert: - that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_interfaces/vars/main.yaml b/test/integration/targets/vyos_interfaces/vars/main.yaml deleted file mode 100644 index b973752289..0000000000 --- a/test/integration/targets/vyos_interfaces/vars/main.yaml +++ /dev/null @@ -1,209 +0,0 @@ ---- -merged: - before: - - name: "eth0" - enabled: true - speed: "auto" - duplex: "auto" - - - name: "eth1" - enabled: true - - - name: "eth2" - enabled: true - - commands: - - "set interfaces ethernet eth1 description 'Configured by Ansible - Interface 1'" - - "set interfaces ethernet eth1 mtu '1500'" - - "set interfaces ethernet eth1 duplex 'auto'" - - "set interfaces ethernet eth1 speed 'auto'" - - "set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100'" - - "set interfaces ethernet eth1 vif 100 mtu '400'" - - "set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101'" - - "set interfaces ethernet eth2 description 'Configured by Ansible - Interface 2 (ADMIN DOWN)'" - - "set interfaces ethernet eth2 mtu '600'" - - "set interfaces ethernet eth2 disable" - - after: - - name: "eth0" - enabled: true - duplex: "auto" - speed: "auto" - - - name: "eth1" - description: "Configured by Ansible - Interface 1" - mtu: 1500 - speed: "auto" - duplex: "auto" - enabled: true - vifs: - - vlan_id: 100 - description: "Eth1 - VIF 100" - mtu: 400 - enabled: true - - - vlan_id: 101 - description: "Eth1 - VIF 101" - enabled: true - - - name: "eth2" - description: "Configured by Ansible - Interface 2 (ADMIN DOWN)" - mtu: 600 - enabled: false - -populate: - - name: "eth1" - enabled: true - speed: "auto" - duplex: "auto" - description: "Configured by Ansible" - mtu: 1500 - vifs: - - vlan_id: 200 - enabled: true - description: "VIF - 200" - - - name: "eth2" - enabled: true - speed: "auto" - duplex: "auto" - description: "Configured by Ansible" - mtu: 1500 - vifs: - - vlan_id: 200 - enabled: true - description: "VIF - 200" - - - name: "eth0" - enabled: true - duplex: "auto" - speed: "auto" - -replaced: - commands: - - "delete interfaces ethernet eth1 mtu" - - "delete interfaces ethernet eth1 speed" - - "delete interfaces ethernet eth1 duplex" - - "delete interfaces ethernet eth1 vif 200 description" - - "set interfaces ethernet eth1 description 'Replaced by Ansible'" - - "set interfaces ethernet eth1 vif 100 description 'VIF 100 - Replaced by Ansible'" - - "delete interfaces ethernet eth2 speed" - - "delete interfaces ethernet eth2 duplex" - - "delete interfaces ethernet eth2 vif 200 description" - - "set interfaces ethernet eth2 description 'Replaced by Ansible'" - - "set interfaces ethernet eth2 mtu '1400'" - - after: - - name: "eth1" - description: "Replaced by Ansible" - enabled: true - vifs: - - vlan_id: 100 - enabled: true - description: "VIF 100 - Replaced by Ansible" - - - vlan_id: 200 - enabled: true - - - name: "eth2" - mtu: 1400 - description: "Replaced by Ansible" - enabled: true - vifs: - - vlan_id: 200 - enabled: true - - - name: "eth0" - enabled: true - duplex: "auto" - speed: "auto" - -overridden: - commands: - - "delete interfaces ethernet eth1 description" - - "delete interfaces ethernet eth1 speed" - - "delete interfaces ethernet eth1 duplex" - - "delete interfaces ethernet eth1 mtu" - - "delete interfaces ethernet eth1 vif 200 description" - - "delete interfaces ethernet eth2 speed" - - "delete interfaces ethernet eth2 duplex" - - "delete interfaces ethernet eth2 vif 200 description" - - "set interfaces ethernet eth2 description 'Overridden by Ansible'" - - "set interfaces ethernet eth2 mtu '1200'" - - after: - - name: "eth0" - enabled: true - speed: "auto" - duplex: "auto" - - - name: "eth1" - enabled: true - vifs: - - vlan_id: 200 - enabled: true - - - name: "eth2" - enabled: true - description: "Overridden by Ansible" - mtu: 1200 - vifs: - - vlan_id: 200 - enabled: true - -deleted: - commands: - - "delete interfaces ethernet eth1 description" - - "delete interfaces ethernet eth1 speed" - - "delete interfaces ethernet eth1 duplex" - - "delete interfaces ethernet eth1 mtu" - - "delete interfaces ethernet eth1 vif 200 description" - - "delete interfaces ethernet eth2 description" - - "delete interfaces ethernet eth2 speed" - - "delete interfaces ethernet eth2 duplex" - - "delete interfaces ethernet eth2 mtu" - - "delete interfaces ethernet eth2 vif 200 description" - - after: - - name: "eth0" - enabled: true - speed: "auto" - duplex: "auto" - - - name: "eth1" - enabled: true - vifs: - - vlan_id: 200 - enabled: true - - - name: "eth2" - enabled: true - vifs: - - vlan_id: 200 - enabled: true - -round_trip: - after: - - name: "eth0" - enabled: true - speed: "auto" - duplex: "auto" - - - name: "eth1" - description: "Interface 1 - Description (WILL BE REVERTED)" - enabled: true - mtu: 1200 - vifs: - - vlan_id: 100 - description: "Eth1 - VIF 100 (WILL BE REVERTED)" - mtu: 400 - enabled: true - - - vlan_id: 101 - description: "Eth1 - VIF 101 (WILL BE REMOVED)" - enabled: true - - - name: "eth2" - description: "Interface 2 (ADMIN DOWN) (WILL BE REVERTED)" - mtu: 600 - enabled: false diff --git a/test/integration/targets/vyos_l3_interface/defaults/main.yaml b/test/integration/targets/vyos_l3_interface/defaults/main.yaml deleted file mode 100644 index 9ef5ba5165..0000000000 --- a/test/integration/targets/vyos_l3_interface/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_l3_interface/tasks/cli.yaml b/test/integration/targets/vyos_l3_interface/tasks/cli.yaml deleted file mode 100644 index 890d3acf3e..0000000000 --- a/test/integration/targets/vyos_l3_interface/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_l3_interface/tasks/main.yaml b/test/integration/targets/vyos_l3_interface/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_l3_interface/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_l3_interface/tests/cli/basic.yaml b/test/integration/targets/vyos_l3_interface/tests/cli/basic.yaml deleted file mode 100644 index 4eac2abe56..0000000000 --- a/test/integration/targets/vyos_l3_interface/tests/cli/basic.yaml +++ /dev/null @@ -1,203 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: Remove IP address - vyos_l3_interface: - name: eth1 - state: absent - -- name: Remove IP address - vyos_l3_interface: - name: eth2 - state: absent - -- name: Set IPv4 address - vyos_l3_interface: - name: eth1 - ipv4: 192.168.2.10/24 - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' - -- name: Set IPv4 address (idempotent) - vyos_l3_interface: - name: eth1 - ipv4: 192.168.2.10/24 - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Set IPv6 address - vyos_l3_interface: - name: eth1 - ipv6: fd5d:12c9:2201:1::1/64 - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands' - -- name: Set IPv6 address (idempotent) - vyos_l3_interface: - name: eth1 - ipv6: fd5d:12c9:2201:1::1/64 - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Remove all IP addresses - vyos_l3_interface: - name: eth1 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1 address" in result.commands' - -- name: Remove all IP addresses again (idempotent) - vyos_l3_interface: - name: eth1 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Set IPv4 and IPv6 address - vyos_l3_interface: - name: eth1 - ipv4: 192.168.2.10/24 - ipv6: fd5d:12c9:2201:1::1/64 - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' - - '"set interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands' - -- name: Set IPv4 and IPv6 address again (idempotent) - vyos_l3_interface: - name: eth1 - ipv4: 192.168.2.10/24 - ipv6: fd5d:12c9:2201:1::1/64 - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Remove IPv4 address - vyos_l3_interface: - name: eth1 - ipv4: 192.168.2.10/24 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' - -- name: Remove IPv4 address again (idempotent) - vyos_l3_interface: - name: eth1 - ipv4: 192.168.2.10/24 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Remove IPv6 address - vyos_l3_interface: - name: eth1 - ipv6: fd5d:12c9:2201:1::1/64 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands' - -- name: Remove IPv6 address again (idempotent) - vyos_l3_interface: - name: eth1 - ipv6: fd5d:12c9:2201:1::1/64 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Set IP addresses on aggregate - vyos_l3_interface: - aggregate: - - {name: eth1, ipv4: 192.168.2.10/24} - - {name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64"} - - {name: eth2, ipv4: 192.168.4.10/24} - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' - - '"set interfaces ethernet eth2 address 192.168.3.10/24" in result.commands' - - '"set interfaces ethernet eth2 address fd5d:12c9:2201:1::1/64" in result.commands' - - '"set interfaces ethernet eth2 address 192.168.4.10/24" in result.commands' - -- name: Set IP addresses on aggregate (idempotent) - vyos_l3_interface: - aggregate: - - {name: eth1, ipv4: 192.168.2.10/24} - - {name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64"} - - {name: eth2, ipv4: 192.168.4.10/24} - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Remove IP addresses on aggregate - vyos_l3_interface: - aggregate: - - {name: eth1, ipv4: 192.168.2.10/24} - - {name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64"} - - {name: eth2, ipv4: 192.168.4.10/24} - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' - - '"delete interfaces ethernet eth2 address 192.168.3.10/24" in result.commands' - - '"delete interfaces ethernet eth2 address fd5d:12c9:2201:1::1/64" in result.commands' - - '"delete interfaces ethernet eth2 address 192.168.4.10/24" in result.commands' - -- name: Remove IP addresses on aggregate (idempotent) - vyos_l3_interface: - aggregate: - - {name: eth1, ipv4: 192.168.2.10/24} - - {name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64"} - - {name: eth2, ipv4: 192.168.4.10/24} - state: absent - register: result - -- assert: - that: - - 'result.changed == false' diff --git a/test/integration/targets/vyos_l3_interfaces/defaults/main.yaml b/test/integration/targets/vyos_l3_interfaces/defaults/main.yaml deleted file mode 100644 index 164afead28..0000000000 --- a/test/integration/targets/vyos_l3_interfaces/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "[^_].*" -test_items: [] diff --git a/test/integration/targets/vyos_l3_interfaces/meta/main.yml b/test/integration/targets/vyos_l3_interfaces/meta/main.yml deleted file mode 100644 index 7413320e48..0000000000 --- a/test/integration/targets/vyos_l3_interfaces/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_vyos_tests diff --git a/test/integration/targets/vyos_l3_interfaces/tasks/cli.yaml b/test/integration/targets/vyos_l3_interfaces/tasks/cli.yaml deleted file mode 100644 index 337e34133b..0000000000 --- a/test/integration/targets/vyos_l3_interfaces/tasks/cli.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -- name: Collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - use_regex: true - register: test_cases - delegate_to: localhost - -- name: Set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - delegate_to: localhost - -- name: Run test case (connection=network_cli) - include: "{{ test_case_to_run }}" - vars: - ansible_connection: network_cli - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_l3_interfaces/tasks/main.yaml b/test/integration/targets/vyos_l3_interfaces/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_l3_interfaces/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml b/test/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml deleted file mode 100644 index d253bd1438..0000000000 --- a/test/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- name: Setup - cli_config: - config: "{{ lines }}" - vars: - lines: | - set interfaces ethernet eth1 address '192.0.2.14/24' - set interfaces ethernet eth2 address '192.0.2.10/24' - set interfaces ethernet eth2 address '192.0.2.11/24' - set interfaces ethernet eth2 address '2001:db8::10/32' - set interfaces ethernet eth2 address '2001:db8::12/32' diff --git a/test/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml b/test/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml deleted file mode 100644 index 31af5ba961..0000000000 --- a/test/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml +++ /dev/null @@ -1,13 +0,0 @@ ---- -- name: Remove Config - cli_config: - config: "{{ lines }}" - vars: - lines: | - delete interfaces ethernet "{{ intf }}" address - delete interfaces ethernet "{{ intf }}" vif - loop: - - eth1 - - eth2 - loop_control: - loop_var: intf diff --git a/test/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml b/test/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml deleted file mode 100644 index 568e05b50c..0000000000 --- a/test/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -- debug: - msg: "Start vyos_interfaces deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- block: - - include_tasks: _populate.yaml - - - name: Delete attributes of given interfaces - vyos_l3_interfaces: &deleted - config: - - name: eth1 - - name: eth2 - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_l3_interfaces: *deleted - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml b/test/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml deleted file mode 100644 index 4859dca2ec..0000000000 --- a/test/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml +++ /dev/null @@ -1,36 +0,0 @@ ---- -- debug: - msg: "START vyos_l3_interfaces empty_config integration tests on connection={{ ansible_connection }}" - -- name: Merged with empty config should give appropriate error message - vyos_l3_interfaces: - config: - state: merged - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state merged' - -- name: Replaced with empty config should give appropriate error message - vyos_l3_interfaces: - config: - state: replaced - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state replaced' - -- name: Overridden with empty config should give appropriate error message - vyos_l3_interfaces: - config: - state: overridden - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state overridden' diff --git a/test/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml b/test/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml deleted file mode 100644 index ec6c3db09b..0000000000 --- a/test/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml +++ /dev/null @@ -1,58 +0,0 @@ ---- -- debug: - msg: "START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- block: - - name: Merge the provided configuration with the exisiting running configuration - vyos_l3_interfaces: &merged - config: - - name: eth1 - ipv4: - - address: 192.0.2.10/24 - ipv6: - - address: 2001:db8::10/32 - - - name: eth2 - ipv4: - - address: 198.51.100.10/24 - vifs: - - vlan_id: 101 - ipv4: - - address: 198.51.100.130/25 - ipv6: - - address: 2001:db8::20/32 - state: merged - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts was correctly generated - assert: - that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) - vyos_l3_interfaces: *merged - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml b/test/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml deleted file mode 100644 index c33b8b1190..0000000000 --- a/test/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml +++ /dev/null @@ -1,52 +0,0 @@ ---- -- debug: - msg: "START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- block: - - include_tasks: _populate.yaml - - - name: Overrides all device configuration with provided configuration - vyos_l3_interfaces: &overridden - config: - - name: eth0 - ipv4: - - address: dhcp - - name: eth1 - ipv4: - - address: "192.0.2.15/24" - state: overridden - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that correct commands were generated - assert: - that: - - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts were correctly generated - assert: - that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Overrides all device configuration with provided configurations (IDEMPOTENT) - vyos_l3_interfaces: *overridden - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml b/test/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml deleted file mode 100644 index 51b372def3..0000000000 --- a/test/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml +++ /dev/null @@ -1,52 +0,0 @@ ---- -- debug: - msg: "START vyos_l3_interfaces replaced integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- block: - - include_tasks: _populate.yaml - - - name: Replace device configurations of listed interfaces with provided configurations - vyos_l3_interfaces: &replaced - config: - - name: eth1 - ipv4: - - address: 192.0.2.19/24 - - name: eth2 - ipv6: - - address: 2001:db8::11/32 - state: replaced - register: result - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that before dicts are correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that after dict is correctly generated - assert: - that: - - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Replace device configurations of listed interfaces with provided configurarions (IDEMPOTENT) - vyos_l3_interfaces: *replaced - register: result - - - name: Assert that task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dict is correctly generated - assert: - that: - - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_l3_interfaces/vars/main.yaml b/test/integration/targets/vyos_l3_interfaces/vars/main.yaml deleted file mode 100644 index 1241763451..0000000000 --- a/test/integration/targets/vyos_l3_interfaces/vars/main.yaml +++ /dev/null @@ -1,114 +0,0 @@ ---- -merged: - before: - - name: "eth0" - ipv4: - - address: "dhcp" - - - name: "eth1" - - - name: "eth2" - - commands: - - "set interfaces ethernet eth1 address '192.0.2.10/24'" - - "set interfaces ethernet eth1 address '2001:db8::10/32'" - - "set interfaces ethernet eth2 address '198.51.100.10/24'" - - "set interfaces ethernet eth2 vif 101 address '198.51.100.130/25'" - - "set interfaces ethernet eth2 vif 101 address '2001:db8::20/32'" - - after: - - name: "eth0" - ipv4: - - address: "dhcp" - - - name: "eth1" - ipv4: - - address: "192.0.2.10/24" - ipv6: - - address: "2001:db8::10/32" - - - name: "eth2" - ipv4: - - address: "198.51.100.10/24" - vifs: - - vlan_id: 101 - ipv4: - - address: "198.51.100.130/25" - ipv6: - - address: "2001:db8::20/32" - -populate: - - name: "eth1" - ipv4: - - address: "192.0.2.14/24" - - - name: "eth2" - ipv4: - - address: "192.0.2.10/24" - - address: "192.0.2.11/24" - ipv6: - - address: "2001:db8::10/32" - - address: "2001:db8::12/32" - - - name: "eth0" - ipv4: - - address: "dhcp" - -replaced: - commands: - - "delete interfaces ethernet eth2 address '192.0.2.10/24'" - - "delete interfaces ethernet eth2 address '192.0.2.11/24'" - - "delete interfaces ethernet eth2 address '2001:db8::10/32'" - - "delete interfaces ethernet eth2 address '2001:db8::12/32'" - - "set interfaces ethernet eth2 address '2001:db8::11/32'" - - "delete interfaces ethernet eth1 address '192.0.2.14/24'" - - "set interfaces ethernet eth1 address '192.0.2.19/24'" - - after: - - name: "eth2" - ipv6: - - address: "2001:db8::11/32" - - - name: "eth1" - ipv4: - - address: "192.0.2.19/24" - - - name: "eth0" - ipv4: - - address: "dhcp" - -overridden: - commands: - - delete interfaces ethernet eth1 address '192.0.2.14/24' - - set interfaces ethernet eth1 address '192.0.2.15/24' - - delete interfaces ethernet eth2 address '192.0.2.10/24' - - delete interfaces ethernet eth2 address '192.0.2.11/24' - - delete interfaces ethernet eth2 address '2001:db8::10/32' - - delete interfaces ethernet eth2 address '2001:db8::12/32' - - after: - - name: "eth0" - ipv4: - - address: "dhcp" - - - name: "eth1" - ipv4: - - address: "192.0.2.15/24" - - - name: "eth2" - -deleted: - commands: - - delete interfaces ethernet eth1 address '192.0.2.14/24' - - delete interfaces ethernet eth2 address '192.0.2.10/24' - - delete interfaces ethernet eth2 address '192.0.2.11/24' - - delete interfaces ethernet eth2 address '2001:db8::10/32' - - delete interfaces ethernet eth2 address '2001:db8::12/32' - after: - - name: "eth0" - ipv4: - - address: "dhcp" - - - name: "eth1" - - - name: "eth2" diff --git a/test/integration/targets/vyos_lag_interfaces/defaults/main.yaml b/test/integration/targets/vyos_lag_interfaces/defaults/main.yaml deleted file mode 100644 index 164afead28..0000000000 --- a/test/integration/targets/vyos_lag_interfaces/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "[^_].*" -test_items: [] diff --git a/test/integration/targets/vyos_lag_interfaces/meta/main.yaml b/test/integration/targets/vyos_lag_interfaces/meta/main.yaml deleted file mode 100644 index 7413320e48..0000000000 --- a/test/integration/targets/vyos_lag_interfaces/meta/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_vyos_tests diff --git a/test/integration/targets/vyos_lag_interfaces/tasks/cli.yaml b/test/integration/targets/vyos_lag_interfaces/tasks/cli.yaml deleted file mode 100644 index 655e51ee63..0000000000 --- a/test/integration/targets/vyos_lag_interfaces/tasks/cli.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- name: Collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - use_regex: true - 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 (connection=network_cli) - include: "{{ test_case_to_run }}" - vars: - ansible_connection: network_cli - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_lag_interfaces/tasks/main.yaml b/test/integration/targets/vyos_lag_interfaces/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_lag_interfaces/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml deleted file mode 100644 index 72cf397859..0000000000 --- a/test/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- name: Add Bond - cli_config: - config: "{{ lines }}" - vars: - lines: | - set interfaces bonding bond0 - set interfaces bonding bond1 diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml deleted file mode 100644 index f644bd935f..0000000000 --- a/test/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -- name: Setup - cli_config: - config: "{{ lines }}" - vars: - lines: | - set interfaces bonding bond0 - set interfaces bonding bond0 hash-policy 'layer2' - set interfaces bonding bond0 mode 'active-backup' - set interfaces ethernet eth1 bond-group bond0 - set interfaces bonding bond1 - set interfaces bonding bond0 primary 'eth1' - set interfaces bonding bond1 hash-policy 'layer2+3' - set interfaces bonding bond1 mode 'active-backup' - set interfaces ethernet eth2 bond-group bond1 - set interfaces bonding bond1 primary 'eth2' diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml deleted file mode 100644 index 2fbfaa0535..0000000000 --- a/test/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- name: Remove Bond - cli_config: - config: "{{ lines }}" - vars: - lines: | - delete interfaces bonding bond0 - delete interfaces bonding bond1 diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml deleted file mode 100644 index 37e61c1da7..0000000000 --- a/test/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- name: Remove Config - cli_config: - config: "{{ lines }}" - vars: - lines: | - delete interfaces bonding bond0 hash-policy - delete interfaces ethernet eth1 bond-group bond0 - delete interfaces bonding bond0 mode - delete interfaces bonding bond0 primary - delete interfaces bonding bond1 hash-policy - delete interfaces ethernet eth2 bond-group bond1 - delete interfaces bonding bond1 mode - delete interfaces bonding bond1 primary diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml deleted file mode 100644 index be635d2936..0000000000 --- a/test/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml +++ /dev/null @@ -1,46 +0,0 @@ ---- -- debug: - msg: "Start vyos_lag_interfaces deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate.yaml - -- block: - - name: Delete attributes of given LAG interfaces. - vyos_lag_interfaces: &deleted - config: - - name: bond0 - - name: bond1 - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_lag_interfaces: *deleted - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml deleted file mode 100644 index 6590bb1d3d..0000000000 --- a/test/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml +++ /dev/null @@ -1,36 +0,0 @@ ---- -- debug: - msg: "START vyos_lag_interfaces empty_config integration tests on connection={{ ansible_connection }}" - -- name: Merged with empty config should give appropriate error message - vyos_lag_interfaces: - config: - state: merged - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state merged' - -- name: Replaced with empty config should give appropriate error message - vyos_lag_interfaces: - config: - state: replaced - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state replaced' - -- name: Overridden with empty config should give appropriate error message - vyos_lag_interfaces: - config: - state: overridden - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state overridden' diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml deleted file mode 100644 index d621e33681..0000000000 --- a/test/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml +++ /dev/null @@ -1,60 +0,0 @@ ---- -- debug: - msg: "START vyos_lag_interfaces merged integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _remove_bond.yaml - -- include_tasks: _add_bond.yaml - -- block: - - name: Merge the provided configuration with the exisiting running configuration - vyos_lag_interfaces: &merged - config: - - name: bond0 - hash_policy: "layer2" - mode: "active-backup" - members: - - member: eth1 - primary: eth1 - - - name: bond1 - hash_policy: "layer2+3" - mode: "active-backup" - members: - - member: eth2 - primary: eth2 - state: merged - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts was correctly generated - assert: - that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) - vyos_lag_interfaces: *merged - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml deleted file mode 100644 index 05bec8e2a3..0000000000 --- a/test/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -- debug: - msg: "START vyos_lag_interfaces overridden integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _remove_bond.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Overrides all device configuration with provided configuration - vyos_lag_interfaces: &overridden - config: - - name: bond1 - mode: "active-backup" - members: - - member: eth2 - primary: eth2 - hash_policy: layer2 - state: overridden - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that correct commands were generated - assert: - that: - - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts were correctly generated - assert: - that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Overrides all device configuration with provided configurations (IDEMPOTENT) - vyos_lag_interfaces: *overridden - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml deleted file mode 100644 index c1b721fc2a..0000000000 --- a/test/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml +++ /dev/null @@ -1,51 +0,0 @@ ---- -- debug: - msg: "START vyos_lag_interfaces replaced integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Replace device configurations of listed LAG interfaces with provided configurations - vyos_lag_interfaces: &replaced - config: - - name: bond1 - mode: "802.3ad" - hash_policy: "layer2" - members: - - member: eth2 - state: replaced - register: result - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that before dicts are correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that after dict is correctly generated - assert: - that: - - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Replace device configurations of listed LAG interfaces with provided configurarions (IDEMPOTENT) - vyos_lag_interfaces: *replaced - register: result - - - name: Assert that task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dict is correctly generated - assert: - that: - - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml deleted file mode 100644 index 7521d8e6ac..0000000000 --- a/test/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml +++ /dev/null @@ -1,69 +0,0 @@ ---- -- debug: - msg: "START vyos_lag_interfaces round trip integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _remove_bond.yaml - -- block: - - name: Apply the provided configuration (base config) - vyos_lag_interfaces: - config: - - name: bond0 - hash_policy: "layer2" - mode: "active-backup" - members: - - member: eth1 - primary: eth1 - - - name: bond1 - hash_policy: "layer2+3" - mode: "active-backup" - members: - - member: eth2 - primary: eth2 - - state: merged - register: base_config - - - name: Gather lag_interfaces facts - vyos_facts: - gather_subset: - - default - gather_network_resources: - - lag_interfaces - - - name: Apply the provided configuration (config to be reverted) - vyos_lag_interfaces: - config: - - name: bond0 - hash_policy: "layer2+3" - mode: "802.3ad" - members: - - member: eth1 - - - name: bond1 - hash_policy: "layer2" - mode: "xor-hash" - members: - - member: eth2 - state: merged - register: result - - - name: Assert that changes were applied - assert: - that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Revert back to base config using facts round trip - vyos_lag_interfaces: - config: "{{ ansible_facts['network_resources']['lag_interfaces'] }}" - state: overridden - register: revert - - - name: Assert that config was reverted - assert: - that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_lag_interfaces/vars/main.yaml b/test/integration/targets/vyos_lag_interfaces/vars/main.yaml deleted file mode 100644 index 8726e399c2..0000000000 --- a/test/integration/targets/vyos_lag_interfaces/vars/main.yaml +++ /dev/null @@ -1,115 +0,0 @@ ---- -merged: - before: - - name: "bond0" - - - name: "bond1" - - commands: - - "set interfaces bonding bond0 hash-policy 'layer2'" - - "set interfaces bonding bond0 mode 'active-backup'" - - "set interfaces ethernet eth1 bond-group 'bond0'" - - "set interfaces bonding bond0 primary 'eth1'" - - "set interfaces bonding bond1 hash-policy 'layer2+3'" - - "set interfaces bonding bond1 mode 'active-backup'" - - "set interfaces ethernet eth2 bond-group 'bond1'" - - "set interfaces bonding bond1 primary 'eth2'" - - after: - - name: "bond0" - hash_policy: "layer2" - members: - - member: eth1 - mode: "active-backup" - primary: eth1 - - - name: "bond1" - hash_policy: "layer2+3" - members: - - member: eth2 - mode: "active-backup" - primary: eth2 - -populate: - - name: "bond0" - hash_policy: "layer2" - members: - - member: eth1 - mode: "active-backup" - primary: eth1 - - - name: "bond1" - hash_policy: "layer2+3" - members: - - member: eth2 - mode: "active-backup" - primary: eth2 - -replaced: - commands: - - "delete interfaces bonding bond1 primary" - - "set interfaces bonding bond1 hash-policy 'layer2'" - - "set interfaces bonding bond1 mode '802.3ad'" - - after: - - name: "bond0" - hash_policy: "layer2" - members: - - member: eth1 - mode: "active-backup" - primary: eth1 - - - name: "bond1" - hash_policy: "layer2" - members: - - member: eth2 - mode: "802.3ad" - -overridden: - commands: - - "delete interfaces bonding bond0 hash-policy" - - "delete interfaces ethernet eth1 bond-group 'bond0'" - - "delete interfaces bonding bond0 mode" - - "delete interfaces bonding bond0 primary" - - "set interfaces bonding bond1 hash-policy 'layer2'" - - after: - - name: "bond0" - - name: "bond1" - hash_policy: "layer2" - members: - - member: eth2 - mode: "active-backup" - primary: eth2 - -deleted: - commands: - - "delete interfaces bonding bond0 hash-policy" - - "delete interfaces ethernet eth1 bond-group 'bond0'" - - "delete interfaces bonding bond0 mode" - - "delete interfaces bonding bond0 primary" - - "delete interfaces bonding bond1 hash-policy" - - "delete interfaces ethernet eth2 bond-group 'bond1'" - - "delete interfaces bonding bond1 mode" - - "delete interfaces bonding bond1 primary" - - after: - - name: "bond0" - - - name: "bond1" - -round_trip: - after: - - name: "bond0" - hash_policy: "layer2+3" - members: - - member: eth1 - mode: "802.3ad" - primary: eth1 - - - name: "bond1" - hash_policy: "layer2" - members: - - member: eth2 - mode: "xor-hash" - primary: eth2 diff --git a/test/integration/targets/vyos_linkagg/defaults/main.yaml b/test/integration/targets/vyos_linkagg/defaults/main.yaml deleted file mode 100644 index 9ef5ba5165..0000000000 --- a/test/integration/targets/vyos_linkagg/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_linkagg/tasks/cli.yaml b/test/integration/targets/vyos_linkagg/tasks/cli.yaml deleted file mode 100644 index 890d3acf3e..0000000000 --- a/test/integration/targets/vyos_linkagg/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_linkagg/tasks/main.yaml b/test/integration/targets/vyos_linkagg/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_linkagg/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_linkagg/tests/cli/basic.yaml b/test/integration/targets/vyos_linkagg/tests/cli/basic.yaml deleted file mode 100644 index 48fc6402f5..0000000000 --- a/test/integration/targets/vyos_linkagg/tests/cli/basic.yaml +++ /dev/null @@ -1,184 +0,0 @@ ---- -- debug: msg="cli/basic.yaml on connection={{ ansible_connection }}" - -- name: Remove linkagg - vyos_linkagg: - name: bond0 - state: absent - -- name: Remove linkagg - vyos_linkagg: - name: bond1 - state: absent - -- name: Create linkagg - vyos_linkagg: - name: bond0 - members: - - eth1 - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces bonding bond0 mode 802.3ad" in result.commands' - - '"set interfaces ethernet eth1 bond-group bond0" in result.commands' - -- name: Create linkagg again (idempotent) - vyos_linkagg: - name: bond0 - members: - - eth1 - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Add linkagg member - vyos_linkagg: - name: bond0 - members: - - eth2 - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth2 bond-group bond0" in result.commands' - -- name: Add linkagg member again (idempotent) - vyos_linkagg: - name: bond0 - members: - - eth2 - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Disable linkagg - vyos_linkagg: - name: bond0 - state: down - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces bonding bond0 disable" in result.commands' - -- name: Disable linkagg again (idempotent) - vyos_linkagg: - name: bond0 - state: down - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Enable linkagg - vyos_linkagg: - name: bond0 - state: up - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces bonding bond0 disable" in result.commands[0]' - -- name: Enable linkagg again (idempotent) - vyos_linkagg: - name: bond0 - state: up - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Remove linkagg - vyos_linkagg: - name: bond0 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1 bond-group" in result.commands' - - '"delete interfaces ethernet eth2 bond-group" in result.commands' - - '"delete interfaces bonding bond0" in result.commands' - -- name: Remove linkagg again (idempotent) - vyos_linkagg: - name: bond0 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Create collection of linkagg definitions - vyos_linkagg: - aggregate: - - {name: bond0, members: [eth1]} - - {name: bond1, members: [eth2]} - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces bonding bond0 mode 802.3ad" in result.commands' - - '"set interfaces ethernet eth1 bond-group bond0" in result.commands' - - '"set interfaces bonding bond1 mode 802.3ad" in result.commands' - - '"set interfaces ethernet eth2 bond-group bond1" in result.commands' - -- name: Create collection of linkagg definitions again (idempotent) - vyos_linkagg: - aggregate: - - {name: bond0, members: [eth1]} - - {name: bond1, members: [eth2]} - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Remove collection of linkagg definitions - vyos_linkagg: - aggregate: - - name: bond0 - - name: bond1 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1 bond-group" in result.commands' - - '"delete interfaces bonding bond0" in result.commands' - - '"delete interfaces ethernet eth2 bond-group" in result.commands' - - '"delete interfaces bonding bond1" in result.commands' - -- name: Remove collection of linkagg definitions again (idempotent) - vyos_linkagg: - aggregate: - - name: bond0 - - name: bond1 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' diff --git a/test/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml b/test/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml deleted file mode 100644 index 93f98e7aed..0000000000 --- a/test/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml +++ /dev/null @@ -1,31 +0,0 @@ ---- -- debug: msg="START vyos cli/net_linkagg.yaml on connection={{ ansible_connection }}" - -# Add minimal testcase to check args are passed correctly to -# implementation module and module run is successful. - -- name: Remove linkagg - set - net_linkagg: - name: bond0 - state: absent - -- name: Create linkagg using platform agnostic module - net_linkagg: - name: bond0 - members: - - eth1 - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces bonding bond0 mode 802.3ad" in result.commands' - - '"set interfaces ethernet eth1 bond-group bond0" in result.commands' - -- name: Remove linkagg - teardown - net_linkagg: - name: bond0 - state: absent - -- debug: msg="END vyos cli/net_linkagg.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_lldp/aliases b/test/integration/targets/vyos_lldp/aliases deleted file mode 100644 index 8071e1f75b..0000000000 --- a/test/integration/targets/vyos_lldp/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/vyos/group1 diff --git a/test/integration/targets/vyos_lldp/defaults/main.yaml b/test/integration/targets/vyos_lldp/defaults/main.yaml deleted file mode 100644 index 9ef5ba5165..0000000000 --- a/test/integration/targets/vyos_lldp/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_lldp/tasks/cli.yaml b/test/integration/targets/vyos_lldp/tasks/cli.yaml deleted file mode 100644 index 890d3acf3e..0000000000 --- a/test/integration/targets/vyos_lldp/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_lldp/tasks/main.yaml b/test/integration/targets/vyos_lldp/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_lldp/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_lldp/tests/cli/basic.yaml b/test/integration/targets/vyos_lldp/tests/cli/basic.yaml deleted file mode 100644 index bc7774f0ee..0000000000 --- a/test/integration/targets/vyos_lldp/tests/cli/basic.yaml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: Make sure LLDP is not running before tests - vyos_config: - lines: delete service lldp - -- name: Enable LLDP service - vyos_lldp: - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set service lldp" in result.commands' - -- name: Enable LLDP service again (idempotent) - vyos_lldp: - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Disable LLDP service - vyos_lldp: - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete service lldp" in result.commands' - -- name: - vyos_lldp: - state: absent - register: result - -- assert: - that: - - 'result.changed == false' diff --git a/test/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml b/test/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml deleted file mode 100644 index cf8f97cb8a..0000000000 --- a/test/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml +++ /dev/null @@ -1,25 +0,0 @@ ---- -- debug: msg="START vyos cli/net_lldp.yaml on connection={{ ansible_connection }}" - -# Add minimal testcase to check args are passed correctly to -# implementation module and module run is successful. - -- name: Make sure LLDP is not running - setup - vyos_config: - lines: delete service lldp - -- name: Enable LLDP service using platform agnostic module - net_lldp: - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set service lldp" in result.commands' - -- name: Make sure LLDP is not running - teardown - vyos_config: - lines: delete service lldp - -- debug: msg="END vyos cli/net_lldp.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_lldp_global/aliases b/test/integration/targets/vyos_lldp_global/aliases deleted file mode 100644 index 8071e1f75b..0000000000 --- a/test/integration/targets/vyos_lldp_global/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/vyos/group1 diff --git a/test/integration/targets/vyos_lldp_global/defaults/main.yaml b/test/integration/targets/vyos_lldp_global/defaults/main.yaml deleted file mode 100644 index 164afead28..0000000000 --- a/test/integration/targets/vyos_lldp_global/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "[^_].*" -test_items: [] diff --git a/test/integration/targets/vyos_lldp_global/tasks/cli.yaml b/test/integration/targets/vyos_lldp_global/tasks/cli.yaml deleted file mode 100644 index 655e51ee63..0000000000 --- a/test/integration/targets/vyos_lldp_global/tasks/cli.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- name: Collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - use_regex: true - 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 (connection=network_cli) - include: "{{ test_case_to_run }}" - vars: - ansible_connection: network_cli - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_lldp_global/tasks/main.yaml b/test/integration/targets/vyos_lldp_global/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_lldp_global/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml b/test/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml deleted file mode 100644 index 183c9a5c10..0000000000 --- a/test/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- name: Setup - cli_config: - config: "{{ lines }}" - vars: - lines: | - set service lldp - set service lldp legacy-protocols 'cdp' - set service lldp management-address '192.0.2.17' diff --git a/test/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml b/test/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml deleted file mode 100644 index 3a0abf22ab..0000000000 --- a/test/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- name: Remove Config - cli_config: - config: "{{ lines }}" - vars: - lines: | - delete service lldp legacy-protocols - delete service lldp management-address - delete service lldp diff --git a/test/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml b/test/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml deleted file mode 100644 index 324ab18484..0000000000 --- a/test/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- debug: - msg: "Start vyos_lldp_global deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate.yaml - -- block: - - name: Delete attributes of LLDP service. - vyos_lldp_global: &deleted - config: - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate == result['before']}}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted['after'] == result['after']}}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_lldp_global: *deleted - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted['after'] == result['before'] }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml b/test/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml deleted file mode 100644 index 46f3b96e45..0000000000 --- a/test/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml +++ /dev/null @@ -1,25 +0,0 @@ ---- -- debug: - msg: "START vyos_lldp_global empty_config integration tests on connection={{ ansible_connection }}" - -- name: Merged with empty config should give appropriate error message - vyos_lldp_global: - config: - state: merged - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state merged' - -- name: Replaced with empty config should give appropriate error message - vyos_lldp_global: - config: - state: replaced - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state replaced' diff --git a/test/integration/targets/vyos_lldp_global/tests/cli/merged.yaml b/test/integration/targets/vyos_lldp_global/tests/cli/merged.yaml deleted file mode 100644 index 9b8e448bd1..0000000000 --- a/test/integration/targets/vyos_lldp_global/tests/cli/merged.yaml +++ /dev/null @@ -1,49 +0,0 @@ ---- -- debug: - msg: "START vyos_lldp_global merged integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Merge the provided configuration with the exisiting running configuration - vyos_lldp_global: &merged - config: - legacy_protocols: - - 'fdp' - - 'cdp' - address: 192.0.2.11 - state: merged - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: "{{ merged['before'] == result['before'] }}" - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts was correctly generated - assert: - that: - - "{{ merged['after'] == result['after'] }}" - - - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) - vyos_lldp_global: *merged - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ merged['after'] == result['before'] }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml b/test/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml deleted file mode 100644 index f641792461..0000000000 --- a/test/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml +++ /dev/null @@ -1,51 +0,0 @@ ---- -- debug: - msg: "START vyos_lldp_global replaced integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Replace device configurations of LLDP service with provided configurations - vyos_lldp_global: &replaced - config: - legacy_protocols: - - 'edp' - - 'sonmp' - - 'cdp' - address: 192.0.2.14 - state: replaced - register: result - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that before dicts are correctly generated - assert: - that: - - "{{ populate == result['before'] }}" - - - name: Assert that after dict is correctly generated - assert: - that: - - "{{ replaced['after'] == result['after'] }}" - - - name: Replace device configurations of LLDP service with provided configurarions (IDEMPOTENT) - vyos_lldp_global: *replaced - register: result - - - name: Assert that task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dict is correctly generated - assert: - that: - - "{{ replaced['after'] == result['before'] }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml b/test/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml deleted file mode 100644 index 1e37cdefeb..0000000000 --- a/test/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml +++ /dev/null @@ -1,51 +0,0 @@ ---- -- debug: - msg: "START vyos_lldp_global round trip integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- block: - - name: Apply the provided configuration (base config) - vyos_lldp_global: - config: - legacy_protocols: - - 'fdp' - - 'cdp' - address: 192.0.2.11 - state: merged - register: base_config - - - name: Gather vyos_lldp_global facts - vyos_facts: - gather_subset: - - default - gather_network_resources: - - lldp_global - - - name: Apply the provided configuration (config to be reverted) - vyos_lldp_global: - config: - legacy_protocols: - - 'edp' - - 'sonmp' - - 'cdp' - address: 192.0.2.14 - state: merged - register: result - - - name: Assert that changes were applied - assert: - that: "{{ round_trip['after'] == result['after'] }}" - - - name: Revert back to base config using facts round trip - vyos_lldp_global: - config: "{{ ansible_facts['network_resources']['lldp_global'] }}" - state: replaced - register: revert - - - name: Assert that config was reverted - assert: - that: "{{ base_config['after'] == revert['after'] }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_lldp_global/vars/main.yaml b/test/integration/targets/vyos_lldp_global/vars/main.yaml deleted file mode 100644 index 420b2b4e8f..0000000000 --- a/test/integration/targets/vyos_lldp_global/vars/main.yaml +++ /dev/null @@ -1,56 +0,0 @@ ---- -merged: - before: - address: '192.0.2.17' - enable: true - legacy_protocols: - - 'cdp' - - commands: - - "set service lldp management-address '192.0.2.11'" - - "set service lldp legacy-protocols 'fdp'" - - after: - address: '192.0.2.11' - enable: true - legacy_protocols: - - 'cdp' - - 'fdp' - -populate: - address: '192.0.2.17' - enable: true - legacy_protocols: - - 'cdp' - -replaced: - commands: - - "set service lldp legacy-protocols 'edp'" - - "set service lldp legacy-protocols 'sonmp'" - - "set service lldp management-address '192.0.2.14'" - - after: - address: '192.0.2.14' - enable: true - legacy_protocols: - - 'cdp' - - 'edp' - - 'sonmp' - -deleted: - commands: - - "delete service lldp management-address" - - "delete service lldp legacy-protocols" - - after: - "enable": true - -round_trip: - after: - address: '192.0.2.14' - enable: true - legacy_protocols: - - 'cdp' - - 'edp' - - 'fdp' - - 'sonmp' diff --git a/test/integration/targets/vyos_lldp_interface/aliases b/test/integration/targets/vyos_lldp_interface/aliases deleted file mode 100644 index 8071e1f75b..0000000000 --- a/test/integration/targets/vyos_lldp_interface/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/vyos/group1 diff --git a/test/integration/targets/vyos_lldp_interface/defaults/main.yaml b/test/integration/targets/vyos_lldp_interface/defaults/main.yaml deleted file mode 100644 index 9ef5ba5165..0000000000 --- a/test/integration/targets/vyos_lldp_interface/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_lldp_interface/tasks/cli.yaml b/test/integration/targets/vyos_lldp_interface/tasks/cli.yaml deleted file mode 100644 index 890d3acf3e..0000000000 --- a/test/integration/targets/vyos_lldp_interface/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_lldp_interface/tasks/main.yaml b/test/integration/targets/vyos_lldp_interface/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_lldp_interface/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml b/test/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml deleted file mode 100644 index 8335aeffe7..0000000000 --- a/test/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml +++ /dev/null @@ -1,167 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: Make sure LLDP is not running before tests - vyos_config: - lines: delete service lldp - -- name: Create LLDP configuration - vyos_lldp_interface: - name: eth1 - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set service lldp interface eth1" in result.commands' - -- name: Create LLDP configuration again (idempotent) - vyos_lldp_interface: - name: eth1 - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Disable LLDP configuration - vyos_lldp_interface: - name: eth1 - state: disabled - register: result - -- assert: - that: - - 'result.changed == true' - - '"set service lldp interface eth1 disable" in result.commands' - -- name: Disable LLDP configuration again (idempotent) - vyos_lldp_interface: - name: eth1 - state: disabled - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Enable LLDP configuration - vyos_lldp_interface: - name: eth1 - state: enabled - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete service lldp interface eth1 disable" in result.commands' - -- name: Enable LLDP configuration again (idempotent) - vyos_lldp_interface: - name: eth1 - state: enabled - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Delete LLDP configuration - vyos_lldp_interface: - name: eth1 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete service lldp interface eth1" in result.commands' - -- name: Delete LLDP configuration again (idempotent) - vyos_lldp_interface: - name: eth1 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Create aggregate of LLDP interface configurations - vyos_lldp_interface: - aggregate: - - name: eth1 - - name: eth2 - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set service lldp interface eth1" in result.commands' - - '"set service lldp interface eth2" in result.commands' - -- name: Create aggregate of LLDP interface configurations again (idempotent) - vyos_lldp_interface: - aggregate: - - name: eth1 - - name: eth2 - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Override LLDP interface configuration on aggregate - vyos_lldp_interface: - aggregate: - - name: eth1 - - {name: eth2, state: disabled} - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set service lldp interface eth2 disable" in result.commands' - -- name: Override LLDP interface configuration on aggregate again (idempotent) - vyos_lldp_interface: - aggregate: - - name: eth1 - - {name: eth2, state: disabled} - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Delete aggregate of LLDP interface configurations - vyos_lldp_interface: - aggregate: - - name: eth1 - - name: eth2 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete service lldp interface eth1" in result.commands' - - '"delete service lldp interface eth2" in result.commands' - -- name: Delete aggregate of LLDP interface configurations (idempotent) - vyos_lldp_interface: - aggregate: - - name: eth1 - - name: eth2 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' diff --git a/test/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml b/test/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml deleted file mode 100644 index 49cd8b005f..0000000000 --- a/test/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml +++ /dev/null @@ -1,26 +0,0 @@ ---- -- debug: msg="START vyos cli/net_lldp_interface.yaml on connection={{ ansible_connection }}" - -# Add minimal testcase to check args are passed correctly to -# implementation module and module run is successful. - -- name: Make sure LLDP is not running - setup - vyos_config: - lines: delete service lldp - -- name: Create LLDP configuration using platform agnostic module - net_lldp_interface: - name: eth1 - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set service lldp interface eth1" in result.commands' - -- name: Make sure LLDP is not running - teardown - vyos_config: - lines: delete service lldp - -- debug: msg="END vyos cli/net_lldp_interface.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_lldp_interfaces/aliases b/test/integration/targets/vyos_lldp_interfaces/aliases deleted file mode 100644 index 8071e1f75b..0000000000 --- a/test/integration/targets/vyos_lldp_interfaces/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/vyos/group1 diff --git a/test/integration/targets/vyos_lldp_interfaces/defaults/main.yaml b/test/integration/targets/vyos_lldp_interfaces/defaults/main.yaml deleted file mode 100644 index 164afead28..0000000000 --- a/test/integration/targets/vyos_lldp_interfaces/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "[^_].*" -test_items: [] diff --git a/test/integration/targets/vyos_lldp_interfaces/meta/main.yaml b/test/integration/targets/vyos_lldp_interfaces/meta/main.yaml deleted file mode 100644 index 7413320e48..0000000000 --- a/test/integration/targets/vyos_lldp_interfaces/meta/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_vyos_tests diff --git a/test/integration/targets/vyos_lldp_interfaces/tasks/cli.yaml b/test/integration/targets/vyos_lldp_interfaces/tasks/cli.yaml deleted file mode 100644 index 655e51ee63..0000000000 --- a/test/integration/targets/vyos_lldp_interfaces/tasks/cli.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- name: Collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - use_regex: true - 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 (connection=network_cli) - include: "{{ test_case_to_run }}" - vars: - ansible_connection: network_cli - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_lldp_interfaces/tasks/main.yaml b/test/integration/targets/vyos_lldp_interfaces/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_lldp_interfaces/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml deleted file mode 100644 index eec2039674..0000000000 --- a/test/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- name: Setup - cli_config: - config: "{{ lines }}" - vars: - lines: | - set service lldp interface eth1 - set service lldp interface eth1 location civic-based country-code US - set service lldp interface eth1 location civic-based ca-type 0 ca-value ENGLISH - set service lldp interface eth2 - set service lldp interface eth2 location coordinate-based latitude 33.524449N - set service lldp interface eth2 location coordinate-based altitude 2200 - set service lldp interface eth2 location coordinate-based datum WGS84 - set service lldp interface eth2 location coordinate-based longitude 222.267255W diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml deleted file mode 100644 index f48509eda5..0000000000 --- a/test/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Setup - cli_config: - config: "{{ lines }}" - vars: - lines: | - set service lldp interface eth2 - set service lldp interface eth2 location civic-based country-code US - set service lldp interface eth2 location civic-based ca-type 0 ca-value ENGLISH - set service lldp interface eth2 disable diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml deleted file mode 100644 index 51b5f25473..0000000000 --- a/test/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- name: Remove Config - cli_config: - config: "{{ lines }}" - vars: - lines: | - delete service lldp interface - delete service lldp diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml deleted file mode 100644 index c1efc1fbeb..0000000000 --- a/test/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml +++ /dev/null @@ -1,46 +0,0 @@ ---- -- debug: - msg: "Start vyos_lldp_interfaces deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate.yaml - -- block: - - name: Delete attributes of given LLDP interfaces. - vyos_lldp_interfaces: &deleted - config: - - name: 'eth1' - - name: 'eth2' - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_lldp_interfaces: *deleted - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - "result.commands|length == 0" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}" - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml deleted file mode 100644 index 6b5596ac28..0000000000 --- a/test/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml +++ /dev/null @@ -1,36 +0,0 @@ ---- -- debug: - msg: "START vyos_lldp_interfaces empty_config integration tests on connection={{ ansible_connection }}" - -- name: Merged with empty config should give appropriate error message - vyos_lldp_interfaces: - config: - state: merged - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state merged' - -- name: Replaced with empty config should give appropriate error message - vyos_lldp_interfaces: - config: - state: replaced - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state replaced' - -- name: Overridden with empty config should give appropriate error message - vyos_lldp_interfaces: - config: - state: overridden - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state overridden' diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml deleted file mode 100644 index a1db60fe54..0000000000 --- a/test/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml +++ /dev/null @@ -1,58 +0,0 @@ ---- -- debug: - msg: "START vyos_lldp_interfaces merged integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- block: - - name: Merge the provided configuration with the exisiting running configuration - vyos_lldp_interfaces: &merged - config: - - name: 'eth1' - location: - civic_based: - country_code: 'US' - ca_info: - - ca_type: 0 - ca_value: 'ENGLISH' - - - name: 'eth2' - location: - coordinate_based: - altitude: 2200 - datum: 'WGS84' - longitude: '222.267255W' - latitude: '33.524449N' - state: merged - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts was correctly generated - assert: - that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) - vyos_lldp_interfaces: *merged - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml deleted file mode 100644 index 16400126ab..0000000000 --- a/test/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml +++ /dev/null @@ -1,49 +0,0 @@ ---- -- debug: - msg: "START vyos_lldp_interfaces overridden integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate_intf.yaml - -- block: - - name: Overrides all device configuration with provided configuration - vyos_lldp_interfaces: &overridden - config: - - name: 'eth2' - location: - elin: '0000000911' - state: overridden - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ populate_intf | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that correct commands were generated - assert: - that: - - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts were correctly generated - assert: - that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Overrides all device configuration with provided configurations (IDEMPOTENT) - vyos_lldp_interfaces: *overridden - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml deleted file mode 100644 index 028aa5e37e..0000000000 --- a/test/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml +++ /dev/null @@ -1,63 +0,0 @@ ---- -- debug: - msg: "START vyos_lldp_interfaces replaced integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Replace device configurations of listed LLDP interfaces with provided configurations - vyos_lldp_interfaces: &replaced - config: - - name: 'eth2' - enable: false - location: - civic_based: - country_code: 'US' - ca_info: - - ca_type: 0 - ca_value: 'ENGLISH' - - - name: 'eth1' - enable: false - location: - coordinate_based: - altitude: 2200 - datum: 'WGS84' - longitude: '222.267255W' - latitude: '33.524449N' - state: replaced - register: result - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that before dicts are correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that after dict is correctly generated - assert: - that: - - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Replace device configurations of listed LLDP interfaces with provided configurarions (IDEMPOTENT) - vyos_lldp_interfaces: *replaced - register: result - - - name: Assert that task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dict is correctly generated - assert: - that: - - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml deleted file mode 100644 index 942e2d0210..0000000000 --- a/test/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml +++ /dev/null @@ -1,57 +0,0 @@ ---- -- debug: - msg: "START vyos_lldp_interfaces round trip integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- block: - - name: Apply the provided configuration (base config) - vyos_lldp_interfaces: - config: - - name: 'eth1' - location: - civic_based: - country_code: 'US' - ca_info: - - ca_type: 0 - ca_value: 'ENGLISH' - - state: merged - register: base_config - - - name: Gather lldp_interfaces facts - vyos_facts: - gather_subset: - - default - gather_network_resources: - - lldp_interfaces - - - name: Apply the provided configuration (config to be reverted) - vyos_lldp_interfaces: - config: - - name: 'eth2' - location: - coordinate_based: - altitude: 2200 - datum: 'WGS84' - longitude: '222.267255W' - latitude: '33.524449N' - state: merged - register: result - - - name: Assert that changes were applied - assert: - that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Revert back to base config using facts round trip - vyos_lldp_interfaces: - config: "{{ ansible_facts['network_resources']['lldp_interfaces'] }}" - state: overridden - register: revert - - - name: Assert that config was reverted - assert: - that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_lldp_interfaces/vars/main.yaml b/test/integration/targets/vyos_lldp_interfaces/vars/main.yaml deleted file mode 100644 index 169b0d5d4a..0000000000 --- a/test/integration/targets/vyos_lldp_interfaces/vars/main.yaml +++ /dev/null @@ -1,130 +0,0 @@ ---- -merged: - before: [] - - - commands: - - "set service lldp interface eth1 location civic-based country-code 'US'" - - "set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH'" - - "set service lldp interface eth1" - - "set service lldp interface eth2 location coordinate-based latitude '33.524449N'" - - "set service lldp interface eth2 location coordinate-based altitude '2200'" - - "set service lldp interface eth2 location coordinate-based datum 'WGS84'" - - "set service lldp interface eth2 location coordinate-based longitude '222.267255W'" - - "set service lldp interface eth2 location coordinate-based latitude '33.524449N'" - - "set service lldp interface eth2 location coordinate-based altitude '2200'" - - "set service lldp interface eth2 location coordinate-based datum 'WGS84'" - - "set service lldp interface eth2 location coordinate-based longitude '222.267255W'" - - "set service lldp interface eth2" - - after: - - name: 'eth1' - location: - civic_based: - country_code: 'US' - ca_info: - - ca_type: 0 - ca_value: 'ENGLISH' - - - name: 'eth2' - location: - coordinate_based: - altitude: 2200 - datum: 'WGS84' - longitude: '222.267255W' - latitude: '33.524449N' - -populate: - - name: 'eth1' - location: - civic_based: - country_code: 'US' - ca_info: - - ca_type: 0 - ca_value: 'ENGLISH' - - - name: 'eth2' - location: - coordinate_based: - altitude: 2200 - datum: 'WGS84' - longitude: '222.267255W' - latitude: '33.524449N' - -replaced: - commands: - - "delete service lldp interface eth2 location" - - "set service lldp interface eth2 'disable'" - - "set service lldp interface eth2 location civic-based country-code 'US'" - - "set service lldp interface eth2 location civic-based ca-type 0 ca-value 'ENGLISH'" - - "delete service lldp interface eth1 location" - - "set service lldp interface eth1 'disable'" - - "set service lldp interface eth1 location coordinate-based latitude '33.524449N'" - - "set service lldp interface eth1 location coordinate-based altitude '2200'" - - "set service lldp interface eth1 location coordinate-based datum 'WGS84'" - - "set service lldp interface eth1 location coordinate-based longitude '222.267255W'" - - after: - - name: 'eth2' - enable: false - location: - civic_based: - country_code: 'US' - ca_info: - - ca_type: 0 - ca_value: 'ENGLISH' - - - name: 'eth1' - enable: false - location: - coordinate_based: - altitude: 2200 - datum: 'WGS84' - longitude: '222.267255W' - latitude: '33.524449N' - -populate_intf: - - name: 'eth2' - enable: false - location: - civic_based: - country_code: 'US' - ca_info: - - ca_type: 0 - ca_value: 'ENGLISH' - -overridden: - commands: - - "delete service lldp interface eth2 location" - - "delete service lldp interface eth2 'disable'" - - "set service lldp interface eth2 location elin '0000000911'" - - after: - - name: 'eth2' - location: - elin: 0000000911 - -deleted: - commands: - - "delete service lldp interface eth1" - - "delete service lldp interface eth2" - - after: [] - -round_trip: - after: - - name: 'eth1' - location: - civic_based: - country_code: 'US' - ca_info: - - ca_type: 0 - ca_value: 'ENGLISH' - - - name: 'eth2' - location: - coordinate_based: - altitude: 2200 - datum: 'WGS84' - longitude: '222.267255W' - latitude: '33.524449N' diff --git a/test/integration/targets/vyos_logging/aliases b/test/integration/targets/vyos_logging/aliases deleted file mode 100644 index 8071e1f75b..0000000000 --- a/test/integration/targets/vyos_logging/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/vyos/group1 diff --git a/test/integration/targets/vyos_logging/defaults/main.yaml b/test/integration/targets/vyos_logging/defaults/main.yaml deleted file mode 100644 index 9ef5ba5165..0000000000 --- a/test/integration/targets/vyos_logging/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_logging/tasks/cli.yaml b/test/integration/targets/vyos_logging/tasks/cli.yaml deleted file mode 100644 index 890d3acf3e..0000000000 --- a/test/integration/targets/vyos_logging/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_logging/tasks/main.yaml b/test/integration/targets/vyos_logging/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_logging/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_logging/tests/cli/basic.yaml b/test/integration/targets/vyos_logging/tests/cli/basic.yaml deleted file mode 100644 index d8a1014b5f..0000000000 --- a/test/integration/targets/vyos_logging/tests/cli/basic.yaml +++ /dev/null @@ -1,126 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: set-up logging - vyos_logging: - dest: console - facility: all - level: info - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set system syslog console facility all level info" in result.commands' - -- name: set-up logging again (idempotent) - vyos_logging: - dest: console - facility: all - level: info - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: file logging - vyos_logging: - dest: file - name: test - facility: all - level: notice - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set system syslog file test facility all level notice" in result.commands' - -- name: file logging again (idempotent) - vyos_logging: - dest: file - name: test - facility: all - level: notice - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: delete logging - vyos_logging: - dest: file - name: test - facility: all - level: notice - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete system syslog file test facility all level notice" in result.commands' - -- name: delete logging again (idempotent) - vyos_logging: - dest: file - name: test - facility: all - level: notice - state: absent - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Add logging collections - vyos_logging: - aggregate: - - {dest: file, name: test1, facility: all, level: info} - - {dest: file, name: test2, facility: news, level: debug} - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set system syslog file test1 facility all level info" in result.commands' - - '"set system syslog file test2 facility news level debug" in result.commands' - -- name: Add and remove logging collections with overrides - vyos_logging: - aggregate: - - {dest: console, facility: all, level: info} - - {dest: file, name: test1, facility: all, level: info, state: absent} - - {dest: console, facility: daemon, level: warning} - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete system syslog file test1 facility all level info" in result.commands' - - '"set system syslog console facility daemon level warning" in result.commands' - -- name: Remove logging collections - vyos_logging: - aggregate: - - {dest: console, facility: all, level: info} - - {dest: console, facility: daemon, level: warning} - - {dest: file, name: test2, facility: news, level: debug} - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete system syslog console facility all level info" in result.commands' - - '"delete system syslog console facility daemon level warning" in result.commands' - - '"delete system syslog file test2 facility news level debug" in result.commands' diff --git a/test/integration/targets/vyos_logging/tests/cli/net_logging.yaml b/test/integration/targets/vyos_logging/tests/cli/net_logging.yaml deleted file mode 100644 index 7c62d72f23..0000000000 --- a/test/integration/targets/vyos_logging/tests/cli/net_logging.yaml +++ /dev/null @@ -1,39 +0,0 @@ ---- -- debug: msg="START vyos cli/net_logging.yaml on connection={{ ansible_connection }}" - -# Add minimal testcase to check args are passed correctly to -# implementation module and module run is successful. - -- name: delete logging - setup - net_logging: - dest: file - name: test - facility: all - level: notice - state: absent - register: result - -- name: file logging using platform agnostic module - net_logging: - dest: file - name: test - facility: all - level: notice - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set system syslog file test facility all level notice" in result.commands' - -- name: delete logging - teardown - net_logging: - dest: file - name: test - facility: all - level: notice - state: absent - register: result - -- debug: msg="END vyos cli/net_logging.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_smoke/defaults/main.yaml b/test/integration/targets/vyos_smoke/defaults/main.yaml deleted file mode 100644 index 9ef5ba5165..0000000000 --- a/test/integration/targets/vyos_smoke/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_smoke/tasks/cli.yaml b/test/integration/targets/vyos_smoke/tasks/cli.yaml deleted file mode 100644 index 890d3acf3e..0000000000 --- a/test/integration/targets/vyos_smoke/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_smoke/tasks/main.yaml b/test/integration/targets/vyos_smoke/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_smoke/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_smoke/tests/cli/common_config.yaml b/test/integration/targets/vyos_smoke/tests/cli/common_config.yaml deleted file mode 100644 index 8cbab2daf2..0000000000 --- a/test/integration/targets/vyos_smoke/tests/cli/common_config.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -# vyos.py in plugins and module_utils/network covered by these as well -# hit NetworkConfig -- name: configure simple config command - vyos_config: - lines: set system host-name smoke - -- name: return host name to inventory_hostname - vyos_config: - lines: set system host-name {{ inventory_hostname_short }} - match: none diff --git a/test/integration/targets/vyos_smoke/tests/cli/common_utils.yaml b/test/integration/targets/vyos_smoke/tests/cli/common_utils.yaml deleted file mode 100644 index f1fe144ba9..0000000000 --- a/test/integration/targets/vyos_smoke/tests/cli/common_utils.yaml +++ /dev/null @@ -1,50 +0,0 @@ ---- -# vyos.py in plugins and module_utils/network covered by these as well -# remove_default_spec() hit by multiple plays - -# hit ComplexList -- name: get output for single command - vyos_command: - commands: - - show version - register: result - -- assert: - that: - - result.changed == false - - result.stdout is defined - - result.stdout_lines is defined - -# hit conditional() - used for declarative intent -# Note, this can't be run on AWS because fully testing the vyos_interface dependencies -# requires the ability to create and remove interfaces other than eth0 -- name: enable eth1 - vyos_interface: - name: eth1 - enabled: true - state: present - register: result - -- name: Check intent arguments - vyos_interface: - name: eth1 - state: up - register: result - -- name: Check intent arguments (failed condition) - vyos_interface: - name: eth1 - state: down - ignore_errors: true - register: result - -- assert: - that: - - "result.failed == true" - - "'state eq(down)' in result.failed_conditions" - -- name: Config + intent - vyos_interface: - name: eth1 - enabled: false - state: down diff --git a/test/integration/targets/vyos_smoke/tests/cli/misc_tests.yaml b/test/integration/targets/vyos_smoke/tests/cli/misc_tests.yaml deleted file mode 100644 index 4dfa29076a..0000000000 --- a/test/integration/targets/vyos_smoke/tests/cli/misc_tests.yaml +++ /dev/null @@ -1,14 +0,0 @@ ---- -# hit check conditional in module_utils.network.vyos -> load_config() -- name: configure simple config command - vyos_config: - lines: set system host-name check-test - check_mode: true - -- name: get host name - vyos_command: - commands: show host name - register: result - -- assert: - that: '"check-test" not in result.stdout' diff --git a/test/integration/targets/vyos_static_route/aliases b/test/integration/targets/vyos_static_route/aliases deleted file mode 100644 index 8071e1f75b..0000000000 --- a/test/integration/targets/vyos_static_route/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/vyos/group1 diff --git a/test/integration/targets/vyos_static_route/defaults/main.yaml b/test/integration/targets/vyos_static_route/defaults/main.yaml deleted file mode 100644 index 9ef5ba5165..0000000000 --- a/test/integration/targets/vyos_static_route/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_static_route/tasks/cli.yaml b/test/integration/targets/vyos_static_route/tasks/cli.yaml deleted file mode 100644 index 890d3acf3e..0000000000 --- a/test/integration/targets/vyos_static_route/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_static_route/tasks/main.yaml b/test/integration/targets/vyos_static_route/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_static_route/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_static_route/tests/cli/basic.yaml b/test/integration/targets/vyos_static_route/tests/cli/basic.yaml deleted file mode 100644 index 2aa69a4483..0000000000 --- a/test/integration/targets/vyos_static_route/tests/cli/basic.yaml +++ /dev/null @@ -1,120 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: create static route - vyos_static_route: - prefix: 172.24.0.0/24 - next_hop: 192.168.42.64 - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set protocols static route 172.24.0.0/24 next-hop 192.168.42.64" in result.commands' - -- name: create static route again (idempotent) - vyos_static_route: - prefix: 172.24.0.0 - mask: 24 - next_hop: 192.168.42.64 - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: modify admin distance of static route - vyos_static_route: - prefix: 172.24.0.0/24 - next_hop: 192.168.42.64 - admin_distance: 1 - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set protocols static route 172.24.0.0/24 next-hop 192.168.42.64 distance 1" in result.commands' - -- name: modify admin distance of static route again (idempotent) - vyos_static_route: - prefix: 172.24.0.0 - mask: 24 - next_hop: 192.168.42.64 - admin_distance: 1 - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: delete static route - vyos_static_route: - prefix: 172.24.0.0/24 - next_hop: 192.168.42.64 - admin_distance: 1 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete protocols static route 172.24.0.0/24" in result.commands' - -- name: delete static route again (idempotent) - vyos_static_route: - prefix: 172.24.0.0/24 - next_hop: 192.168.42.64 - admin_distance: 1 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Add static route collections - vyos_static_route: - aggregate: - - {prefix: 172.24.1.0/24, next_hop: 192.168.42.64} - - {prefix: 172.24.2.0, mask: 24, next_hop: 192.168.42.64} - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set protocols static route 172.24.1.0/24 next-hop 192.168.42.64" in result.commands' - - '"set protocols static route 172.24.2.0/24 next-hop 192.168.42.64" in result.commands' - -- name: Add and remove static route collections with overrides - vyos_static_route: - aggregate: - - {prefix: 172.24.1.0/24, next_hop: 192.168.42.64} - - {prefix: 172.24.2.0/24, next_hop: 192.168.42.64, state: absent} - - {prefix: 172.24.3.0/24, next_hop: 192.168.42.64} - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete protocols static route 172.24.2.0/24" in result.commands' - - '"set protocols static route 172.24.3.0/24 next-hop 192.168.42.64" in result.commands' - -- name: Remove static route collections - vyos_static_route: - aggregate: - - {prefix: 172.24.1.0/24, next_hop: 192.168.42.64} - - {prefix: 172.24.3.0/24, next_hop: 192.168.42.64} - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete protocols static route 172.24.1.0/24" in result.commands' - - '"delete protocols static route 172.24.3.0/24" in result.commands' diff --git a/test/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml b/test/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml deleted file mode 100644 index e2529ebccd..0000000000 --- a/test/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml +++ /dev/null @@ -1,33 +0,0 @@ ---- -- debug: msg="START vyos cli/net_static_route.yaml on connection={{ ansible_connection }}" - -# Add minimal testcase to check args are passed correctly to -# implementation module and module run is successful. - -- name: delete static route - setup - net_static_route: - prefix: 172.24.0.0/24 - next_hop: 192.168.42.64 - state: absent - register: result - -- name: create static route using platform agnostic module - net_static_route: - prefix: 172.24.0.0/24 - next_hop: 192.168.42.64 - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set protocols static route 172.24.0.0/24 next-hop 192.168.42.64" in result.commands' - -- name: delete static route - teardown - net_static_route: - prefix: 172.24.0.0/24 - next_hop: 192.168.42.64 - state: absent - register: result - -- debug: msg="END vyos cli/net_static_route.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_static_routes/aliases b/test/integration/targets/vyos_static_routes/aliases deleted file mode 100644 index 8071e1f75b..0000000000 --- a/test/integration/targets/vyos_static_routes/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/vyos/group1 diff --git a/test/integration/targets/vyos_static_routes/defaults/main.yaml b/test/integration/targets/vyos_static_routes/defaults/main.yaml deleted file mode 100644 index 164afead28..0000000000 --- a/test/integration/targets/vyos_static_routes/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "[^_].*" -test_items: [] diff --git a/test/integration/targets/vyos_static_routes/meta/main.yaml b/test/integration/targets/vyos_static_routes/meta/main.yaml deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/integration/targets/vyos_static_routes/meta/main.yaml +++ /dev/null diff --git a/test/integration/targets/vyos_static_routes/tasks/cli.yaml b/test/integration/targets/vyos_static_routes/tasks/cli.yaml deleted file mode 100644 index 655e51ee63..0000000000 --- a/test/integration/targets/vyos_static_routes/tasks/cli.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- name: Collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - use_regex: true - 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 (connection=network_cli) - include: "{{ test_case_to_run }}" - vars: - ansible_connection: network_cli - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_static_routes/tasks/main.yaml b/test/integration/targets/vyos_static_routes/tasks/main.yaml deleted file mode 100644 index 415c99d8b1..0000000000 --- a/test/integration/targets/vyos_static_routes/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_static_routes/tests/cli/_parsed_config.cfg b/test/integration/targets/vyos_static_routes/tests/cli/_parsed_config.cfg deleted file mode 100644 index b2ecd4e9c0..0000000000 --- a/test/integration/targets/vyos_static_routes/tests/cli/_parsed_config.cfg +++ /dev/null @@ -1,6 +0,0 @@ -set protocols static route 192.0.2.32/28 next-hop '192.0.2.9' -set protocols static route 192.0.2.32/28 next-hop '192.0.2.10' -set protocols static route 192.0.2.32/28 blackhole -set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' -set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' -set protocols static route6 2001:db8:1000::/36 blackhole distance '2' diff --git a/test/integration/targets/vyos_static_routes/tests/cli/_populate.yaml b/test/integration/targets/vyos_static_routes/tests/cli/_populate.yaml deleted file mode 100644 index c5b02f73eb..0000000000 --- a/test/integration/targets/vyos_static_routes/tests/cli/_populate.yaml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- name: Setup - cli_config: - config: "{{ lines }}" - vars: - lines: | - set protocols static route 192.0.2.32/28 next-hop '192.0.2.10' - set protocols static route 192.0.2.32/28 next-hop '192.0.2.9' - set protocols static route 192.0.2.32/28 blackhole - set protocols static route 192.0.2.32/28 - set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' - set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' - set protocols static route6 2001:db8:1000::/36 blackhole distance '2' - set protocols static route6 2001:db8:1000::/36 diff --git a/test/integration/targets/vyos_static_routes/tests/cli/_remove_config.yaml b/test/integration/targets/vyos_static_routes/tests/cli/_remove_config.yaml deleted file mode 100644 index 026ef4580e..0000000000 --- a/test/integration/targets/vyos_static_routes/tests/cli/_remove_config.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- name: Remove Config - cli_config: - config: "{{ lines }}" - vars: - lines: | - delete protocols static route - delete protocols static route6 diff --git a/test/integration/targets/vyos_static_routes/tests/cli/deleted.yaml b/test/integration/targets/vyos_static_routes/tests/cli/deleted.yaml deleted file mode 100644 index b4bad0cc7c..0000000000 --- a/test/integration/targets/vyos_static_routes/tests/cli/deleted.yaml +++ /dev/null @@ -1,51 +0,0 @@ ---- -- debug: - msg: "Start vyos_static_routes deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate.yaml - -- block: - - name: Delete static route based on destiation. - vyos_static_routes: &deleted_dest - config: - - address_families: - - afi: 'ipv4' - routes: - - dest: '192.0.2.32/28' - - afi: 'ipv6' - routes: - - dest: '2001:db8:1000::/36' - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted_dest['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted_dest['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_static_routes: *deleted_dest - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - "result.commands|length == 0" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted_dest['after'] | symmetric_difference(result['before']) |length == 0 }}" - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_static_routes/tests/cli/deleted_afi.yaml b/test/integration/targets/vyos_static_routes/tests/cli/deleted_afi.yaml deleted file mode 100644 index 3b6c7e017f..0000000000 --- a/test/integration/targets/vyos_static_routes/tests/cli/deleted_afi.yaml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- debug: - msg: "Start vyos_static_routes deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate.yaml - -- block: - - name: Delete static route based on afi. - vyos_static_routes: &deleted_afi - config: - - address_families: - - afi: 'ipv4' - - afi: 'ipv6' - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_static_routes: *deleted_afi - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - "result.commands|length == 0" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['before']) |length == 0 }}" - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_static_routes/tests/cli/deleted_all.yaml b/test/integration/targets/vyos_static_routes/tests/cli/deleted_all.yaml deleted file mode 100644 index 39e3f14413..0000000000 --- a/test/integration/targets/vyos_static_routes/tests/cli/deleted_all.yaml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- debug: - msg: "Start vyos_static_routes deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate.yaml - -- block: - - name: Delete all the static routes. - vyos_static_routes: &deleted_all - config: - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_static_routes: *deleted_all - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - "result.commands|length == 0" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['before']) |length == 0 }}" - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_static_routes/tests/cli/deleted_nh.yaml b/test/integration/targets/vyos_static_routes/tests/cli/deleted_nh.yaml deleted file mode 100644 index 976b384e79..0000000000 --- a/test/integration/targets/vyos_static_routes/tests/cli/deleted_nh.yaml +++ /dev/null @@ -1,55 +0,0 @@ ---- -- debug: - msg: "Start vyos_static_routes deleted integration tests ansible_connection={{ ansible_connection }}" - -- include_tasks: _populate.yaml - -- block: - - name: Delete static route based on next_hop. - vyos_static_routes: &deleted_nh - config: - - address_families: - - afi: 'ipv4' - routes: - - dest: '192.0.2.32/28' - next_hops: - - forward_router_address: '192.0.2.9' - - afi: 'ipv6' - routes: - - dest: '2001:db8:1000::/36' - next_hops: - - forward_router_address: '2001:db8:2000:2::1' - state: deleted - register: result - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated - assert: - that: - - "{{ deleted_nh['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated - assert: - that: - - "{{ deleted_nh['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos_static_routes: *deleted_nh - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result.changed == false" - - "result.commands|length == 0" - - - name: Assert that the before dicts were correctly generated - assert: - that: - - "{{ deleted_nh['after'] | symmetric_difference(result['before']) |length == 0 }}" - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_static_routes/tests/cli/empty_config.yaml b/test/integration/targets/vyos_static_routes/tests/cli/empty_config.yaml deleted file mode 100644 index 96bec582a5..0000000000 --- a/test/integration/targets/vyos_static_routes/tests/cli/empty_config.yaml +++ /dev/null @@ -1,58 +0,0 @@ ---- -- debug: - msg: "START vyos_static_routes empty_config integration tests on connection={{ ansible_connection }}" - -- name: Merged with empty config should give appropriate error message - vyos_static_routes: - config: - state: merged - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state merged' - -- name: Replaced with empty config should give appropriate error message - vyos_static_routes: - config: - state: replaced - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state replaced' - -- name: Overridden with empty config should give appropriate error message - vyos_static_routes: - config: - state: overridden - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state overridden' - -- name: Parsed with empty running_config should give appropriate error message - vyos_static_routes: - running_config: - state: parsed - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of running_config parameter must not be empty for state parsed' - -- name: Rendered with empty config should give appropriate error message - vyos_static_routes: - config: - state: rendered - register: result - ignore_errors: true - -- assert: - that: - - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/test/integration/targets/vyos_static_routes/tests/cli/gathered.yaml b/test/integration/targets/vyos_static_routes/tests/cli/gathered.yaml deleted file mode 100644 index 58a4279ec2..0000000000 --- a/test/integration/targets/vyos_static_routes/tests/cli/gathered.yaml +++ /dev/null @@ -1,31 +0,0 @@ ---- -- debug: - msg: "START vyos_static_routes gathered integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Merge the provided configuration with the exisiting running configuration - vyos_static_routes: &gathered - config: - state: gathered - register: result - - - name: Assert that gathered dicts was correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['gathered']) |length == 0 }}" - - - name: Gather the existing running configuration (IDEMPOTENT) - vyos_static_routes: *gathered - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_static_routes/tests/cli/merged.yaml b/test/integration/targets/vyos_static_routes/tests/cli/merged.yaml deleted file mode 100644 index e9399ad77b..0000000000 --- a/test/integration/targets/vyos_static_routes/tests/cli/merged.yaml +++ /dev/null @@ -1,61 +0,0 @@ ---- -- debug: - msg: "START vyos_static_routes merged integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- block: - - name: Merge the provided configuration with the exisiting running configuration - vyos_static_routes: &merged - config: - - address_families: - - afi: 'ipv4' - routes: - - dest: 192.0.2.32/28 - blackhole_config: - type: 'blackhole' - next_hops: - - forward_router_address: 192.0.2.10 - - forward_router_address: 192.0.2.9 - - address_families: - - afi: 'ipv6' - routes: - - dest: 2001:db8:1000::/36 - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: 2001:db8:2000:2::1 - - forward_router_address: 2001:db8:2000:2::2 - state: merged - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts was correctly generated - assert: - that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) - vyos_static_routes: *merged - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_static_routes/tests/cli/overridden.yaml b/test/integration/targets/vyos_static_routes/tests/cli/overridden.yaml deleted file mode 100644 index 9e838d7bcf..0000000000 --- a/test/integration/targets/vyos_static_routes/tests/cli/overridden.yaml +++ /dev/null @@ -1,52 +0,0 @@ ---- -- debug: - msg: "START vyos_static_routes overridden integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Overrides all device configuration with provided configuration - vyos_static_routes: &overridden - config: - - address_families: - - afi: 'ipv4' - routes: - - dest: 198.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.18 - state: overridden - register: result - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that correct commands were generated - assert: - that: - - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that after dicts were correctly generated - assert: - that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Overrides all device configuration with provided configurations (IDEMPOTENT) - vyos_static_routes: *overridden - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dicts were correctly generated - assert: - that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_static_routes/tests/cli/parsed.yaml b/test/integration/targets/vyos_static_routes/tests/cli/parsed.yaml deleted file mode 100644 index 18e5781e71..0000000000 --- a/test/integration/targets/vyos_static_routes/tests/cli/parsed.yaml +++ /dev/null @@ -1,39 +0,0 @@ ---- -- debug: - msg: "START vyos_static_routes parsed integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Gather static_routes facts - vyos_facts: - gather_subset: - - default - gather_network_resources: - - static_routes - register: static_routes_facts - - - name: Provide the running configuration for parsing (config to be parsed) - vyos_static_routes: &parsed - running_config: - "{{ lookup('file', '_parsed_config.cfg') }}" - state: parsed - register: result - - - name: Assert that correct parsing done - assert: - that: "{{ ansible_facts['network_resources']['static_routes'] | symmetric_difference(result['parsed']) |length == 0 }}" - - - name: Gather the existing running configuration (IDEMPOTENT) - vyos_static_routes: *parsed - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_static_routes/tests/cli/rendered.yaml b/test/integration/targets/vyos_static_routes/tests/cli/rendered.yaml deleted file mode 100644 index 80b90ebe5a..0000000000 --- a/test/integration/targets/vyos_static_routes/tests/cli/rendered.yaml +++ /dev/null @@ -1,49 +0,0 @@ ---- -- debug: - msg: "START vyos_static_routes rendered integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Structure provided configuration into device specific commands - vyos_static_routes: &rendered - config: - - address_families: - - afi: 'ipv4' - routes: - - dest: 192.0.2.32/28 - blackhole_config: - type: 'blackhole' - next_hops: - - forward_router_address: 192.0.2.10 - - forward_router_address: 192.0.2.9 - - address_families: - - afi: 'ipv6' - routes: - - dest: 2001:db8:1000::/36 - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: 2001:db8:2000:2::1 - - forward_router_address: 2001:db8:2000:2::2 - state: rendered - register: result - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" - - - name: Structure provided configuration into device specific commands (IDEMPOTENT) - vyos_static_routes: *rendered - register: result - - - name: Assert that the previous task was idempotent - assert: - that: - - "result['changed'] == false" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_static_routes/tests/cli/replaced.yaml b/test/integration/targets/vyos_static_routes/tests/cli/replaced.yaml deleted file mode 100644 index 1daf406945..0000000000 --- a/test/integration/targets/vyos_static_routes/tests/cli/replaced.yaml +++ /dev/null @@ -1,56 +0,0 @@ ---- -- debug: - msg: "START vyos_static_routes replaced integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - name: Replace device configurations of listed static routes with provided configurations - vyos_static_routes: &replaced - config: - - address_families: - - afi: 'ipv4' - routes: - - dest: 192.0.2.32/28 - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: 192.0.2.7 - - forward_router_address: 192.0.2.8 - - forward_router_address: 192.0.2.9 - state: replaced - register: result - - - name: Assert that correct set of commands were generated - assert: - that: - - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that before dicts are correctly generated - assert: - that: - - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that after dict is correctly generated - assert: - that: - - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Replace device configurations of listed static routes with provided configurarions (IDEMPOTENT) - vyos_static_routes: *replaced - register: result - - - name: Assert that task was idempotent - assert: - that: - - "result['changed'] == false" - - - name: Assert that before dict is correctly generated - assert: - that: - - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_static_routes/tests/cli/rtt.yaml b/test/integration/targets/vyos_static_routes/tests/cli/rtt.yaml deleted file mode 100644 index 81ece8b383..0000000000 --- a/test/integration/targets/vyos_static_routes/tests/cli/rtt.yaml +++ /dev/null @@ -1,71 +0,0 @@ ---- -- debug: - msg: "START vyos_static_routes round trip integration tests on connection={{ ansible_connection }}" - -- include_tasks: _remove_config.yaml - -- block: - - name: Apply the provided configuration (base config) - vyos_static_routes: - config: - - address_families: - - afi: 'ipv4' - routes: - - dest: 192.0.2.32/28 - blackhole_config: - type: 'blackhole' - next_hops: - - forward_router_address: 192.0.2.10 - - forward_router_address: 192.0.2.9 - - address_families: - - afi: 'ipv6' - routes: - - dest: 2001:db8:1000::/36 - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: 2001:db8:2000:2::1 - - forward_router_address: 2001:db8:2000:2::2 - - state: merged - register: base_config - - - name: Gather static_routes facts - vyos_facts: - gather_subset: - - default - gather_network_resources: - - static_routes - - - name: Apply the provided configuration (config to be reverted) - vyos_static_routes: - config: - - address_families: - - afi: 'ipv4' - routes: - - dest: 192.0.2.32/28 - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: 192.0.2.7 - - forward_router_address: 192.0.2.8 - - forward_router_address: 192.0.2.9 - state: merged - register: result - - - name: Assert that changes were applied - assert: - that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}" - - - name: Revert back to base config using facts round trip - vyos_static_routes: - config: "{{ ansible_facts['network_resources']['static_routes'] }}" - state: overridden - register: revert - - - name: Assert that config was reverted - assert: - that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}" - - always: - - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/vyos_static_routes/vars/main.yaml b/test/integration/targets/vyos_static_routes/vars/main.yaml deleted file mode 100644 index eeed9bbe90..0000000000 --- a/test/integration/targets/vyos_static_routes/vars/main.yaml +++ /dev/null @@ -1,163 +0,0 @@ ---- -merged: - before: [] - - commands: - - "set protocols static route 192.0.2.32/28 next-hop '192.0.2.10'" - - "set protocols static route 192.0.2.32/28 next-hop '192.0.2.9'" - - "set protocols static route 192.0.2.32/28 blackhole" - - "set protocols static route 192.0.2.32/28" - - "set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'" - - "set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'" - - "set protocols static route6 2001:db8:1000::/36 blackhole distance '2'" - - "set protocols static route6 2001:db8:1000::/36" - - after: - - address_families: - - afi: 'ipv4' - routes: - - dest: '192.0.2.32/28' - blackhole_config: - type: 'blackhole' - next_hops: - - forward_router_address: '192.0.2.9' - - forward_router_address: '192.0.2.10' - - afi: 'ipv6' - routes: - - dest: '2001:db8:1000::/36' - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: '2001:db8:2000:2::1' - - forward_router_address: '2001:db8:2000:2::2' - -populate: - - address_families: - - afi: 'ipv4' - routes: - - dest: '192.0.2.32/28' - blackhole_config: - type: 'blackhole' - next_hops: - - forward_router_address: '192.0.2.9' - - forward_router_address: '192.0.2.10' - - afi: 'ipv6' - routes: - - dest: '2001:db8:1000::/36' - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: '2001:db8:2000:2::1' - - forward_router_address: '2001:db8:2000:2::2' - -replaced: - commands: - - "delete protocols static route 192.0.2.32/28 next-hop '192.0.2.10'" - - "set protocols static route 192.0.2.32/28 next-hop '192.0.2.7'" - - "set protocols static route 192.0.2.32/28 next-hop '192.0.2.8'" - - "set protocols static route 192.0.2.32/28 blackhole distance '2'" - - after: - - address_families: - - afi: 'ipv4' - routes: - - dest: 192.0.2.32/28 - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: 192.0.2.7 - - forward_router_address: 192.0.2.8 - - forward_router_address: 192.0.2.9 - - afi: 'ipv6' - routes: - - dest: '2001:db8:1000::/36' - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: '2001:db8:2000:2::1' - - forward_router_address: '2001:db8:2000:2::2' -overridden: - commands: - - "delete protocols static route 192.0.2.32/28" - - "delete protocols static route6 2001:db8:1000::/36" - - "set protocols static route 198.0.2.48/28 next-hop '192.0.2.18'" - - "set protocols static route 198.0.2.48/28" - - after: - - address_families: - - afi: 'ipv4' - routes: - - dest: 198.0.2.48/28 - next_hops: - - forward_router_address: '192.0.2.18' - -rendered: - commands: - - "set protocols static route 192.0.2.32/28 next-hop '192.0.2.10'" - - "set protocols static route 192.0.2.32/28 next-hop '192.0.2.9'" - - "set protocols static route 192.0.2.32/28 blackhole" - - "set protocols static route 192.0.2.32/28" - - "set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'" - - "set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'" - - "set protocols static route6 2001:db8:1000::/36 blackhole distance '2'" - - "set protocols static route6 2001:db8:1000::/36" - -deleted_dest: - - commands: - - "delete protocols static route 192.0.2.32/28" - - "delete protocols static route6 2001:db8:1000::/36" - - after: [] - -deleted_nh: - - commands: - - "delete protocols static route 192.0.2.32/28 next-hop '192.0.2.9'" - - "delete protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'" - - after: - - address_families: - - afi: 'ipv4' - routes: - - dest: '192.0.2.32/28' - blackhole_config: - type: 'blackhole' - next_hops: - - forward_router_address: '192.0.2.10' - - afi: 'ipv6' - routes: - - dest: '2001:db8:1000::/36' - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: '2001:db8:2000:2::2' - -deleted_afi_all: - - commands: - - "delete protocols static route" - - "delete protocols static route6" - after: [] - -round_trip: - after: - - address_families: - - afi: 'ipv4' - routes: - - dest: 192.0.2.32/28 - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: '192.0.2.7' - - forward_router_address: '192.0.2.8' - - forward_router_address: '192.0.2.9' - - forward_router_address: '192.0.2.10' - - afi: 'ipv6' - routes: - - dest: '2001:db8:1000::/36' - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: '2001:db8:2000:2::1' - - forward_router_address: '2001:db8:2000:2::2' diff --git a/test/integration/targets/vyos_system/aliases b/test/integration/targets/vyos_system/aliases deleted file mode 100644 index 8071e1f75b..0000000000 --- a/test/integration/targets/vyos_system/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/vyos/group1 diff --git a/test/integration/targets/vyos_system/defaults/main.yaml b/test/integration/targets/vyos_system/defaults/main.yaml deleted file mode 100644 index 9ef5ba5165..0000000000 --- a/test/integration/targets/vyos_system/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_system/tasks/cli.yaml b/test/integration/targets/vyos_system/tasks/cli.yaml deleted file mode 100644 index 890d3acf3e..0000000000 --- a/test/integration/targets/vyos_system/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_system/tasks/main.yaml b/test/integration/targets/vyos_system/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_system/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_system/tests/cli/basic.yaml b/test/integration/targets/vyos_system/tests/cli/basic.yaml deleted file mode 100644 index c42eddea84..0000000000 --- a/test/integration/targets/vyos_system/tests/cli/basic.yaml +++ /dev/null @@ -1,61 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: setup - vyos_config: - lines: - - delete system name-server 192.0.2.1 - - delete system name-server 192.0.2.2 - - delete system name-server 192.0.2.3 - match: none - -- name: configure name servers - vyos_system: - name_servers: - - 192.0.2.1 - - 192.0.2.2 - - 192.0.2.3 - register: result - -- assert: - that: - - result.changed == true - - result.commands|length == 3 - - result.commands[0] is search("set system name-server '192.0.2.1'") - - result.commands[1] is search("set system name-server '192.0.2.2'") - - result.commands[2] is search("set system name-server '192.0.2.3'") - -- name: verify name_servers - vyos_system: - name_servers: - - 192.0.2.1 - - 192.0.2.2 - - 192.0.2.3 - register: result - -- assert: - that: - - result.changed == false - -- name: remove one - vyos_system: - name_servers: - - 192.0.2.3 - state: absent - register: result - -- assert: - that: - - result.changed == true - - result.commands|length == 1 - - result.commands[0] is search("delete system name-server '192.0.2.3'") - -- name: teardown - vyos_config: - lines: - - delete system name-server name-server 192.0.2.1 - - delete system name-server name-server 192.0.2.2 - - delete system name-server name-server 192.0.2.3 - match: none - -- debug: msg="END cli/basic.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_system/tests/cli/net_system.yaml b/test/integration/targets/vyos_system/tests/cli/net_system.yaml deleted file mode 100644 index b7813c09f0..0000000000 --- a/test/integration/targets/vyos_system/tests/cli/net_system.yaml +++ /dev/null @@ -1,30 +0,0 @@ ---- -- debug: msg="START vyos cli/net_system.yaml on connection={{ ansible_connection }}" - -# Add minimal testcase to check args are passed correctly to -# implementation module and module run is successful. - -- name: setup - vyos_config: - lines: - - delete system name-server 192.0.2.1 - match: none - -- name: configure name servers using platform agnostic module - net_system: - name_servers: - - 192.0.2.1 - register: result - -- assert: - that: - - result.changed == true - - result.commands[0] is search("set system name-server '192.0.2.1'") - -- name: setup - vyos_config: - lines: - - delete system name-server 192.0.2.1 - match: none - -- debug: msg="END vyos cli/net_system.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_user/defaults/main.yaml b/test/integration/targets/vyos_user/defaults/main.yaml deleted file mode 100644 index 9ef5ba5165..0000000000 --- a/test/integration/targets/vyos_user/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_user/tasks/cli.yaml b/test/integration/targets/vyos_user/tasks/cli.yaml deleted file mode 100644 index 890d3acf3e..0000000000 --- a/test/integration/targets/vyos_user/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_user/tasks/main.yaml b/test/integration/targets/vyos_user/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_user/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_user/tests/cli/auth.yaml b/test/integration/targets/vyos_user/tests/cli/auth.yaml deleted file mode 100644 index 1f4609ab5d..0000000000 --- a/test/integration/targets/vyos_user/tests/cli/auth.yaml +++ /dev/null @@ -1,34 +0,0 @@ ---- -- block: - - name: Create user with password - vyos_user: - name: auth_user - role: admin - state: present - configured_password: pass123 - - - name: test login via ssh with new user - expect: - command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper show version'" - responses: - (?i)password: "pass123" - - - name: test login via ssh with invalid password (should fail) - expect: - command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper show version'" - responses: - (?i)password: "badpass" - ignore_errors: true - register: results - - - name: check that attempt failed - assert: - that: - - results.failed - - always: - - name: delete user - vyos_user: - name: auth_user - state: absent - register: result diff --git a/test/integration/targets/vyos_user/tests/cli/basic.yaml b/test/integration/targets/vyos_user/tests/cli/basic.yaml deleted file mode 100644 index 346ecda33a..0000000000 --- a/test/integration/targets/vyos_user/tests/cli/basic.yaml +++ /dev/null @@ -1,77 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: Setup - vyos_config: - lines: - - delete system login user ansibletest1 - - delete system login user ansibletest2 - - delete system login user ansibletest3 - -- name: Create user - vyos_user: - name: ansibletest1 - configured_password: test - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set system login user" in result.commands[0]' - - '"authentication plaintext-password" in result.commands[0]' - -- name: Collection of users (SetUp) - vyos_user: - aggregate: - - name: ansibletest2 - - name: ansibletest3 - level: operator - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - 'result.commands == ["set system login user ansibletest2 level operator", "set system login user ansibletest3 level operator"]' - -- name: Add user again (Idempotent) - vyos_user: - name: ansibletest1 - configured_password: test - state: present - update_password: on_create - register: result - -- assert: - that: - - 'result.changed == false' - - 'result.commands | length == 0' - -- name: Add collection of users (Idempotent) - vyos_user: - aggregate: - - name: ansibletest2 - - name: ansibletest3 - level: operator - state: present - register: result - -- assert: - that: - - 'result.changed == false' - - 'result.commands | length == 0' - -- name: tearDown - vyos_user: - users: - - name: ansibletest1 - - name: ansibletest2 - - name: ansibletest3 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - 'result.commands == ["delete system login user ansibletest1", "delete system login user ansibletest2", "delete system login user ansibletest3"]' diff --git a/test/integration/targets/vyos_vlan/defaults/main.yaml b/test/integration/targets/vyos_vlan/defaults/main.yaml deleted file mode 100644 index 9ef5ba5165..0000000000 --- a/test/integration/targets/vyos_vlan/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_vlan/tasks/cli.yaml b/test/integration/targets/vyos_vlan/tasks/cli.yaml deleted file mode 100644 index 890d3acf3e..0000000000 --- a/test/integration/targets/vyos_vlan/tasks/cli.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- 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 (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - -- name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_vlan/tasks/main.yaml b/test/integration/targets/vyos_vlan/tasks/main.yaml deleted file mode 100644 index d4cf26fc4a..0000000000 --- a/test/integration/targets/vyos_vlan/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- {include: cli.yaml, tags: ['cli']} diff --git a/test/integration/targets/vyos_vlan/tests/cli/basic.yaml b/test/integration/targets/vyos_vlan/tests/cli/basic.yaml deleted file mode 100644 index 7c63478538..0000000000 --- a/test/integration/targets/vyos_vlan/tests/cli/basic.yaml +++ /dev/null @@ -1,101 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: setup - remove vlan used in test - vyos_config: - lines: - - delete interfaces ethernet eth1 vif 100 - - delete interfaces ethernet eth0 vif 5 - - delete interfaces ethernet eth0 vif 100 - - delete interfaces ethernet eth0 vif 101 - - delete interfaces ethernet eth1 vif 201 - -- name: set vlan with name - vyos_vlan: &name - vlan_id: 100 - name: vlan-100 - interfaces: eth1 - register: result - -- assert: - that: - - "result.changed == true" - - "'set interfaces ethernet eth1 vif 100 description vlan-100' in result.commands" - -- name: set vlan with name(idempotence) - vyos_vlan: *name - register: result - -- assert: - that: - - "result.changed == false" - -- name: set vlan with address - vyos_vlan: &address - vlan_id: 5 - address: 192.168.5.12/24 - interfaces: eth0 - register: result - -- assert: - that: - - "result.changed == true" - - "'set interfaces ethernet eth0 vif 5 address 192.168.5.12/24' in result.commands" - -- name: set vlan with address(idempotence) - vyos_vlan: *address - register: result - -- assert: - that: - - "result.changed == false" - -- name: delete - vyos_vlan: &delete - vlan_id: 100 - interfaces: eth1 - state: absent - register: result - -- assert: - that: - - "result.changed == true" - - "'delete interfaces ethernet eth1 vif 100' in result.commands" - -- name: delete(idempotence) - vyos_vlan: *delete - register: result - -- assert: - that: - - "result.changed == false" - -- name: Create VLANs using aggregate - vyos_vlan: &agg_vlan - aggregate: - - {vlan_id: 101, name: voice, interfaces: "eth0"} - - {vlan_id: 201, name: mgm, interfaces: "eth1"} - state: present - register: result - -- assert: - that: - - "result.changed == true" - - "'set interfaces ethernet eth0 vif 101 description voice' in result.commands" - - "'set interfaces ethernet eth1 vif 201 description mgm' in result.commands" - -- name: Create VLANs using aggregate (idempotent) - vyos_vlan: *agg_vlan - register: result - -- assert: - that: - - "result.changed == false" - -- name: teardown - vyos_config: - lines: - - delete interfaces ethernet eth1 vif 100 - - delete interfaces ethernet eth0 vif 5 - - delete interfaces ethernet eth0 vif 101 - - delete interfaces ethernet eth1 vif 201 diff --git a/test/integration/targets/vyos_vlan/tests/cli/intent.yaml b/test/integration/targets/vyos_vlan/tests/cli/intent.yaml deleted file mode 100644 index 16617e9e01..0000000000 --- a/test/integration/targets/vyos_vlan/tests/cli/intent.yaml +++ /dev/null @@ -1,59 +0,0 @@ ---- -- debug: msg="START cli/intent.yaml on connection={{ ansible_connection }}" - -- name: setup - remove vlan used in test - vyos_config: &delete - lines: - - delete interfaces ethernet eth1 vif 100 - - delete interfaces ethernet eth0 vif 100 - -- name: set vlan with name - vyos_vlan: - vlan_id: 100 - name: vlan-100 - interfaces: eth1 - register: result - -- assert: - that: - - "result.changed == true" - - "'set interfaces ethernet eth1 vif 100 description vlan-100' in result.commands" - -- name: check vlan interface intent - vyos_vlan: - vlan_id: 100 - name: vlan-100 - associated_interfaces: eth1 - register: result - -- assert: - that: - - "result.failed == false" - -- name: vlan interface config + intent - vyos_vlan: - vlan_id: 100 - interfaces: eth0 - associated_interfaces: - - eth0 - - eth1 - register: result - -- assert: - that: - - "result.failed == false" - -- name: vlan intent fail - vyos_vlan: - vlan_id: 100 - associated_interfaces: - - eth3 - - eth4 - register: result - ignore_errors: true - -- assert: - that: - - "result.failed == True" - -- debug: msg="End cli/intent.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_vlan/tests/cli/multiple.yaml b/test/integration/targets/vyos_vlan/tests/cli/multiple.yaml deleted file mode 100644 index 25bc1af095..0000000000 --- a/test/integration/targets/vyos_vlan/tests/cli/multiple.yaml +++ /dev/null @@ -1,60 +0,0 @@ ---- -- debug: msg="START cli/multiple.yaml on connection={{ ansible_connection }}" - -- name: setup - remove vlan used in test - vyos_config: - lines: - - delete interfaces ethernet eth0 vif 5 - - delete interfaces ethernet eth0 vif 100 - - delete interfaces ethernet eth1 vif 100 - -- name: Add multiple interfaces to vlan - vyos_vlan: &multiple - vlan_id: 100 - interfaces: - - eth0 - - eth1 - register: result - -- assert: - that: - - "result.changed == true" - - "'set interfaces ethernet eth0 vif 100' in result.commands" - - "'set interfaces ethernet eth1 vif 100' in result.commands" - -- name: Add multiple interfaces to vlan(idempotence) - vyos_vlan: *multiple - register: result - -- assert: - that: - - "result.changed == false" - -- name: delete vlan with multiple interfaces - vyos_vlan: &delete_multiple - vlan_id: 100 - interfaces: - - eth0 - - eth1 - state: absent - register: result - -- assert: - that: - - "result.changed == true" - - "'delete interfaces ethernet eth0 vif 100' in result.commands" - - "'delete interfaces ethernet eth1 vif 100' in result.commands" - -- name: delete vlan with multiple interfaces(idempotence) - vyos_vlan: *delete_multiple - register: result - -- assert: - that: - - "result.changed == false" - -- name: teardown - vyos_config: - lines: - - delete interfaces ethernet eth0 vif 100 - - delete interfaces ethernet eth1 vif 100 diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt index 4220cf3bf6..ade5083a60 100644 --- a/test/sanity/ignore.txt +++ b/test/sanity/ignore.txt @@ -76,8 +76,6 @@ lib/ansible/module_utils/facts/utils.py future-import-boilerplate lib/ansible/module_utils/facts/utils.py metaclass-boilerplate lib/ansible/module_utils/json_utils.py future-import-boilerplate lib/ansible/module_utils/json_utils.py metaclass-boilerplate -lib/ansible/module_utils/network/vyos/vyos.py future-import-boilerplate -lib/ansible/module_utils/network/vyos/vyos.py metaclass-boilerplate lib/ansible/module_utils/parsing/convert_bool.py future-import-boilerplate lib/ansible/module_utils/parsing/convert_bool.py metaclass-boilerplate lib/ansible/module_utils/powershell/Ansible.ModuleUtils.ArgvParser.psm1 pslint:PSUseApprovedVerbs @@ -142,129 +140,6 @@ lib/ansible/modules/net_tools/basics/uri.py pylint:blacklisted-name lib/ansible/modules/net_tools/basics/uri.py validate-modules:doc-required-mismatch lib/ansible/modules/net_tools/basics/uri.py validate-modules:parameter-list-no-elements lib/ansible/modules/net_tools/basics/uri.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/network/vyos/_vyos_interface.py future-import-boilerplate -lib/ansible/modules/network/vyos/_vyos_interface.py metaclass-boilerplate -lib/ansible/modules/network/vyos/_vyos_interface.py validate-modules:doc-choices-do-not-match-spec -lib/ansible/modules/network/vyos/_vyos_interface.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/network/vyos/_vyos_interface.py validate-modules:doc-elements-mismatch -lib/ansible/modules/network/vyos/_vyos_interface.py validate-modules:doc-missing-type -lib/ansible/modules/network/vyos/_vyos_interface.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/_vyos_interface.py validate-modules:missing-suboption-docs -lib/ansible/modules/network/vyos/_vyos_interface.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/network/vyos/_vyos_interface.py validate-modules:undocumented-parameter -lib/ansible/modules/network/vyos/_vyos_l3_interface.py future-import-boilerplate -lib/ansible/modules/network/vyos/_vyos_l3_interface.py metaclass-boilerplate -lib/ansible/modules/network/vyos/_vyos_l3_interface.py validate-modules:doc-choices-do-not-match-spec -lib/ansible/modules/network/vyos/_vyos_l3_interface.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/network/vyos/_vyos_l3_interface.py validate-modules:doc-elements-mismatch -lib/ansible/modules/network/vyos/_vyos_l3_interface.py validate-modules:doc-missing-type -lib/ansible/modules/network/vyos/_vyos_l3_interface.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/_vyos_l3_interface.py validate-modules:missing-suboption-docs -lib/ansible/modules/network/vyos/_vyos_l3_interface.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/network/vyos/_vyos_l3_interface.py validate-modules:undocumented-parameter -lib/ansible/modules/network/vyos/_vyos_linkagg.py future-import-boilerplate -lib/ansible/modules/network/vyos/_vyos_linkagg.py metaclass-boilerplate -lib/ansible/modules/network/vyos/_vyos_linkagg.py validate-modules:doc-choices-do-not-match-spec -lib/ansible/modules/network/vyos/_vyos_linkagg.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/network/vyos/_vyos_linkagg.py validate-modules:doc-elements-mismatch -lib/ansible/modules/network/vyos/_vyos_linkagg.py validate-modules:doc-missing-type -lib/ansible/modules/network/vyos/_vyos_linkagg.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/_vyos_linkagg.py validate-modules:missing-suboption-docs -lib/ansible/modules/network/vyos/_vyos_linkagg.py validate-modules:parameter-list-no-elements -lib/ansible/modules/network/vyos/_vyos_linkagg.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/network/vyos/_vyos_linkagg.py validate-modules:undocumented-parameter -lib/ansible/modules/network/vyos/_vyos_lldp.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/network/vyos/_vyos_lldp.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/_vyos_lldp.py validate-modules:parameter-list-no-elements -lib/ansible/modules/network/vyos/_vyos_lldp_interface.py future-import-boilerplate -lib/ansible/modules/network/vyos/_vyos_lldp_interface.py metaclass-boilerplate -lib/ansible/modules/network/vyos/_vyos_lldp_interface.py validate-modules:doc-choices-do-not-match-spec -lib/ansible/modules/network/vyos/_vyos_lldp_interface.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/network/vyos/_vyos_lldp_interface.py validate-modules:doc-elements-mismatch -lib/ansible/modules/network/vyos/_vyos_lldp_interface.py validate-modules:doc-missing-type -lib/ansible/modules/network/vyos/_vyos_lldp_interface.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/_vyos_lldp_interface.py validate-modules:missing-suboption-docs -lib/ansible/modules/network/vyos/_vyos_lldp_interface.py validate-modules:undocumented-parameter -lib/ansible/modules/network/vyos/_vyos_static_route.py future-import-boilerplate -lib/ansible/modules/network/vyos/_vyos_static_route.py metaclass-boilerplate -lib/ansible/modules/network/vyos/_vyos_static_route.py validate-modules:doc-choices-do-not-match-spec -lib/ansible/modules/network/vyos/_vyos_static_route.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/network/vyos/_vyos_static_route.py validate-modules:doc-elements-mismatch -lib/ansible/modules/network/vyos/_vyos_static_route.py validate-modules:doc-missing-type -lib/ansible/modules/network/vyos/_vyos_static_route.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/_vyos_static_route.py validate-modules:missing-suboption-docs -lib/ansible/modules/network/vyos/_vyos_static_route.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/network/vyos/_vyos_static_route.py validate-modules:undocumented-parameter -lib/ansible/modules/network/vyos/vyos_banner.py future-import-boilerplate -lib/ansible/modules/network/vyos/vyos_banner.py metaclass-boilerplate -lib/ansible/modules/network/vyos/vyos_banner.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/network/vyos/vyos_banner.py validate-modules:doc-missing-type -lib/ansible/modules/network/vyos/vyos_banner.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/vyos_command.py future-import-boilerplate -lib/ansible/modules/network/vyos/vyos_command.py metaclass-boilerplate -lib/ansible/modules/network/vyos/vyos_command.py pylint:blacklisted-name -lib/ansible/modules/network/vyos/vyos_command.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/network/vyos/vyos_command.py validate-modules:doc-missing-type -lib/ansible/modules/network/vyos/vyos_command.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/vyos_command.py validate-modules:parameter-list-no-elements -lib/ansible/modules/network/vyos/vyos_command.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/network/vyos/vyos_config.py future-import-boilerplate -lib/ansible/modules/network/vyos/vyos_config.py metaclass-boilerplate -lib/ansible/modules/network/vyos/vyos_config.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/network/vyos/vyos_config.py validate-modules:doc-missing-type -lib/ansible/modules/network/vyos/vyos_config.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/vyos_config.py validate-modules:parameter-list-no-elements -lib/ansible/modules/network/vyos/vyos_config.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/network/vyos/vyos_facts.py future-import-boilerplate -lib/ansible/modules/network/vyos/vyos_facts.py metaclass-boilerplate -lib/ansible/modules/network/vyos/vyos_facts.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/network/vyos/vyos_facts.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/vyos_facts.py validate-modules:parameter-list-no-elements -lib/ansible/modules/network/vyos/vyos_facts.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/network/vyos/vyos_interfaces.py validate-modules:doc-elements-mismatch -lib/ansible/modules/network/vyos/vyos_lag_interfaces.py validate-modules:doc-elements-mismatch -lib/ansible/modules/network/vyos/vyos_lag_interfaces.py validate-modules:parameter-list-no-elements -lib/ansible/modules/network/vyos/vyos_lldp_global.py validate-modules:parameter-list-no-elements -lib/ansible/modules/network/vyos/vyos_lldp_interfaces.py validate-modules:doc-elements-mismatch -lib/ansible/modules/network/vyos/vyos_lldp_interfaces.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/vyos_logging.py future-import-boilerplate -lib/ansible/modules/network/vyos/vyos_logging.py metaclass-boilerplate -lib/ansible/modules/network/vyos/vyos_logging.py validate-modules:doc-choices-do-not-match-spec -lib/ansible/modules/network/vyos/vyos_logging.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/network/vyos/vyos_logging.py validate-modules:doc-elements-mismatch -lib/ansible/modules/network/vyos/vyos_logging.py validate-modules:doc-missing-type -lib/ansible/modules/network/vyos/vyos_logging.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/vyos_logging.py validate-modules:missing-suboption-docs -lib/ansible/modules/network/vyos/vyos_logging.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/network/vyos/vyos_logging.py validate-modules:undocumented-parameter -lib/ansible/modules/network/vyos/vyos_ping.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/network/vyos/vyos_ping.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/vyos_ping.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/network/vyos/vyos_system.py future-import-boilerplate -lib/ansible/modules/network/vyos/vyos_system.py metaclass-boilerplate -lib/ansible/modules/network/vyos/vyos_system.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/network/vyos/vyos_system.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/vyos_system.py validate-modules:parameter-list-no-elements -lib/ansible/modules/network/vyos/vyos_system.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/network/vyos/vyos_user.py future-import-boilerplate -lib/ansible/modules/network/vyos/vyos_user.py metaclass-boilerplate -lib/ansible/modules/network/vyos/vyos_user.py validate-modules:doc-choices-do-not-match-spec -lib/ansible/modules/network/vyos/vyos_user.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/network/vyos/vyos_user.py validate-modules:doc-elements-mismatch -lib/ansible/modules/network/vyos/vyos_user.py validate-modules:doc-missing-type -lib/ansible/modules/network/vyos/vyos_user.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/vyos_user.py validate-modules:missing-suboption-docs -lib/ansible/modules/network/vyos/vyos_user.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/network/vyos/vyos_user.py validate-modules:undocumented-parameter -lib/ansible/modules/network/vyos/vyos_vlan.py validate-modules:doc-choices-do-not-match-spec -lib/ansible/modules/network/vyos/vyos_vlan.py validate-modules:doc-default-does-not-match-spec -lib/ansible/modules/network/vyos/vyos_vlan.py validate-modules:doc-elements-mismatch -lib/ansible/modules/network/vyos/vyos_vlan.py validate-modules:doc-missing-type -lib/ansible/modules/network/vyos/vyos_vlan.py validate-modules:doc-required-mismatch -lib/ansible/modules/network/vyos/vyos_vlan.py validate-modules:missing-suboption-docs -lib/ansible/modules/network/vyos/vyos_vlan.py validate-modules:parameter-list-no-elements -lib/ansible/modules/network/vyos/vyos_vlan.py validate-modules:parameter-type-not-in-doc -lib/ansible/modules/network/vyos/vyos_vlan.py validate-modules:undocumented-parameter lib/ansible/modules/packaging/language/pip.py pylint:blacklisted-name lib/ansible/modules/packaging/language/pip.py validate-modules:doc-elements-mismatch lib/ansible/modules/packaging/language/pip.py validate-modules:invalid-ansiblemodule-schema @@ -360,7 +235,6 @@ lib/ansible/playbook/collectionsearch.py required-and-default-attributes # http lib/ansible/playbook/helpers.py pylint:blacklisted-name lib/ansible/playbook/role/__init__.py pylint:blacklisted-name lib/ansible/plugins/action/normal.py action-plugin-docs # default action plugin for modules without a dedicated action plugin -lib/ansible/plugins/action/vyos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` lib/ansible/plugins/cache/base.py ansible-doc!skip # not a plugin, but a stub for backwards compatibility lib/ansible/plugins/doc_fragments/backup.py future-import-boilerplate lib/ansible/plugins/doc_fragments/backup.py metaclass-boilerplate @@ -384,8 +258,6 @@ lib/ansible/plugins/doc_fragments/url.py future-import-boilerplate lib/ansible/plugins/doc_fragments/url.py metaclass-boilerplate lib/ansible/plugins/doc_fragments/validate.py future-import-boilerplate lib/ansible/plugins/doc_fragments/validate.py metaclass-boilerplate -lib/ansible/plugins/doc_fragments/vyos.py future-import-boilerplate -lib/ansible/plugins/doc_fragments/vyos.py metaclass-boilerplate lib/ansible/plugins/lookup/sequence.py pylint:blacklisted-name lib/ansible/plugins/strategy/__init__.py pylint:blacklisted-name lib/ansible/plugins/strategy/linear.py pylint:blacklisted-name diff --git a/test/units/modules/network/vyos/fixtures/show_host_name b/test/units/modules/network/vyos/fixtures/show_host_name deleted file mode 100644 index e89bc06462..0000000000 --- a/test/units/modules/network/vyos/fixtures/show_host_name +++ /dev/null @@ -1 +0,0 @@ -vyos01 diff --git a/test/units/modules/network/vyos/fixtures/show_version b/test/units/modules/network/vyos/fixtures/show_version deleted file mode 100644 index a015d554eb..0000000000 --- a/test/units/modules/network/vyos/fixtures/show_version +++ /dev/null @@ -1,14 +0,0 @@ -Version: VyOS 1.1.7 -Description: VyOS 1.1.7 (helium) -Copyright: 2016 VyOS maintainers and contributors -Built by: maintainers@vyos.net -Built on: Wed Feb 17 09:57:31 UTC 2016 -Build ID: 1602170957-4459750 -System type: x86 64-bit -Boot via: image -Hypervisor: VMware -HW model: VMware Virtual Platform -HW S/N: VMware-42 3c 26 25 44 c5 0a 91-cf 2c 97 2b fe 9b 25 be -HW UUID: 423C2625-44C5-0A91-CF2C-972BFE9B25BE -Uptime: 01:08:20 up 52 days, 2:13, 1 user, load average: 0.00, 0.01, 0.05 - diff --git a/test/units/modules/network/vyos/fixtures/vyos_config_config.cfg b/test/units/modules/network/vyos/fixtures/vyos_config_config.cfg deleted file mode 100644 index fcef8ebdda..0000000000 --- a/test/units/modules/network/vyos/fixtures/vyos_config_config.cfg +++ /dev/null @@ -1,10 +0,0 @@ -set system host-name 'router' -set system domain-name 'example.com' -set system domain-search domain 'example.com' -set system name-server '8.8.8.8' -set system name-server '8.8.4.4' -set interfaces ethernet eth0 address '1.2.3.4/24' -set interfaces ethernet eth0 description 'test string' -set interfaces ethernet eth1 address '6.7.8.9/24' -set interfaces ethernet eth1 description 'test string' -set interfaces ethernet eth1 disable diff --git a/test/units/modules/network/vyos/fixtures/vyos_config_src.cfg b/test/units/modules/network/vyos/fixtures/vyos_config_src.cfg deleted file mode 100644 index 410f6115fc..0000000000 --- a/test/units/modules/network/vyos/fixtures/vyos_config_src.cfg +++ /dev/null @@ -1,6 +0,0 @@ -set system host-name foo - -delete interfaces ethernet eth0 address -set interfaces ethernet eth1 address '6.7.8.9/24' - set interfaces ethernet eth1 description 'test string' -set interfaces ethernet eth1 disable diff --git a/test/units/modules/network/vyos/fixtures/vyos_config_src_brackets.cfg b/test/units/modules/network/vyos/fixtures/vyos_config_src_brackets.cfg deleted file mode 100644 index 468b32c268..0000000000 --- a/test/units/modules/network/vyos/fixtures/vyos_config_src_brackets.cfg +++ /dev/null @@ -1,13 +0,0 @@ -interfaces { - ethernet eth0 { - address 10.10.10.10/24 - } - ethernet eth1 { - address 6.7.8.9/24 - description test string - disable - } -} -system { - host-name foo -} diff --git a/test/units/modules/network/vyos/fixtures/vyos_firewall_global_config.cfg b/test/units/modules/network/vyos/fixtures/vyos_firewall_global_config.cfg deleted file mode 100644 index 2a2a8e8bd8..0000000000 --- a/test/units/modules/network/vyos/fixtures/vyos_firewall_global_config.cfg +++ /dev/null @@ -1,6 +0,0 @@ -set firewall group address-group RND-HOSTS address 192.0.2.1 -set firewall group address-group RND-HOSTS address 192.0.2.3 -set firewall group address-group RND-HOSTS address 192.0.2.5 -set firewall group address-group RND-HOSTS description 'This group has the Management hosts address lists' -set firewall group network-group RND network 192.0.2.0/24 -set firewall group network-group RND description 'This group has the Management network addresses' diff --git a/test/units/modules/network/vyos/fixtures/vyos_firewall_interfaces_config.cfg b/test/units/modules/network/vyos/fixtures/vyos_firewall_interfaces_config.cfg deleted file mode 100644 index 24704d2ddf..0000000000 --- a/test/units/modules/network/vyos/fixtures/vyos_firewall_interfaces_config.cfg +++ /dev/null @@ -1,8 +0,0 @@ -set interfaces ethernet eth0 firewall in name 'INBOUND' -set interfaces ethernet eth0 firewall local ipv6-name 'V6-LOCAL' -set interfaces ethernet eth0 firewall local name 'LOCAL' -set interfaces ethernet eth0 firewall out name 'OUTBOUND' -set interfaces ethernet eth2 firewall in name 'INBOUND' -set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL' -set interfaces ethernet eth2 firewall local name 'LOCAL' -set interfaces ethernet eth2 firewall out name 'OUTBOUND' diff --git a/test/units/modules/network/vyos/fixtures/vyos_firewall_rules_config.cfg b/test/units/modules/network/vyos/fixtures/vyos_firewall_rules_config.cfg deleted file mode 100644 index f65b386963..0000000000 --- a/test/units/modules/network/vyos/fixtures/vyos_firewall_rules_config.cfg +++ /dev/null @@ -1,13 +0,0 @@ -set firewall name V4-INGRESS default-action 'accept' -set firewall ipv6-name V6-INGRESS default-action 'accept' -set firewall name V4-INGRESS description 'This is IPv4 V4-INGRESS rule set' -set firewall name V4-INGRESS enable-default-log -set firewall name V4-INGRESS rule 101 protocol 'icmp' -set firewall name V4-INGRESS rule 101 description 'Rule 101 is configured by Ansible' -set firewall name V4-INGRESS rule 101 fragment 'match-frag' -set firewall name V4-INGRESS rule 101 -set firewall name V4-INGRESS rule 101 disabled -set firewall name V4-INGRESS rule 101 action 'accept' -set firewall name V4-INGRESS rule 101 ipsec 'match-ipsec' -set firewall name V4-EGRESS default-action 'reject' -set firewall ipv6-name V6-EGRESS default-action 'reject' diff --git a/test/units/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.10_count_2 b/test/units/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.10_count_2 deleted file mode 100644 index c28fba1583..0000000000 --- a/test/units/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.10_count_2 +++ /dev/null @@ -1,7 +0,0 @@ -PING 10.10.10.10 (10.10.10.10) 56(84) bytes of data. -64 bytes from 10.10.10.10: icmp_req=1 ttl=255 time=1.27 ms -64 bytes from 10.10.10.10: icmp_req=2 ttl=255 time=2.28 ms - ---- 10.8.38.66 ping statistics --- -2 packets transmitted, 2 received, 0% packet loss, time 1001ms -rtt min/avg/max/mdev = 12.1222/17.124/22.225/10.143 ms diff --git a/test/units/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.11_count_10_ttl_128_size_512 b/test/units/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.11_count_10_ttl_128_size_512 deleted file mode 100644 index 54e026c231..0000000000 --- a/test/units/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.11_count_10_ttl_128_size_512 +++ /dev/null @@ -1,15 +0,0 @@ -PING 10.10.10.11 (10.8.38.65) 512(540) bytes of data. -520 bytes from 10.10.10.11: icmp_req=1 ttl=255 time=1.17 ms -520 bytes from 10.10.10.11: icmp_req=2 ttl=255 time=1.32 ms -520 bytes from 10.10.10.11: icmp_req=3 ttl=255 time=1.21 ms -520 bytes from 10.10.10.11: icmp_req=4 ttl=255 time=1.46 ms -520 bytes from 10.10.10.11: icmp_req=5 ttl=255 time=1.32 ms -520 bytes from 10.10.10.11: icmp_req=6 ttl=255 time=1.28 ms -520 bytes from 10.10.10.11: icmp_req=7 ttl=255 time=1.25 ms -520 bytes from 10.10.10.11: icmp_req=8 ttl=255 time=1.23 ms -520 bytes from 10.10.10.11: icmp_req=9 ttl=255 time=1.34 ms -520 bytes from 10.10.10.11: icmp_req=10 ttl=255 time=21.0 ms - ---- 10.10.10.11 ping statistics --- -10 packets transmitted, 10 received, 0% packet loss, time 9012ms -rtt min/avg/max/mdev = 1.170/3.262/21.002/5.913 ms diff --git a/test/units/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.20_count_4 b/test/units/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.20_count_4 deleted file mode 100644 index 08e6181715..0000000000 --- a/test/units/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.20_count_4 +++ /dev/null @@ -1,9 +0,0 @@ -PING 10.10.10.20 (10.10.10.20) 56(84) bytes of data. -From 10.10.10.20 icmp_seq=1 Destination Host Unreachable -From 10.10.10.20 icmp_seq=2 Destination Host Unreachable -From 10.10.10.20 icmp_seq=3 Destination Host Unreachable -From 10.10.10.20 icmp_seq=4 Destination Host Unreachable - ---- 10.10.10.20 ping statistics --- -4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 3053ms -pipe 3 diff --git a/test/units/modules/network/vyos/fixtures/vyos_static_routes_config.cfg b/test/units/modules/network/vyos/fixtures/vyos_static_routes_config.cfg deleted file mode 100644 index 0411dc9a8e..0000000000 --- a/test/units/modules/network/vyos/fixtures/vyos_static_routes_config.cfg +++ /dev/null @@ -1,2 +0,0 @@ -'set protocols static route 192.0.2.32/28 next-hop 192.0.2.9' -'set protocols static route 192.0.2.32/28 next-hop 192.0.2.10' diff --git a/test/units/modules/network/vyos/fixtures/vyos_user_config.cfg b/test/units/modules/network/vyos/fixtures/vyos_user_config.cfg deleted file mode 100644 index 81cd1a48a1..0000000000 --- a/test/units/modules/network/vyos/fixtures/vyos_user_config.cfg +++ /dev/null @@ -1,2 +0,0 @@ -set system login user admin level operator authentication encrypted-password '$6$V5oWW3JM9NFAwOG$P2L4raFvIrZjjs3g0qmH4Ns5ti7flRpSs6aEqy4TrGZYXGeBiYzwi2A6jy' -set system login user ansible level operator authentication encrypted-password '$6$ZfvSv6A50W6yNPYX$4HP5eg2sywcXYxTqhApQ7zvUvx0HsQHrI9xuJoFLy2gM/' diff --git a/test/units/modules/network/vyos/test_vyos_banner.py b/test/units/modules/network/vyos/test_vyos_banner.py deleted file mode 100644 index f9a172054c..0000000000 --- a/test/units/modules/network/vyos/test_vyos_banner.py +++ /dev/null @@ -1,54 +0,0 @@ -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from units.compat.mock import patch -from ansible.modules.network.vyos import vyos_banner -from units.modules.utils import set_module_args -from .vyos_module import TestVyosModule - - -class TestVyosBannerModule(TestVyosModule): - - module = vyos_banner - - def setUp(self): - super(TestVyosBannerModule, self).setUp() - - self.mock_get_config = patch('ansible.modules.network.vyos.vyos_banner.get_config') - self.get_config = self.mock_get_config.start() - - self.mock_load_config = patch('ansible.modules.network.vyos.vyos_banner.load_config') - self.load_config = self.mock_load_config.start() - - def tearDown(self): - super(TestVyosBannerModule, self).tearDown() - self.mock_get_config.stop() - self.mock_load_config.stop() - - def load_fixtures(self, commands=None): - self.load_config.return_value = dict(diff=None, session='session') - - def test_vyos_banner_create(self): - set_module_args(dict(banner='pre-login', text='test\nbanner\nstring')) - commands = ["set system login banner pre-login 'test\\nbanner\\nstring'"] - self.execute_module(changed=True, commands=commands) - - def test_vyos_banner_remove(self): - set_module_args(dict(banner='pre-login', state='absent')) - self.execute_module(changed=False, commands=[]) diff --git a/test/units/modules/network/vyos/test_vyos_command.py b/test/units/modules/network/vyos/test_vyos_command.py deleted file mode 100644 index 02423affd8..0000000000 --- a/test/units/modules/network/vyos/test_vyos_command.py +++ /dev/null @@ -1,103 +0,0 @@ -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from units.compat.mock import patch -from ansible.modules.network.vyos import vyos_command -from units.modules.utils import set_module_args -from .vyos_module import TestVyosModule, load_fixture - - -class TestVyosCommandModule(TestVyosModule): - - module = vyos_command - - def setUp(self): - super(TestVyosCommandModule, self).setUp() - self.mock_run_commands = patch('ansible.modules.network.vyos.vyos_command.run_commands') - self.run_commands = self.mock_run_commands.start() - - def tearDown(self): - super(TestVyosCommandModule, self).tearDown() - self.mock_run_commands.stop() - - def load_fixtures(self, commands=None): - def load_from_file(*args, **kwargs): - module, commands = args - output = list() - - for item in commands: - try: - command = item['command'] - except ValueError: - command = item - filename = str(command).replace(' ', '_') - output.append(load_fixture(filename)) - return output - - self.run_commands.side_effect = load_from_file - - def test_vyos_command_simple(self): - set_module_args(dict(commands=['show version'])) - result = self.execute_module() - self.assertEqual(len(result['stdout']), 1) - self.assertTrue(result['stdout'][0].startswith('Version: VyOS')) - - def test_vyos_command_multiple(self): - set_module_args(dict(commands=['show version', 'show version'])) - result = self.execute_module() - self.assertEqual(len(result['stdout']), 2) - self.assertTrue(result['stdout'][0].startswith('Version: VyOS')) - - def test_vyos_command_wait_for(self): - wait_for = 'result[0] contains "VyOS maintainers"' - set_module_args(dict(commands=['show version'], wait_for=wait_for)) - self.execute_module() - - def test_vyos_command_wait_for_fails(self): - wait_for = 'result[0] contains "test string"' - set_module_args(dict(commands=['show version'], wait_for=wait_for)) - self.execute_module(failed=True) - self.assertEqual(self.run_commands.call_count, 10) - - def test_vyos_command_retries(self): - wait_for = 'result[0] contains "test string"' - set_module_args(dict(commands=['show version'], wait_for=wait_for, retries=2)) - self.execute_module(failed=True) - self.assertEqual(self.run_commands.call_count, 2) - - def test_vyos_command_match_any(self): - wait_for = ['result[0] contains "VyOS maintainers"', - 'result[0] contains "test string"'] - set_module_args(dict(commands=['show version'], wait_for=wait_for, match='any')) - self.execute_module() - - def test_vyos_command_match_all(self): - wait_for = ['result[0] contains "VyOS maintainers"', - 'result[0] contains "maintainers@vyos.net"'] - set_module_args(dict(commands=['show version'], wait_for=wait_for, match='all')) - self.execute_module() - - def test_vyos_command_match_all_failure(self): - wait_for = ['result[0] contains "VyOS maintainers"', - 'result[0] contains "test string"'] - commands = ['show version', 'show version'] - set_module_args(dict(commands=commands, wait_for=wait_for, match='all')) - self.execute_module(failed=True) diff --git a/test/units/modules/network/vyos/test_vyos_config.py b/test/units/modules/network/vyos/test_vyos_config.py deleted file mode 100644 index 015ec8807f..0000000000 --- a/test/units/modules/network/vyos/test_vyos_config.py +++ /dev/null @@ -1,117 +0,0 @@ -# -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from units.compat.mock import patch, MagicMock -from ansible.modules.network.vyos import vyos_config -from ansible.plugins.cliconf.vyos import Cliconf -from units.modules.utils import set_module_args -from .vyos_module import TestVyosModule, load_fixture - - -class TestVyosConfigModule(TestVyosModule): - - module = vyos_config - - def setUp(self): - super(TestVyosConfigModule, self).setUp() - - self.mock_get_config = patch('ansible.modules.network.vyos.vyos_config.get_config') - self.get_config = self.mock_get_config.start() - - self.mock_load_config = patch('ansible.modules.network.vyos.vyos_config.load_config') - self.load_config = self.mock_load_config.start() - - self.mock_run_commands = patch('ansible.modules.network.vyos.vyos_config.run_commands') - self.run_commands = self.mock_run_commands.start() - - self.mock_get_connection = patch('ansible.modules.network.vyos.vyos_config.get_connection') - self.get_connection = self.mock_get_connection.start() - - self.cliconf_obj = Cliconf(MagicMock()) - self.running_config = load_fixture('vyos_config_config.cfg') - - self.conn = self.get_connection() - self.conn.edit_config = MagicMock() - self.running_config = load_fixture('vyos_config_config.cfg') - - def tearDown(self): - super(TestVyosConfigModule, self).tearDown() - - self.mock_get_config.stop() - self.mock_load_config.stop() - self.mock_run_commands.stop() - self.mock_get_connection.stop() - - def load_fixtures(self, commands=None): - config_file = 'vyos_config_config.cfg' - self.get_config.return_value = load_fixture(config_file) - self.load_config.return_value = None - - def test_vyos_config_unchanged(self): - src = load_fixture('vyos_config_config.cfg') - self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(src, src)) - set_module_args(dict(src=src)) - self.execute_module() - - def test_vyos_config_src(self): - src = load_fixture('vyos_config_src.cfg') - set_module_args(dict(src=src)) - candidate = '\n'.join(self.module.format_commands(src.splitlines())) - commands = ['set system host-name foo', 'delete interfaces ethernet eth0 address'] - self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(candidate, self.running_config)) - self.execute_module(changed=True, commands=commands) - - def test_vyos_config_src_brackets(self): - src = load_fixture('vyos_config_src_brackets.cfg') - set_module_args(dict(src=src)) - candidate = '\n'.join(self.module.format_commands(src.splitlines())) - commands = ['set interfaces ethernet eth0 address 10.10.10.10/24', 'set system host-name foo'] - self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(candidate, self.running_config)) - self.execute_module(changed=True, commands=commands) - - def test_vyos_config_backup(self): - set_module_args(dict(backup=True)) - result = self.execute_module() - self.assertIn('__backup__', result) - - def test_vyos_config_lines(self): - commands = ['set system host-name foo'] - set_module_args(dict(lines=commands)) - candidate = '\n'.join(commands) - self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(candidate, self.running_config)) - self.execute_module(changed=True, commands=commands) - - def test_vyos_config_config(self): - config = 'set system host-name localhost' - new_config = ['set system host-name router'] - set_module_args(dict(lines=new_config, config=config)) - candidate = '\n'.join(new_config) - self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(candidate, config)) - self.execute_module(changed=True, commands=new_config) - - def test_vyos_config_match_none(self): - lines = ['set system interfaces ethernet eth0 address 1.2.3.4/24', - 'set system interfaces ethernet eth0 description test string'] - set_module_args(dict(lines=lines, match='none')) - candidate = '\n'.join(lines) - self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(candidate, None, diff_match='none')) - self.execute_module(changed=True, commands=lines, sort=False) diff --git a/test/units/modules/network/vyos/test_vyos_facts.py b/test/units/modules/network/vyos/test_vyos_facts.py deleted file mode 100644 index e7d525c2fa..0000000000 --- a/test/units/modules/network/vyos/test_vyos_facts.py +++ /dev/null @@ -1,97 +0,0 @@ -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type -import json -from units.compat.mock import patch -from ansible.modules.network.vyos import vyos_facts -from units.modules.utils import set_module_args -from .vyos_module import TestVyosModule, load_fixture - - -class TestVyosFactsModule(TestVyosModule): - module = vyos_facts - - def setUp(self): - super(TestVyosFactsModule, self).setUp() - self.mock_run_commands = patch('ansible.module_utils.network.vyos.facts.legacy.base.run_commands') - self.run_commands = self.mock_run_commands.start() - - self.mock_get_resource_connection = patch('ansible.module_utils.network.common.facts.facts.get_resource_connection') - self.get_resource_connection = self.mock_get_resource_connection.start() - - self.mock_get_capabilities = patch('ansible.module_utils.network.vyos.facts.legacy.base.get_capabilities') - self.get_capabilities = self.mock_get_capabilities.start() - self.get_capabilities.return_value = { - 'device_info': { - 'network_os': 'vyos', - 'network_os_hostname': 'vyos01', - 'network_os_model': 'VMware', - 'network_os_version': 'VyOS 1.1.7' - }, - 'network_api': 'cliconf' - } - - def tearDown(self): - super(TestVyosFactsModule, self).tearDown() - self.mock_run_commands.stop() - self.mock_get_capabilities.stop() - self.mock_get_resource_connection.stop() - - def load_fixtures(self, commands=None): - def load_from_file(*args, **kwargs): - module, commands = args - output = list() - for item in commands: - try: - obj = json.loads(item) - command = obj['command'] - except ValueError: - command = item - filename = str(command).replace(' ', '_') - output.append(load_fixture(filename)) - return output - self.run_commands.side_effect = load_from_file - - def test_vyos_facts_default(self): - set_module_args(dict(gather_subset='default')) - result = self.execute_module() - facts = result.get('ansible_facts') - self.assertEqual(len(facts), 10) - self.assertEqual(facts['ansible_net_hostname'].strip(), 'vyos01') - self.assertEqual(facts['ansible_net_version'], 'VyOS 1.1.7') - - def test_vyos_facts_not_all(self): - set_module_args(dict(gather_subset='!all')) - result = self.execute_module() - facts = result.get('ansible_facts') - self.assertEqual(len(facts), 10) - self.assertEqual(facts['ansible_net_hostname'].strip(), 'vyos01') - self.assertEqual(facts['ansible_net_version'], 'VyOS 1.1.7') - - def test_vyos_facts_exclude_most(self): - set_module_args(dict(gather_subset=['!neighbors', '!config'])) - result = self.execute_module() - facts = result.get('ansible_facts') - self.assertEqual(len(facts), 10) - self.assertEqual(facts['ansible_net_hostname'].strip(), 'vyos01') - self.assertEqual(facts['ansible_net_version'], 'VyOS 1.1.7') - - def test_vyos_facts_invalid_subset(self): - set_module_args(dict(gather_subset='cereal')) - self.execute_module(failed=True) diff --git a/test/units/modules/network/vyos/test_vyos_firewall_global.py b/test/units/modules/network/vyos/test_vyos_firewall_global.py deleted file mode 100644 index 36e0ba48b5..0000000000 --- a/test/units/modules/network/vyos/test_vyos_firewall_global.py +++ /dev/null @@ -1,207 +0,0 @@ -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from units.compat.mock import patch -from ansible.modules.network.vyos import vyos_firewall_global -from units.modules.utils import set_module_args -from .vyos_module import TestVyosModule, load_fixture - - -class TestVyosFirewallRulesModule(TestVyosModule): - - module = vyos_firewall_global - - def setUp(self): - super(TestVyosFirewallRulesModule, self).setUp() - self.mock_get_config = patch( - 'ansible.module_utils.network.common.network.Config.get_config') - self.get_config = self.mock_get_config.start() - - self.mock_load_config = patch( - 'ansible.module_utils.network.common.network.Config.load_config') - self.load_config = self.mock_load_config.start() - - self.mock_get_resource_connection_config = patch( - 'ansible.module_utils.network.common.cfg.base.get_resource_connection' - ) - self.get_resource_connection_config = self.mock_get_resource_connection_config.start( - ) - - self.mock_get_resource_connection_facts = patch( - 'ansible.module_utils.network.common.facts.facts.get_resource_connection' - ) - self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start( - ) - - self.mock_execute_show_command = patch( - 'ansible.module_utils.network.vyos.facts.firewall_global.firewall_global.Firewall_globalFacts.get_device_data' - ) - - self.execute_show_command = self.mock_execute_show_command.start() - - def tearDown(self): - super(TestVyosFirewallRulesModule, self).tearDown() - self.mock_get_resource_connection_config.stop() - self.mock_get_resource_connection_facts.stop() - self.mock_get_config.stop() - self.mock_load_config.stop() - self.mock_execute_show_command.stop() - - def load_fixtures(self, commands=None): - def load_from_file(*args, **kwargs): - return load_fixture('vyos_firewall_global_config.cfg') - - self.execute_show_command.side_effect = load_from_file - - def test_vyos_firewall_global_set_01_merged(self): - set_module_args( - dict(config=dict( - validation='strict', - config_trap=True, - log_martians=True, - syn_cookies=True, - twa_hazards_protection=True, - ping=dict(all=True, broadcast=True), - state_policy=[ - dict( - connection_type='established', - action='accept', - log=True, - ), - dict(connection_type='invalid', action='reject') - ], - route_redirects=[ - dict(afi='ipv4', - ip_src_route=True, - icmp_redirects=dict(send=True, receive=False)) - ], - group=dict( - address_group=[ - dict( - name='MGMT-HOSTS', - description='This group has the Management hosts address lists', - members=[ - dict(address='192.0.1.1'), - dict(address='192.0.1.3'), - dict(address='192.0.1.5') - ]) - ], - network_group=[ - dict(name='MGMT', - description='This group has the Management network addresses', - members=[dict(address='192.0.1.0/24')]) - ])), - state="merged")) - commands = [ - "set firewall group address-group MGMT-HOSTS address 192.0.1.1", - "set firewall group address-group MGMT-HOSTS address 192.0.1.3", - "set firewall group address-group MGMT-HOSTS address 192.0.1.5", - "set firewall group address-group MGMT-HOSTS description 'This group has the Management hosts address lists'", - "set firewall group address-group MGMT-HOSTS", - "set firewall group network-group MGMT network 192.0.1.0/24", - "set firewall group network-group MGMT description 'This group has the Management network addresses'", - "set firewall group network-group MGMT", - "set firewall ip-src-route 'enable'", - "set firewall receive-redirects 'disable'", - "set firewall send-redirects 'enable'", - "set firewall config-trap 'enable'", - "set firewall state-policy established action 'accept'", - "set firewall state-policy established log 'enable'", - "set firewall state-policy invalid action 'reject'", - "set firewall broadcast-ping 'enable'", - "set firewall all-ping 'enable'", - "set firewall log-martians 'enable'", - "set firewall twa-hazards-protection 'enable'", - "set firewall syn-cookies 'enable'", - "set firewall source-validation 'strict'" - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_global_set_01_merged_idem(self): - set_module_args( - dict(config=dict(group=dict( - address_group=[ - dict(name='RND-HOSTS', - description='This group has the Management hosts address lists', - members=[ - dict(address='192.0.2.1'), - dict(address='192.0.2.3'), - dict(address='192.0.2.5') - ]) - ], - network_group=[ - dict(name='RND', - description='This group has the Management network addresses', - members=[dict(address='192.0.2.0/24')]) - ])), - state="merged")) - self.execute_module(changed=False, commands=[]) - - def test_vyos_firewall_global_set_01_replaced(self): - set_module_args( - dict(config=dict(group=dict( - address_group=[ - dict(name='RND-HOSTS', - description='This group has the Management hosts address lists', - members=[ - dict(address='192.0.2.1'), - dict(address='192.0.2.7'), - dict(address='192.0.2.9') - ]) - ], - network_group=[ - dict(name='RND', - description='This group has the Management network addresses', - members=[dict(address='192.0.2.0/24')]) - ])), - state="replaced")) - commands = [ - "delete firewall group address-group RND-HOSTS address 192.0.2.3", - "delete firewall group address-group RND-HOSTS address 192.0.2.5", - "set firewall group address-group RND-HOSTS address 192.0.2.7", - "set firewall group address-group RND-HOSTS address 192.0.2.9" - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_global_set_01_replaced_idem(self): - set_module_args( - dict(config=dict(group=dict( - address_group=[ - dict(name='RND-HOSTS', - description='This group has the Management hosts address lists', - members=[ - dict(address='192.0.2.1'), - dict(address='192.0.2.3'), - dict(address='192.0.2.5') - ]) - ], - network_group=[ - dict(name='RND', - description='This group has the Management network addresses', - members=[dict(address='192.0.2.0/24')]) - ])), - state="replaced")) - self.execute_module(changed=False, commands=[]) - - def test_vyos_firewall_global_set_01_deleted(self): - set_module_args(dict(config=dict(), state="deleted")) - commands = ["delete firewall "] - self.execute_module(changed=True, commands=commands) diff --git a/test/units/modules/network/vyos/test_vyos_firewall_interfaces.py b/test/units/modules/network/vyos/test_vyos_firewall_interfaces.py deleted file mode 100644 index 574263a374..0000000000 --- a/test/units/modules/network/vyos/test_vyos_firewall_interfaces.py +++ /dev/null @@ -1,305 +0,0 @@ -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from units.compat.mock import patch, MagicMock -from ansible.modules.network.vyos import vyos_firewall_interfaces -from units.modules.utils import set_module_args -from .vyos_module import TestVyosModule, load_fixture - - -class TestVyosFirewallInterfacesModule(TestVyosModule): - - module = vyos_firewall_interfaces - - def setUp(self): - super(TestVyosFirewallInterfacesModule, self).setUp() - self.mock_get_config = patch( - 'ansible.module_utils.network.common.network.Config.get_config') - self.get_config = self.mock_get_config.start() - - self.mock_load_config = patch( - 'ansible.module_utils.network.common.network.Config.load_config') - self.load_config = self.mock_load_config.start() - - self.mock_get_resource_connection_config = patch( - 'ansible.module_utils.network.common.cfg.base.get_resource_connection' - ) - self.get_resource_connection_config = self.mock_get_resource_connection_config.start( - ) - - self.mock_get_resource_connection_facts = patch( - 'ansible.module_utils.network.common.facts.facts.get_resource_connection' - ) - self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start( - ) - - self.mock_execute_show_command = patch( - 'ansible.module_utils.network.vyos.facts.firewall_interfaces.firewall_interfaces.Firewall_interfacesFacts.get_device_data' - ) - self.execute_show_command = self.mock_execute_show_command.start() - - def tearDown(self): - super(TestVyosFirewallInterfacesModule, self).tearDown() - self.mock_get_resource_connection_config.stop() - self.mock_get_resource_connection_facts.stop() - self.mock_get_config.stop() - self.mock_load_config.stop() - self.mock_execute_show_command.stop() - - def load_fixtures(self, commands=None): - def load_from_file(*args, **kwargs): - return load_fixture('vyos_firewall_interfaces_config.cfg') - - self.execute_show_command.side_effect = load_from_file - - def test_vyos_firewall_rule_set_01_merged(self): - set_module_args( - dict(config=[ - dict(name='eth1', - access_rules=[ - dict(afi='ipv4', - rules=[ - dict(name='INBOUND', direction='in'), - dict(name='OUTBOUND', direction='out'), - dict(name='LOCAL', direction='local') - ]), - dict(afi='ipv6', - rules=[dict(name='V6-LOCAL', direction='local')]) - ]), - dict(name='eth3', - access_rules=[ - dict(afi='ipv4', - rules=[ - dict(name='INBOUND', direction='in'), - dict(name='OUTBOUND', direction='out'), - dict(name='LOCAL', direction='local') - ]), - dict(afi='ipv6', - rules=[dict(name='V6-LOCAL', direction='local')]) - ]) - ], - state="merged")) - commands = [ - "set interfaces ethernet eth1 firewall in name 'INBOUND'", - "set interfaces ethernet eth1 firewall out name 'OUTBOUND'", - "set interfaces ethernet eth1 firewall local name 'LOCAL'", - "set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL'", - "set interfaces ethernet eth3 firewall in name 'INBOUND'", - "set interfaces ethernet eth3 firewall out name 'OUTBOUND'", - "set interfaces ethernet eth3 firewall local name 'LOCAL'", - "set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL'" - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_rule_set_02_merged_idem(self): - set_module_args( - dict(config=[ - dict(name='eth0', - access_rules=[ - dict(afi='ipv4', - rules=[ - dict(name='INBOUND', direction='in'), - dict(name='OUTBOUND', direction='out'), - dict(name='LOCAL', direction='local') - ]), - dict(afi='ipv6', - rules=[dict(name='V6-LOCAL', direction='local')]) - ]), - dict(name='eth2', - access_rules=[ - dict(afi='ipv4', - rules=[ - dict(name='INBOUND', direction='in'), - dict(name='OUTBOUND', direction='out'), - dict(name='LOCAL', direction='local') - ]), - dict(afi='ipv6', - rules=[dict(name='V6-LOCAL', direction='local')]) - ]) - ], - state="merged")) - self.execute_module(changed=False, commands=[]) - - def test_vyos_firewall_rule_set_01_deleted_per_afi(self): - set_module_args( - dict(config=[ - dict(name='eth0', - access_rules=[dict(afi='ipv4'), - dict(afi='ipv6')]) - ], - state="deleted")) - commands = [ - "delete interfaces ethernet eth0 firewall in name", - "delete interfaces ethernet eth0 firewall local name", - "delete interfaces ethernet eth0 firewall out name", - "delete interfaces ethernet eth0 firewall local ipv6-name" - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_rule_set_03_deleted_per_interface(self): - set_module_args( - dict(config=[dict(name='eth0'), - dict(name='eth2')], - state="deleted")) - commands = [ - "delete interfaces ethernet eth0 firewall", - "delete interfaces ethernet eth2 firewall" - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_rule_set_03_deleted_all(self): - set_module_args(dict(config=[], state="deleted")) - commands = [ - "delete interfaces ethernet eth0 firewall", - "delete interfaces ethernet eth2 firewall" - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_rule_set_03_deleted(self): - set_module_args( - dict(config=[dict(name='eth0'), - dict(name='eth2')], - state="deleted")) - commands = [ - "delete interfaces ethernet eth0 firewall", - "delete interfaces ethernet eth2 firewall" - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_rule_set_04_deleted_interface_idem(self): - set_module_args( - dict(config=[dict(name='eth1'), - dict(name='eth3')], - state="deleted")) - self.execute_module(changed=False, commands=[]) - - def test_vyos_firewall_rule_set_02_replaced_idem(self): - set_module_args( - dict(config=[ - dict(name='eth0', - access_rules=[ - dict(afi='ipv4', - rules=[ - dict(name='INBOUND', direction='in'), - dict(name='OUTBOUND', direction='out'), - dict(name='LOCAL', direction='local') - ]), - dict(afi='ipv6', - rules=[dict(name='V6-LOCAL', direction='local')]) - ]), - dict(name='eth2', - access_rules=[ - dict(afi='ipv4', - rules=[ - dict(name='INBOUND', direction='in'), - dict(name='OUTBOUND', direction='out'), - dict(name='LOCAL', direction='local') - ]), - dict(afi='ipv6', - rules=[dict(name='V6-LOCAL', direction='local')]) - ]) - ], - state="replaced")) - self.execute_module(changed=False, commands=[]) - - def test_vyos_firewall_rule_set_01_replaced(self): - set_module_args( - dict(config=[ - dict(name='eth0', - access_rules=[ - dict(afi='ipv4', - rules=[ - dict(name='INBOUND', direction='in'), - ]), - dict(afi='ipv6', - rules=[dict(name='V6-LOCAL', direction='local')]) - ]), - dict(name='eth2', - access_rules=[ - dict(afi='ipv4', - rules=[dict(name='LOCAL', direction='local')]), - dict(afi='ipv6', - rules=[dict(name='V6-LOCAL', direction='local')]) - ]), - dict(name='eth3', - access_rules=[ - dict(afi='ipv4', - rules=[dict(name='LOCAL', direction='local')]), - dict(afi='ipv6', - rules=[dict(name='V6-LOCAL', direction='local')]) - ]) - ], - state="replaced")) - commands = [ - "delete interfaces ethernet eth0 firewall out name", - "delete interfaces ethernet eth0 firewall local name", - "delete interfaces ethernet eth2 firewall in name", - "delete interfaces ethernet eth2 firewall out name", - "set interfaces ethernet eth3 firewall local name 'LOCAL'", - "set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL'" - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_rule_set_01_overridden(self): - set_module_args( - dict(config=[ - dict(name='eth1', - access_rules=[ - dict(afi='ipv4', - rules=[dict(name='INBOUND', direction='in')]) - ]) - ], - state="overridden")) - commands = [ - "delete interfaces ethernet eth0 firewall", - "delete interfaces ethernet eth2 firewall", - "set interfaces ethernet eth1 firewall in name 'INBOUND'" - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_rule_set_02_overridden_idem(self): - set_module_args( - dict(config=[ - dict(name='eth0', - access_rules=[ - dict(afi='ipv4', - rules=[ - dict(name='INBOUND', direction='in'), - dict(name='OUTBOUND', direction='out'), - dict(name='LOCAL', direction='local') - ]), - dict(afi='ipv6', - rules=[dict(name='V6-LOCAL', direction='local')]) - ]), - dict(name='eth2', - access_rules=[ - dict(afi='ipv4', - rules=[ - dict(name='INBOUND', direction='in'), - dict(name='OUTBOUND', direction='out'), - dict(name='LOCAL', direction='local') - ]), - dict(afi='ipv6', - rules=[dict(name='V6-LOCAL', direction='local')]) - ]) - ], - state="overridden")) - self.execute_module(changed=False, commands=[]) diff --git a/test/units/modules/network/vyos/test_vyos_firewall_rules.py b/test/units/modules/network/vyos/test_vyos_firewall_rules.py deleted file mode 100644 index 5dc6eaa474..0000000000 --- a/test/units/modules/network/vyos/test_vyos_firewall_rules.py +++ /dev/null @@ -1,827 +0,0 @@ -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from units.compat.mock import patch -from ansible.modules.network.vyos import vyos_firewall_rules -from units.modules.utils import set_module_args -from .vyos_module import TestVyosModule, load_fixture - - -class TestVyosFirewallRulesModule(TestVyosModule): - - module = vyos_firewall_rules - - def setUp(self): - super(TestVyosFirewallRulesModule, self).setUp() - self.mock_get_config = patch( - 'ansible.module_utils.network.common.network.Config.get_config') - self.get_config = self.mock_get_config.start() - - self.mock_load_config = patch( - 'ansible.module_utils.network.common.network.Config.load_config') - self.load_config = self.mock_load_config.start() - - self.mock_get_resource_connection_config = patch( - 'ansible.module_utils.network.common.cfg.base.get_resource_connection' - ) - self.get_resource_connection_config = self.mock_get_resource_connection_config.start( - ) - - self.mock_get_resource_connection_facts = patch( - 'ansible.module_utils.network.common.facts.facts.get_resource_connection' - ) - self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start( - ) - self.mock_execute_show_command = patch( - 'ansible.module_utils.network.vyos.facts.static_routes.static_routes.Static_routesFacts.get_device_data' - ) - - self.mock_execute_show_command = patch( - 'ansible.module_utils.network.vyos.facts.firewall_rules.firewall_rules.Firewall_rulesFacts.get_device_data' - ) - self.execute_show_command = self.mock_execute_show_command.start() - - def tearDown(self): - super(TestVyosFirewallRulesModule, self).tearDown() - self.mock_get_resource_connection_config.stop() - self.mock_get_resource_connection_facts.stop() - self.mock_get_config.stop() - self.mock_load_config.stop() - self.mock_execute_show_command.stop() - - def load_fixtures(self, commands=None): - def load_from_file(*args, **kwargs): - return load_fixture('vyos_firewall_rules_config.cfg') - - self.execute_show_command.side_effect = load_from_file - - def test_vyos_firewall_rule_set_01_merged(self): - set_module_args( - dict(config=[ - dict(afi='ipv6', - rule_sets=[ - dict(name='V6-INBOUND', - description='This is IPv6 INBOUND rule set', - default_action='reject', - enable_default_log=True, - rules=[]), - dict(name='V6-OUTBOUND', - description='This is IPv6 OUTBOUND rule set', - default_action='accept', - enable_default_log=False, - rules=[]) - ]), - dict(afi='ipv4', - rule_sets=[ - dict(name='V4-INBOUND', - description='This is IPv4 INBOUND rule set', - default_action='reject', - enable_default_log=True, - rules=[]), - dict(name='V4-OUTBOUND', - description='This is IPv4 OUTBOUND rule set', - default_action='accept', - enable_default_log=False, - rules=[]) - ]) - ], - state="merged")) - commands = [ - "set firewall ipv6-name V6-INBOUND default-action 'reject'", - "set firewall ipv6-name V6-INBOUND description 'This is IPv6 INBOUND rule set'", - 'set firewall ipv6-name V6-INBOUND enable-default-log', - "set firewall ipv6-name V6-OUTBOUND default-action 'accept'", - "set firewall ipv6-name V6-OUTBOUND description 'This is IPv6 OUTBOUND rule set'", - "set firewall name V4-INBOUND default-action 'reject'", - "set firewall name V4-INBOUND description 'This is IPv4 INBOUND rule set'", - 'set firewall name V4-INBOUND enable-default-log', - "set firewall name V4-OUTBOUND default-action 'accept'", - "set firewall name V4-OUTBOUND description 'This is IPv4 OUTBOUND rule set'" - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_rule_set_02_merged(self): - set_module_args( - dict(config=[ - dict(afi='ipv6', - rule_sets=[ - dict(name='V6-INBOUND', - description='This is IPv6 INBOUND rule set', - default_action='reject', - enable_default_log=True, - rules=[]), - dict(name='V6-OUTBOUND', - description='This is IPv6 OUTBOUND rule set', - default_action='accept', - enable_default_log=False, - rules=[]) - ]), - dict(afi='ipv4', - rule_sets=[ - dict(name='V4-INBOUND', - description='This is IPv4 INBOUND rule set', - default_action='reject', - enable_default_log=True, - rules=[]), - dict(name='V4-OUTBOUND', - description='This is IPv4 OUTBOUND rule set', - default_action='accept', - enable_default_log=False, - rules=[]) - ]) - ], - state="merged")) - commands = [ - "set firewall ipv6-name V6-INBOUND default-action 'reject'", - "set firewall ipv6-name V6-INBOUND description 'This is IPv6 INBOUND rule set'", - 'set firewall ipv6-name V6-INBOUND enable-default-log', - "set firewall ipv6-name V6-OUTBOUND default-action 'accept'", - "set firewall ipv6-name V6-OUTBOUND description 'This is IPv6 OUTBOUND rule set'", - "set firewall name V4-INBOUND default-action 'reject'", - "set firewall name V4-INBOUND description 'This is IPv4 INBOUND rule set'", - 'set firewall name V4-INBOUND enable-default-log', - "set firewall name V4-OUTBOUND default-action 'accept'", - "set firewall name V4-OUTBOUND description 'This is IPv4 OUTBOUND rule set'" - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v4_rule_sets_rule_merged_01(self): - set_module_args( - dict(config=[ - dict(afi='ipv4', - rule_sets=[ - dict(name='INBOUND', - description='This is IPv4 INBOUND rule set', - default_action='accept', - enable_default_log=True, - rules=[ - dict(number='101', - action='accept', - description='Rule 101 is configured by Ansible', - ipsec='match-ipsec', - protocol='icmp', - fragment='match-frag', - disabled=True) - ]), - ]) - ], - state="merged")) - commands = [ - "set firewall name INBOUND default-action 'accept'", - "set firewall name INBOUND description 'This is IPv4 INBOUND rule set'", - 'set firewall name INBOUND enable-default-log', - "set firewall name INBOUND rule 101 protocol 'icmp'", - "set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible'", - "set firewall name INBOUND rule 101 fragment 'match-frag'", - 'set firewall name INBOUND rule 101', - 'set firewall name INBOUND rule 101 disabled', - "set firewall name INBOUND rule 101 action 'accept'", - "set firewall name INBOUND rule 101 ipsec 'match-ipsec'" - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v4_rule_sets_rule_merged_02(self): - set_module_args( - dict(config=[ - dict(afi='ipv4', - rule_sets=[ - dict(name='INBOUND', - rules=[ - dict(number='101', - protocol='tcp', - source=dict( - address='192.0.2.0', - mac_address='38:00:25:19:76:0c', - port=2127), - destination=dict(address='192.0.1.0', - port=2124), - limit=dict(burst=10, - rate=dict(number=20, - unit='second')), - recent=dict(count=10, time=20), - state=dict(established=True, - related=True, - invalid=True, - new=True)) - ]), - ]) - ], - state="merged")) - commands = [ - "set firewall name INBOUND rule 101 protocol 'tcp'", - 'set firewall name INBOUND rule 101 destination address 192.0.1.0', - 'set firewall name INBOUND rule 101 destination port 2124', - 'set firewall name INBOUND rule 101', - 'set firewall name INBOUND rule 101 source address 192.0.2.0', - 'set firewall name INBOUND rule 101 source mac-address 38:00:25:19:76:0c', - 'set firewall name INBOUND rule 101 source port 2127', - 'set firewall name INBOUND rule 101 state new enable', - 'set firewall name INBOUND rule 101 state invalid enable', - 'set firewall name INBOUND rule 101 state related enable', - 'set firewall name INBOUND rule 101 state established enable', - 'set firewall name INBOUND rule 101 limit burst 10', - 'set firewall name INBOUND rule 101 limit rate 20/second', - 'set firewall name INBOUND rule 101 recent count 10', - 'set firewall name INBOUND rule 101 recent time 20', - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v4_rule_sets_rule_merged_03(self): - set_module_args( - dict(config=[ - dict(afi='ipv4', - rule_sets=[ - dict(name='INBOUND', - rules=[ - dict(number='101', - destination=dict(group=dict( - address_group='OUT-ADDR-GROUP', - network_group='OUT-NET-GROUP', - port_group='OUT-PORT-GROUP')), - source=dict(group=dict( - address_group='IN-ADDR-GROUP', - network_group='IN-NET-GROUP', - port_group='IN-PORT-GROUP'))) - ]), - ]) - ], - state="merged")) - commands = [ - 'set firewall name INBOUND rule 101 source group address-group IN-ADDR-GROUP', - 'set firewall name INBOUND rule 101 source group network-group IN-NET-GROUP', - 'set firewall name INBOUND rule 101 source group port-group IN-PORT-GROUP', - 'set firewall name INBOUND rule 101 destination group address-group OUT-ADDR-GROUP', - 'set firewall name INBOUND rule 101 destination group network-group OUT-NET-GROUP', - 'set firewall name INBOUND rule 101 destination group port-group OUT-PORT-GROUP', - 'set firewall name INBOUND rule 101' - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v4_rule_sets_rule_merged_04(self): - set_module_args( - dict(config=[ - dict(afi='ipv4', - rule_sets=[ - dict(name='INBOUND', - rules=[ - dict(number='101', - time=dict(monthdays='2', - startdate='2020-01-24', - starttime='13:20:00', - stopdate='2020-01-28', - stoptime='13:30:00', - weekdays='!Sat,Sun', - utc=True), - tcp=dict(flags='ALL')) - ]), - ]) - ], - state="merged")) - commands = [ - 'set firewall name INBOUND rule 101', - 'set firewall name INBOUND rule 101 tcp flags ALL', - 'set firewall name INBOUND rule 101 time utc', - 'set firewall name INBOUND rule 101 time monthdays 2', - 'set firewall name INBOUND rule 101 time startdate 2020-01-24', - 'set firewall name INBOUND rule 101 time stopdate 2020-01-28', - 'set firewall name INBOUND rule 101 time weekdays !Sat,Sun', - 'set firewall name INBOUND rule 101 time stoptime 13:30:00', - 'set firewall name INBOUND rule 101 time starttime 13:20:00', - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v6_rule_sets_rule_merged_01(self): - set_module_args( - dict(config=[ - dict(afi='ipv6', - rule_sets=[ - dict(name='INBOUND', - description='This is IPv6 INBOUND rule set', - default_action='accept', - enable_default_log=True, - rules=[ - dict(number='101', - action='accept', - description='Rule 101 is configured by Ansible', - ipsec='match-ipsec', - protocol='icmp', - disabled=True) - ]), - ]) - ], - state="merged")) - commands = [ - "set firewall ipv6-name INBOUND default-action 'accept'", - "set firewall ipv6-name INBOUND description 'This is IPv6 INBOUND rule set'", - 'set firewall ipv6-name INBOUND enable-default-log', - "set firewall ipv6-name INBOUND rule 101 protocol 'icmp'", - "set firewall ipv6-name INBOUND rule 101 description 'Rule 101 is configured by Ansible'", - 'set firewall ipv6-name INBOUND rule 101', - 'set firewall ipv6-name INBOUND rule 101 disabled', - "set firewall ipv6-name INBOUND rule 101 action 'accept'", - "set firewall ipv6-name INBOUND rule 101 ipsec 'match-ipsec'" - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v6_rule_sets_rule_merged_02(self): - set_module_args( - dict(config=[ - dict(afi='ipv6', - rule_sets=[ - dict(name='INBOUND', - rules=[ - dict(number='101', - protocol='tcp', - source=dict( - address='2001:db8::12', - mac_address='38:00:25:19:76:0c', - port=2127), - destination=dict(address='2001:db8::11', - port=2124), - limit=dict(burst=10, - rate=dict(number=20, - unit='second')), - recent=dict(count=10, time=20), - state=dict(established=True, - related=True, - invalid=True, - new=True)) - ]), - ]) - ], - state="merged")) - commands = [ - "set firewall ipv6-name INBOUND rule 101 protocol 'tcp'", - 'set firewall ipv6-name INBOUND rule 101 destination address 2001:db8::11', - 'set firewall ipv6-name INBOUND rule 101 destination port 2124', - 'set firewall ipv6-name INBOUND rule 101', - 'set firewall ipv6-name INBOUND rule 101 source address 2001:db8::12', - 'set firewall ipv6-name INBOUND rule 101 source mac-address 38:00:25:19:76:0c', - 'set firewall ipv6-name INBOUND rule 101 source port 2127', - 'set firewall ipv6-name INBOUND rule 101 state new enable', - 'set firewall ipv6-name INBOUND rule 101 state invalid enable', - 'set firewall ipv6-name INBOUND rule 101 state related enable', - 'set firewall ipv6-name INBOUND rule 101 state established enable', - 'set firewall ipv6-name INBOUND rule 101 limit burst 10', - 'set firewall ipv6-name INBOUND rule 101 recent count 10', - 'set firewall ipv6-name INBOUND rule 101 recent time 20', - 'set firewall ipv6-name INBOUND rule 101 limit rate 20/second' - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v6_rule_sets_rule_merged_03(self): - set_module_args( - dict(config=[ - dict(afi='ipv6', - rule_sets=[ - dict(name='INBOUND', - rules=[ - dict(number='101', - destination=dict(group=dict( - address_group='OUT-ADDR-GROUP', - network_group='OUT-NET-GROUP', - port_group='OUT-PORT-GROUP')), - source=dict(group=dict( - address_group='IN-ADDR-GROUP', - network_group='IN-NET-GROUP', - port_group='IN-PORT-GROUP'))) - ]), - ]) - ], - state="merged")) - commands = [ - 'set firewall ipv6-name INBOUND rule 101 source group address-group IN-ADDR-GROUP', - 'set firewall ipv6-name INBOUND rule 101 source group network-group IN-NET-GROUP', - 'set firewall ipv6-name INBOUND rule 101 source group port-group IN-PORT-GROUP', - 'set firewall ipv6-name INBOUND rule 101 destination group address-group OUT-ADDR-GROUP', - 'set firewall ipv6-name INBOUND rule 101 destination group network-group OUT-NET-GROUP', - 'set firewall ipv6-name INBOUND rule 101 destination group port-group OUT-PORT-GROUP', - 'set firewall ipv6-name INBOUND rule 101' - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v6_rule_sets_rule_merged_04(self): - set_module_args( - dict(config=[ - dict(afi='ipv6', - rule_sets=[ - dict(name='INBOUND', - rules=[ - dict(number='101', - time=dict(monthdays='2', - startdate='2020-01-24', - starttime='13:20:00', - stopdate='2020-01-28', - stoptime='13:30:00', - weekdays='!Sat,Sun', - utc=True), - tcp=dict(flags='ALL')) - ]), - ]) - ], - state="merged")) - commands = [ - 'set firewall ipv6-name INBOUND rule 101', - 'set firewall ipv6-name INBOUND rule 101 tcp flags ALL', - 'set firewall ipv6-name INBOUND rule 101 time utc', - 'set firewall ipv6-name INBOUND rule 101 time monthdays 2', - 'set firewall ipv6-name INBOUND rule 101 time startdate 2020-01-24', - 'set firewall ipv6-name INBOUND rule 101 time stopdate 2020-01-28', - 'set firewall ipv6-name INBOUND rule 101 time weekdays !Sat,Sun', - 'set firewall ipv6-name INBOUND rule 101 time stoptime 13:30:00', - 'set firewall ipv6-name INBOUND rule 101 time starttime 13:20:00' - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v6_rule_sets_rule_merged_icmp_01(self): - set_module_args( - dict(config=[ - dict(afi='ipv6', - rule_sets=[ - dict(name='INBOUND', - rules=[ - dict(number='101', - protocol='icmp', - icmp=dict(type_name='port-unreachable')) - ]), - ]) - ], - state="merged")) - commands = [ - 'set firewall ipv6-name INBOUND rule 101 icmpv6 type port-unreachable', - "set firewall ipv6-name INBOUND rule 101 protocol 'icmp'", - 'set firewall ipv6-name INBOUND rule 101' - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v4_rule_sets_rule_merged_icmp_01(self): - set_module_args( - dict(config=[ - dict(afi='ipv4', - rule_sets=[ - dict(name='INBOUND', - rules=[ - dict(number='101', - protocol='icmp', - icmp=dict(type=1, code=1)) - ]), - ]) - ], - state="merged")) - commands = [ - 'set firewall name INBOUND rule 101 icmp type 1', - 'set firewall name INBOUND rule 101 icmp code 1', - "set firewall name INBOUND rule 101 protocol 'icmp'", - 'set firewall name INBOUND rule 101' - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v4_rule_sets_rule_merged_icmp_02(self): - set_module_args( - dict(config=[ - dict(afi='ipv4', - rule_sets=[ - dict(name='INBOUND', - rules=[ - dict(number='101', - protocol='icmp', - icmp=dict(type_name='echo-request')) - ]), - ]) - ], - state="merged")) - commands = [ - 'set firewall name INBOUND rule 101 icmp type-name echo-request', - "set firewall name INBOUND rule 101 protocol 'icmp'", - 'set firewall name INBOUND rule 101' - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v4_rule_sets_del_01(self): - set_module_args( - dict(config=[ - dict(afi='ipv4', rule_sets=[ - dict(name='V4-INGRESS'), - ]) - ], - state="deleted")) - commands = ['delete firewall name V4-INGRESS'] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v4v6_rule_sets_del_02(self): - set_module_args( - dict(config=[ - dict(afi='ipv4', rule_sets=[ - dict(name='V4-INGRESS'), - ]), - dict(afi='ipv6', rule_sets=[ - dict(name='V6-INGRESS'), - ]) - ], - state="deleted")) - commands = [ - 'delete firewall name V4-INGRESS', - 'delete firewall ipv6-name V6-INGRESS' - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v4v6_rule_sets_del_03(self): - set_module_args(dict(config=[], state="deleted")) - commands = ['delete firewall name', 'delete firewall ipv6-name'] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v4v6_rule_sets_del_04(self): - set_module_args( - dict(config=[ - dict(afi='ipv4', rule_sets=[ - dict(name='V4-ING'), - ]), - dict(afi='ipv6', rule_sets=[ - dict(name='V6-ING'), - ]) - ], - state="deleted")) - self.execute_module(changed=False, commands=[]) - - def test_vyos_firewall_v4v6_rule_sets_rule_rep_01(self): - set_module_args( - dict(config=[ - dict(afi='ipv4', - rule_sets=[ - dict(name='V4-INGRESS', - description='This is IPv4 INGRESS rule set', - default_action='accept', - enable_default_log=True, - rules=[ - dict(number='101', - action='reject', - description='Rule 101 is configured by Ansible RM', - ipsec='match-ipsec', - protocol='tcp', - fragment='match-frag', - disabled=False), - dict(number='102', - action='accept', - description='Rule 102 is configured by Ansible RM', - protocol='icmp', - disabled=True) - ]), - ]), - dict(afi='ipv6', - rule_sets=[ - dict(name='V6-INGRESS', - default_action='accept', - description='This rule-set is configured by Ansible RM'), - dict(name='V6-EGRESS', - default_action='reject', - description='This rule-set is configured by Ansible RM') - ]) - ], - state="replaced")) - commands = [ - 'delete firewall name V4-INGRESS rule 101 disabled', - 'delete firewall name V4-EGRESS default-action', - "set firewall name V4-INGRESS description 'This is IPv4 INGRESS rule set'", - "set firewall name V4-INGRESS rule 101 protocol 'tcp'", - "set firewall name V4-INGRESS rule 101 description 'Rule 101 is configured by Ansible RM'", - "set firewall name V4-INGRESS rule 101 action 'reject'", - 'set firewall name V4-INGRESS rule 102 disabled', - "set firewall name V4-INGRESS rule 102 action 'accept'", - "set firewall name V4-INGRESS rule 102 protocol 'icmp'", - "set firewall name V4-INGRESS rule 102 description 'Rule 102 is configured by Ansible RM'", - 'set firewall name V4-INGRESS rule 102', - "set firewall ipv6-name V6-INGRESS description 'This rule-set is configured by Ansible RM'", - "set firewall ipv6-name V6-EGRESS description 'This rule-set is configured by Ansible RM'" - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v4v6_rule_sets_rule_rep_02(self): - set_module_args( - dict(config=[ - dict(afi='ipv4', - rule_sets=[ - dict(name='V4-INGRESS', - description='This is IPv4 V4-INGRESS rule set', - default_action='accept', - enable_default_log=False, - rules=[ - dict(number='101', - action='accept', - description='Rule 101 is configured by Ansible', - ipsec='match-ipsec', - protocol='icmp', - fragment='match-frag', - disabled=True), - ]), - ]), - dict(afi='ipv6', - rule_sets=[ - dict( - name='V6-INGRESS', - default_action='accept', - ), - dict( - name='V6-EGRESS', - default_action='reject', - ) - ]) - ], - state="replaced")) - commands = [ - 'delete firewall name V4-INGRESS enable-default-log', - 'delete firewall name V4-EGRESS default-action' - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v4v6_rule_sets_rule_rep_idem_01(self): - set_module_args( - dict(config=[ - dict(afi='ipv4', - rule_sets=[ - dict(name='V4-INGRESS', - description='This is IPv4 V4-INGRESS rule set', - default_action='accept', - enable_default_log=True, - rules=[ - dict(number='101', - action='accept', - description='Rule 101 is configured by Ansible', - ipsec='match-ipsec', - protocol='icmp', - fragment='match-frag', - disabled=True) - ]), - dict( - name='V4-EGRESS', - default_action='reject', - ), - ]), - dict(afi='ipv6', - rule_sets=[ - dict( - name='V6-INGRESS', - default_action='accept', - ), - dict( - name='V6-EGRESS', - default_action='reject', - ) - ]) - ], - state="replaced")) - self.execute_module(changed=False, commands=[]) - - def test_vyos_firewall_v4v6_rule_sets_rule_mer_idem_01(self): - set_module_args( - dict(config=[ - dict(afi='ipv4', - rule_sets=[ - dict(name='V4-INGRESS', - description='This is IPv4 V4-INGRESS rule set', - default_action='accept', - enable_default_log=True, - rules=[ - dict(number='101', - action='accept', - description='Rule 101 is configured by Ansible', - ipsec='match-ipsec', - protocol='icmp', - fragment='match-frag', - disabled=True) - ]), - dict( - name='V4-EGRESS', - default_action='reject', - ), - ]), - dict(afi='ipv6', - rule_sets=[ - dict( - name='V6-INGRESS', - default_action='accept', - ), - dict( - name='V6-EGRESS', - default_action='reject', - ) - ]) - ], - state="merged")) - self.execute_module(changed=False, commands=[]) - - def test_vyos_firewall_v4v6_rule_sets_rule_ovr_01(self): - set_module_args( - dict(config=[ - dict(afi='ipv4', - rule_sets=[ - dict(name='V4-IN', - description='This is IPv4 INGRESS rule set', - default_action='accept', - enable_default_log=True, - rules=[ - dict(number='1', - action='reject', - description='Rule 1 is configured by Ansible RM', - ipsec='match-ipsec', - protocol='tcp', - fragment='match-frag', - disabled=False), - dict(number='2', - action='accept', - description='Rule 102 is configured by Ansible RM', - protocol='icmp', - disabled=True) - ]), - ]), - dict(afi='ipv6', - rule_sets=[ - dict(name='V6-IN', - default_action='accept', - description='This rule-set is configured by Ansible RM'), - dict(name='V6-EG', - default_action='reject', - description='This rule-set is configured by Ansible RM') - ]) - ], - state="overridden")) - commands = [ - 'delete firewall ipv6-name V6-INGRESS', - 'delete firewall ipv6-name V6-EGRESS', - 'delete firewall name V4-INGRESS', - 'delete firewall name V4-EGRESS', - "set firewall name V4-IN default-action 'accept'", - "set firewall name V4-IN description 'This is IPv4 INGRESS rule set'", - 'set firewall name V4-IN enable-default-log', - "set firewall name V4-IN rule 1 protocol 'tcp'", - "set firewall name V4-IN rule 1 description 'Rule 1 is configured by Ansible RM'", - "set firewall name V4-IN rule 1 fragment 'match-frag'", - 'set firewall name V4-IN rule 1', - "set firewall name V4-IN rule 1 action 'reject'", - "set firewall name V4-IN rule 1 ipsec 'match-ipsec'", - 'set firewall name V4-IN rule 2 disabled', - "set firewall name V4-IN rule 2 action 'accept'", - "set firewall name V4-IN rule 2 protocol 'icmp'", - "set firewall name V4-IN rule 2 description 'Rule 102 is configured by Ansible RM'", - 'set firewall name V4-IN rule 2', - "set firewall ipv6-name V6-IN default-action 'accept'", - "set firewall ipv6-name V6-IN description 'This rule-set is configured by Ansible RM'", - "set firewall ipv6-name V6-EG default-action 'reject'", - "set firewall ipv6-name V6-EG description 'This rule-set is configured by Ansible RM'" - ] - self.execute_module(changed=True, commands=commands) - - def test_vyos_firewall_v4v6_rule_sets_rule_ovr_idem_01(self): - set_module_args( - dict(config=[ - dict(afi='ipv4', - rule_sets=[ - dict(name='V4-INGRESS', - description='This is IPv4 V4-INGRESS rule set', - default_action='accept', - enable_default_log=True, - rules=[ - dict(number='101', - action='accept', - description='Rule 101 is configured by Ansible', - ipsec='match-ipsec', - protocol='icmp', - fragment='match-frag', - disabled=True) - ]), - dict( - name='V4-EGRESS', - default_action='reject', - ), - ]), - dict(afi='ipv6', - rule_sets=[ - dict( - name='V6-INGRESS', - default_action='accept', - ), - dict( - name='V6-EGRESS', - default_action='reject', - ) - ]) - ], - state="overridden")) - self.execute_module(changed=False, commands=[]) diff --git a/test/units/modules/network/vyos/test_vyos_ping.py b/test/units/modules/network/vyos/test_vyos_ping.py deleted file mode 100644 index e12eb8a694..0000000000 --- a/test/units/modules/network/vyos/test_vyos_ping.py +++ /dev/null @@ -1,102 +0,0 @@ -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from units.compat.mock import patch -from ansible.modules.network.vyos import vyos_ping -from units.modules.utils import set_module_args -from .vyos_module import TestVyosModule, load_fixture - - -class TestVyosPingModule(TestVyosModule): - - module = vyos_ping - - def setUp(self): - super(TestVyosPingModule, self).setUp() - self.mock_run_commands = patch('ansible.modules.network.vyos.vyos_ping.run_commands') - self.run_commands = self.mock_run_commands.start() - - def tearDown(self): - super(TestVyosPingModule, self).tearDown() - self.mock_run_commands.stop() - - def load_fixtures(self, commands=None): - def load_from_file(*args, **kwargs): - commands = kwargs['commands'] - output = list() - - for command in commands: - filename = str(command).split(' | ')[0].replace(' ', '_') - output.append(load_fixture('vyos_ping_%s' % filename)) - return output - - self.run_commands.side_effect = load_from_file - - def test_vyos_ping_expected_success(self): - ''' Test for successful pings when destination should be reachable ''' - set_module_args(dict(count=2, dest="10.10.10.10")) - self.execute_module() - - def test_vyos_ping_expected_failure(self): - ''' Test for unsuccessful pings when destination should not be reachable ''' - set_module_args(dict(count=4, dest="10.10.10.20", state="absent")) - self.execute_module() - - def test_vyos_ping_unexpected_success(self): - ''' Test for successful pings when destination should not be reachable - FAIL. ''' - set_module_args(dict(count=2, dest="10.10.10.10", state="absent")) - self.execute_module(failed=True) - - def test_vyos_ping_unexpected_failure(self): - ''' Test for unsuccessful pings when destination should be reachable - FAIL. ''' - set_module_args(dict(count=4, dest="10.10.10.20")) - self.execute_module(failed=True) - - def test_vyos_ping_failure_stats(self): - '''Test for asserting stats when ping fails''' - set_module_args(dict(count=4, dest="10.10.10.20")) - result = self.execute_module(failed=True) - self.assertEqual(result['packet_loss'], '100%') - self.assertEqual(result['packets_rx'], 0) - self.assertEqual(result['packets_tx'], 4) - - def test_vyos_ping_success_stats(self): - '''Test for asserting stats when ping passes''' - set_module_args(dict(count=2, dest="10.10.10.10")) - result = self.execute_module() - self.assertEqual(result['packet_loss'], '0%') - self.assertEqual(result['packets_rx'], 2) - self.assertEqual(result['packets_tx'], 2) - self.assertEqual(result['rtt']['min'], 12) - self.assertEqual(result['rtt']['avg'], 17) - self.assertEqual(result['rtt']['max'], 22) - self.assertEqual(result['rtt']['mdev'], 10) - - def test_vyos_ping_success_stats_with_options(self): - set_module_args(dict(count=10, ttl=128, size=512, dest="10.10.10.11")) - result = self.execute_module() - self.assertEqual(result['packet_loss'], '0%') - self.assertEqual(result['packets_rx'], 10) - self.assertEqual(result['packets_tx'], 10) - self.assertEqual(result['rtt']['min'], 1) - self.assertEqual(result['rtt']['avg'], 3) - self.assertEqual(result['rtt']['max'], 21) - self.assertEqual(result['rtt']['mdev'], 5) diff --git a/test/units/modules/network/vyos/test_vyos_static_route.py b/test/units/modules/network/vyos/test_vyos_static_route.py deleted file mode 100644 index 4a592ceaca..0000000000 --- a/test/units/modules/network/vyos/test_vyos_static_route.py +++ /dev/null @@ -1,54 +0,0 @@ -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from units.compat.mock import patch -from ansible.modules.network.vyos import _vyos_static_route -from units.modules.utils import set_module_args -from .vyos_module import TestVyosModule - - -class TestVyosStaticRouteModule(TestVyosModule): - - module = _vyos_static_route - - def setUp(self): - super(TestVyosStaticRouteModule, self).setUp() - - self.mock_get_config = patch('ansible.modules.network.vyos._vyos_static_route.get_config') - self.get_config = self.mock_get_config.start() - - self.mock_load_config = patch('ansible.modules.network.vyos._vyos_static_route.load_config') - self.load_config = self.mock_load_config.start() - - def tearDown(self): - super(TestVyosStaticRouteModule, self).tearDown() - - self.mock_get_config.stop() - self.mock_load_config.stop() - - def load_fixtures(self, commands=None, transport='cli'): - self.load_config.return_value = dict(diff=None, session='session') - - def test_vyos_static_route_present(self): - set_module_args(dict(prefix='172.26.0.0/16', next_hop='172.26.4.1', admin_distance='1')) - result = self.execute_module(changed=True) - self.assertEqual(result['commands'], - ['set protocols static route 172.26.0.0/16 next-hop 172.26.4.1 distance 1']) diff --git a/test/units/modules/network/vyos/test_vyos_static_routes.py b/test/units/modules/network/vyos/test_vyos_static_routes.py deleted file mode 100644 index a2882c32d7..0000000000 --- a/test/units/modules/network/vyos/test_vyos_static_routes.py +++ /dev/null @@ -1,202 +0,0 @@ -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from units.compat.mock import patch -from ansible.modules.network.vyos import vyos_static_routes -from units.modules.utils import set_module_args -from .vyos_module import TestVyosModule, load_fixture - - -class TestVyosStaticRoutesModule(TestVyosModule): - - module = vyos_static_routes - - def setUp(self): - super(TestVyosStaticRoutesModule, self).setUp() - self.mock_get_config = patch('ansible.module_utils.network.common.network.Config.get_config') - self.get_config = self.mock_get_config.start() - - self.mock_load_config = patch('ansible.module_utils.network.common.network.Config.load_config') - self.load_config = self.mock_load_config.start() - - self.mock_get_resource_connection_config = patch('ansible.module_utils.network.common.cfg.base.get_resource_connection') - self.get_resource_connection_config = self.mock_get_resource_connection_config.start() - - self.mock_get_resource_connection_facts = patch('ansible.module_utils.network.common.facts.facts.get_resource_connection') - self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() - - self.mock_execute_show_command = patch('ansible.module_utils.network.vyos.facts.static_routes.static_routes.Static_routesFacts.get_device_data') - self.execute_show_command = self.mock_execute_show_command.start() - - def tearDown(self): - super(TestVyosStaticRoutesModule, self).tearDown() - self.mock_get_resource_connection_config.stop() - self.mock_get_resource_connection_facts.stop() - self.mock_get_config.stop() - self.mock_load_config.stop() - self.mock_execute_show_command.stop() - - def load_fixtures(self, commands=None): - def load_from_file(*args, **kwargs): - return load_fixture('vyos_static_routes_config.cfg') - self.execute_show_command.side_effect = load_from_file - - def test_vyos_static_routes_merged(self): - set_module_args( - dict(config=[ - dict(address_families=[ - dict( - afi='ipv4', - routes=[ - dict( - dest='192.0.2.48/28', - next_hops=[ - dict( - forward_router_address='192.0.2.9'), - dict(forward_router_address='192.0.2.10') - ]) - ]) - ]) - ], - state="merged")) - commands = ['set protocols static route 192.0.2.48/28', - "set protocols static route 192.0.2.48/28 next-hop '192.0.2.9'", - "set protocols static route 192.0.2.48/28 next-hop '192.0.2.10'"] - self.execute_module(changed=True, commands=commands) - - def test_vyos_static_routes_merged_idempotent(self): - set_module_args( - dict(config=[ - dict(address_families=[ - dict( - afi='ipv4', - routes=[ - dict( - dest='192.0.2.32/28', - next_hops=[ - dict( - forward_router_address='192.0.2.9'), - dict(forward_router_address='192.0.2.10') - ]) - ]) - ]) - ], - state="merged")) - self.execute_module(changed=False, commands=[]) - - def test_vyos_static_routes_replaced(self): - set_module_args( - dict(config=[ - dict(address_families=[ - dict( - afi='ipv4', - routes=[ - dict( - dest='192.0.2.48/28', - next_hops=[ - dict( - forward_router_address='192.0.2.9'), - dict(forward_router_address='192.0.2.10') - ]) - ]) - ]) - ], - state="replaced")) - commands = ["set protocols static route 192.0.2.48/28", - "set protocols static route 192.0.2.48/28 next-hop '192.0.2.9'", - "set protocols static route 192.0.2.48/28 next-hop '192.0.2.10'"] - self.execute_module(changed=True, commands=commands) - - def test_vyos_static_routes_replaced_idempotent(self): - set_module_args( - dict(config=[ - dict(address_families=[ - dict( - afi='ipv4', - routes=[ - dict( - dest='192.0.2.32/28', - next_hops=[ - dict( - forward_router_address='192.0.2.9'), - dict(forward_router_address='192.0.2.10') - ]) - ]) - ]) - ], - state="replaced")) - - self.execute_module(changed=False, commands=[]) - - def test_vyos_static_routes_overridden(self): - set_module_args( - dict(config=[ - dict(address_families=[ - dict( - afi='ipv4', - routes=[ - dict( - dest='192.0.2.48/28', - next_hops=[ - dict( - forward_router_address='192.0.2.9'), - dict(forward_router_address='192.0.2.10') - ]) - ]) - ]) - ], - state="overridden")) - commands = ['delete protocols static route 192.0.2.32/28', - 'set protocols static route 192.0.2.48/28', - "set protocols static route 192.0.2.48/28 next-hop '192.0.2.9'", - "set protocols static route 192.0.2.48/28 next-hop '192.0.2.10'"] - self.execute_module(changed=True, commands=commands) - - def test_vyos_static_routes_overridden_idempotent(self): - set_module_args( - dict(config=[ - dict(address_families=[ - dict( - afi='ipv4', - routes=[ - dict( - dest='192.0.2.32/28', - next_hops=[ - dict( - forward_router_address='192.0.2.9'), - dict(forward_router_address='192.0.2.10') - ]) - ]) - ]) - ], - state="overridden")) - self.execute_module(changed=False, commands=[]) - - def test_vyos_static_routes_deleted(self): - set_module_args( - dict(config=[ - dict(address_families=[ - dict(afi='ipv4', routes=[dict(dest='192.0.2.32/28')]) - ]) - ], - state="deleted")) - commands = ['delete protocols static route 192.0.2.32/28'] - self.execute_module(changed=True, commands=commands) diff --git a/test/units/modules/network/vyos/test_vyos_system.py b/test/units/modules/network/vyos/test_vyos_system.py deleted file mode 100644 index 1720735a3e..0000000000 --- a/test/units/modules/network/vyos/test_vyos_system.py +++ /dev/null @@ -1,97 +0,0 @@ -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from units.compat.mock import patch -from ansible.modules.network.vyos import vyos_system -from units.modules.utils import set_module_args -from .vyos_module import TestVyosModule, load_fixture - - -class TestVyosSystemModule(TestVyosModule): - - module = vyos_system - - def setUp(self): - super(TestVyosSystemModule, self).setUp() - - self.mock_get_config = patch('ansible.modules.network.vyos.vyos_system.get_config') - self.get_config = self.mock_get_config.start() - - self.mock_load_config = patch('ansible.modules.network.vyos.vyos_system.load_config') - self.load_config = self.mock_load_config.start() - - def tearDown(self): - super(TestVyosSystemModule, self).tearDown() - - self.mock_get_config.stop() - self.mock_load_config.stop() - - def load_fixtures(self, commands=None): - self.get_config.return_value = load_fixture('vyos_config_config.cfg') - - def test_vyos_system_hostname(self): - set_module_args(dict(host_name='foo')) - commands = ["set system host-name 'foo'"] - self.execute_module(changed=True, commands=commands) - - def test_vyos_system_clear_hostname(self): - set_module_args(dict(host_name='foo', state='absent')) - commands = ["delete system host-name"] - self.execute_module(changed=True, commands=commands) - - def test_vyos_remove_single_name_server(self): - set_module_args(dict(name_server=['8.8.4.4'], state='absent')) - commands = ["delete system name-server '8.8.4.4'"] - self.execute_module(changed=True, commands=commands) - - def test_vyos_system_domain_name(self): - set_module_args(dict(domain_name='example2.com')) - commands = ["set system domain-name 'example2.com'"] - self.execute_module(changed=True, commands=commands) - - def test_vyos_system_clear_domain_name(self): - set_module_args(dict(domain_name='example.com', state='absent')) - commands = ['delete system domain-name'] - self.execute_module(changed=True, commands=commands) - - def test_vyos_system_domain_search(self): - set_module_args(dict(domain_search=['foo.example.com', 'bar.example.com'])) - commands = ["set system domain-search domain 'foo.example.com'", - "set system domain-search domain 'bar.example.com'"] - self.execute_module(changed=True, commands=commands) - - def test_vyos_system_clear_domain_search(self): - set_module_args(dict(domain_search=[])) - commands = ['delete system domain-search domain'] - self.execute_module(changed=True, commands=commands) - - def test_vyos_system_no_change(self): - set_module_args(dict(host_name='router', domain_name='example.com', name_server=['8.8.8.8', '8.8.4.4'])) - result = self.execute_module() - self.assertEqual([], result['commands']) - - def test_vyos_system_clear_all(self): - set_module_args(dict(state='absent')) - commands = ['delete system host-name', - 'delete system domain-search domain', - 'delete system domain-name', - 'delete system name-server'] - self.execute_module(changed=True, commands=commands) diff --git a/test/units/modules/network/vyos/test_vyos_user.py b/test/units/modules/network/vyos/test_vyos_user.py deleted file mode 100644 index 784721c98f..0000000000 --- a/test/units/modules/network/vyos/test_vyos_user.py +++ /dev/null @@ -1,87 +0,0 @@ -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from units.compat.mock import patch -from ansible.modules.network.vyos import vyos_user -from units.modules.utils import set_module_args -from .vyos_module import TestVyosModule, load_fixture - - -class TestVyosUserModule(TestVyosModule): - - module = vyos_user - - def setUp(self): - super(TestVyosUserModule, self).setUp() - - self.mock_get_config = patch('ansible.modules.network.vyos.vyos_user.get_config') - self.get_config = self.mock_get_config.start() - - self.mock_load_config = patch('ansible.modules.network.vyos.vyos_user.load_config') - self.load_config = self.mock_load_config.start() - - def tearDown(self): - super(TestVyosUserModule, self).tearDown() - self.mock_get_config.stop() - self.mock_load_config.stop() - - def load_fixtures(self, commands=None, transport='cli'): - self.get_config.return_value = load_fixture('vyos_user_config.cfg') - self.load_config.return_value = dict(diff=None, session='session') - - def test_vyos_user_password(self): - set_module_args(dict(name='ansible', configured_password='test')) - result = self.execute_module(changed=True) - self.assertEqual(result['commands'], ['set system login user ansible authentication plaintext-password test']) - - def test_vyos_user_delete(self): - set_module_args(dict(name='ansible', state='absent')) - result = self.execute_module(changed=True) - self.assertEqual(result['commands'], ['delete system login user ansible']) - - def test_vyos_user_level(self): - set_module_args(dict(name='ansible', level='operator')) - result = self.execute_module(changed=True) - self.assertEqual(result['commands'], ['set system login user ansible level operator']) - - def test_vyos_user_level_invalid(self): - set_module_args(dict(name='ansible', level='sysadmin')) - self.execute_module(failed=True) - - def test_vyos_user_purge(self): - set_module_args(dict(purge=True)) - result = self.execute_module(changed=True) - self.assertEqual(sorted(result['commands']), sorted(['delete system login user ansible', - 'delete system login user admin'])) - - def test_vyos_user_update_password_changed(self): - set_module_args(dict(name='test', configured_password='test', update_password='on_create')) - result = self.execute_module(changed=True) - self.assertEqual(result['commands'], ['set system login user test authentication plaintext-password test']) - - def test_vyos_user_update_password_on_create_ok(self): - set_module_args(dict(name='ansible', configured_password='test', update_password='on_create')) - self.execute_module() - - def test_vyos_user_update_password_always(self): - set_module_args(dict(name='ansible', configured_password='test', update_password='always')) - result = self.execute_module(changed=True) - self.assertEqual(result['commands'], ['set system login user ansible authentication plaintext-password test']) diff --git a/test/units/modules/network/vyos/vyos_module.py b/test/units/modules/network/vyos/vyos_module.py deleted file mode 100644 index 138c684e88..0000000000 --- a/test/units/modules/network/vyos/vyos_module.py +++ /dev/null @@ -1,87 +0,0 @@ -# (c) 2016 Red Hat Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -import os -import json - -from units.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase - - -fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') -fixture_data = {} - - -def load_fixture(name): - path = os.path.join(fixture_path, name) - - if path in fixture_data: - return fixture_data[path] - - with open(path) as f: - data = f.read() - - try: - data = json.loads(data) - except Exception: - pass - - fixture_data[path] = data - return data - - -class TestVyosModule(ModuleTestCase): - - def execute_module(self, failed=False, changed=False, commands=None, sort=True, defaults=False): - self.load_fixtures(commands) - - if failed: - result = self.failed() - self.assertTrue(result['failed'], result) - else: - result = self.changed(changed) - self.assertEqual(result['changed'], changed, result) - - if commands is not None: - if sort: - self.assertEqual(sorted(commands), sorted(result['commands']), result['commands']) - else: - self.assertEqual(commands, result['commands'], result['commands']) - - return result - - def failed(self): - with self.assertRaises(AnsibleFailJson) as exc: - self.module.main() - - result = exc.exception.args[0] - self.assertTrue(result['failed'], result) - return result - - def changed(self, changed=False): - with self.assertRaises(AnsibleExitJson) as exc: - self.module.main() - - result = exc.exception.args[0] - self.assertEqual(result['changed'], changed, result) - return result - - def load_fixtures(self, commands=None): - pass |