diff options
| author | omnom62 <75066712+omnom62@users.noreply.github.com> | 2026-08-27 04:19:30 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-26 21:19:30 +0300 |
| commit | 860b54cbf0f6a13b43a487f41467ab2c4d60d647 (patch) | |
| tree | 059b072fcf9521a34562d3279076b82f131b8eb8 | |
| parent | 433a274ce636573953f8a4be9c68743a2ed1d0a5 (diff) | |
| download | vyos.vyos-860b54cbf0f6a13b43a487f41467ab2c4d60d647.tar.gz vyos.vyos-860b54cbf0f6a13b43a487f41467ab2c4d60d647.zip | |
T9053: fixes to vyos_config test cases (#487)
* T9053: fixes to vyos_module
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Viacheslav Hletenko <v.gletenko@vyos.io>
5 files changed, 93 insertions, 55 deletions
diff --git a/changelogs/fragments/t9053_vyos_module_bugfix.yml b/changelogs/fragments/t9053_vyos_module_bugfix.yml new file mode 100644 index 00000000..b8d0a3d9 --- /dev/null +++ b/changelogs/fragments/t9053_vyos_module_bugfix.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - vyos_config.py - Fixing test case diff --git a/tests/integration/targets/vyos_config/tests/cli/backup.yaml b/tests/integration/targets/vyos_config/tests/cli/backup.yaml index adfa2ad7..3bcd5d35 100644 --- a/tests/integration/targets/vyos_config/tests/cli/backup.yaml +++ b/tests/integration/targets/vyos_config/tests/cli/backup.yaml @@ -2,17 +2,18 @@ - debug: msg="START vyos/backup.yaml on connection={{ ansible_connection }}" - name: collect any backup files - find: + ansible.builtin.find: paths: "{{ role_path }}/backup" pattern: "{{ inventory_hostname_short }}_config*" register: backup_files connection: local - name: delete backup files - file: + ansible.builtin.file: path: "{{ item.path }}" state: absent with_items: "{{ backup_files.files|default([]) }}" + connection: local - name: take configure backup register: result @@ -24,7 +25,7 @@ - result.changed == true - name: collect any backup files - find: + ansible.builtin.find: paths: "{{ role_path }}/backup" pattern: "{{ inventory_hostname_short }}_config*" register: backup_files @@ -35,13 +36,14 @@ - backup_files.files is defined - name: delete configurable backup file path - file: + ansible.builtin.file: path: "{{ item }}" state: absent with_items: - "{{ role_path }}/backup_test_dir/" - "{{ role_path }}/backup/backup.cfg" run_once: true + connection: local - name: take configuration backup in custom filename and directory path register: result @@ -56,7 +58,7 @@ - result.changed == true - name: check if the backup file-1 exist - find: + ansible.builtin.find: paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg" register: backup_file connection: local @@ -77,7 +79,7 @@ - result.changed == true - name: check if the backup file-2 exist - find: + ansible.builtin.find: paths: "{{ role_path }}/backup/backup.cfg" register: backup_file connection: local @@ -98,7 +100,7 @@ - result.changed == true - name: check if the backup file-3 exist - find: + ansible.builtin.find: paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" pattern: "{{ inventory_hostname_short }}_config*" register: backup_file diff --git a/tests/integration/targets/vyos_config/tests/cli/check_config.yaml b/tests/integration/targets/vyos_config/tests/cli/check_config.yaml index 83a62197..a03a3115 100644 --- a/tests/integration/targets/vyos_config/tests/cli/check_config.yaml +++ b/tests/integration/targets/vyos_config/tests/cli/check_config.yaml @@ -41,51 +41,71 @@ that: - result.changed == false -- name: check multiple line config filter is working - register: result +- name: setup- ensure test login accounts are not present vyos.vyos.vyos_config: lines: - - set system login user esa full-name 'ESA admin' - - set system login user esa authentication encrypted-password '!abc!' - - set system login user vyos full-name 'VyOS admin' - - set system login user vyos authentication encrypted-password 'abc' - - set system login user john full-name 'John' - - set system login user john authentication plaintext-password 'xyz' + - delete system login user testesa + - delete system login user testadmin + - delete system login user testjohn + match: none + ignore_errors: true -- assert: - that: - - result.filtered|length == 2 +- block: + - name: check multiple line config filter is working + register: result + vyos.vyos.vyos_config: + lines: + - set system login user testesa full-name 'ESA admin' + - set system login user testesa authentication encrypted-password '!abc!' + - set system login user testadmin full-name 'Test admin' + - set system login user testadmin authentication encrypted-password 'abc' + - set system login user testjohn full-name 'John' + - set system login user testjohn authentication plaintext-password 'xyz' -- name: check multiple line config filter is working - register: result - vyos.vyos.vyos_config: - allow_password_change: none - lines: - - set system login user esa full-name 'ESA admin' - - set system login user esa authentication encrypted-password '!abc!' - - set system login user vyos full-name 'VyOS admin' - - set system login user vyos authentication encrypted-password 'abc' - - set system login user john full-name 'John' - - set system login user john authentication plaintext-password 'xyz' + - assert: + that: + - result.filtered|length == 2 -- assert: - that: - - result.filtered|length == 3 + - name: check multiple line config filter is working + register: result + vyos.vyos.vyos_config: + allow_password_change: none + lines: + - set system login user testesa full-name 'ESA admin' + - set system login user testesa authentication encrypted-password '!abc!' + - set system login user testadmin full-name 'Test admin' + - set system login user testadmin authentication encrypted-password 'abc' + - set system login user testjohn full-name 'John' + - set system login user testjohn authentication plaintext-password 'xyz' -- name: check multiple line config filter is working - register: result - vyos.vyos.vyos_config: - allow_password_change: all - lines: - - set system login user esa full-name 'ESA admin' - - set system login user esa authentication encrypted-password '!abc!' - - set system login user vyos full-name 'VyOS admin' - - set system login user vyos authentication encrypted-password 'abc' - - set system login user john full-name 'John' - - set system login user john authentication plaintext-password 'xyz' + - assert: + that: + - result.filtered|length == 3 -- assert: - that: - - result.filtered|length == 0 + - name: check multiple line config filter is working + register: result + vyos.vyos.vyos_config: + allow_password_change: all + lines: + - set system login user testesa full-name 'ESA admin' + - set system login user testesa authentication encrypted-password '$5$jR0jeXg3jHzSN7k3$33fO1qz3CVzsWJhxksLE7.KTIizYWGAMsd6LH9ItJmB' + - set system login user testadmin full-name 'Test admin' + - set system login user testadmin authentication encrypted-password '$5$YVhfNdmQbKQpDROb$N1b2nKh69wvrtQu7JwiIp/IsWlLHU8QCDcNGVaRWh6.' + - set system login user testjohn full-name 'John' + - set system login user testjohn authentication plaintext-password 'xyz' + + - assert: + that: + - result.filtered|length == 0 + + always: + - name: cleanup test login accounts created by password filter checks + vyos.vyos.vyos_config: + lines: + - delete system login user testesa + - delete system login user testadmin + - delete system login user testjohn + match: none + ignore_errors: true - debug: msg="END cli/config_check.yaml on connection={{ ansible_connection }}" diff --git a/tests/integration/targets/vyos_config/tests/cli/confirm.yaml b/tests/integration/targets/vyos_config/tests/cli/confirm.yaml index 73674a17..a7a3cff4 100644 --- a/tests/integration/targets/vyos_config/tests/cli/confirm.yaml +++ b/tests/integration/targets/vyos_config/tests/cli/confirm.yaml @@ -28,13 +28,24 @@ that: - "'foo' in hostname_after.stdout[0]" +- name: pause to allow confirm timeout to elapse and device to revert/reboot + pause: + seconds: 75 + +- name: reset connection to avoid stale ssh channel after device reboot + meta: reset_connection + - name: wait until config auto-reverts (no confirmation) register: hostname_reverted vyos.vyos.vyos_command: commands: show host name retries: 18 - delay: 5 - until: inventory_hostname_short in hostname_reverted.stdout[0] + delay: 10 + until: hostname_reverted is succeeded and inventory_hostname_short in hostname_reverted.stdout[0] + ignore_unreachable: true + +- name: reset connection after device reboot recovery + meta: reset_connection - name: teardown vyos.vyos.vyos_config: diff --git a/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml b/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml index 03450c31..681a22ee 100644 --- a/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml +++ b/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml @@ -2,26 +2,28 @@ - debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}" - name: delete configurable backup file path - file: + ansible.builtin.file: path: "{{ item }}" state: absent with_items: - "{{ role_path }}/backup_test_dir/" - "{{ role_path }}/backup/backup.cfg" run_once: true + connection: local - name: collect any backup files - find: + ansible.builtin.find: paths: "{{ role_path }}/backup" pattern: "{{ inventory_hostname_short }}_config*" register: backup_files connection: local - name: delete backup files - file: + ansible.builtin.file: path: "{{ item.path }}" state: absent with_items: "{{backup_files.files|default([])}}" + connection: local - name: take config backup register: result @@ -33,7 +35,7 @@ - result.changed == true - name: collect any backup files - find: + ansible.builtin.find: paths: "{{ role_path }}/backup" pattern: "{{ inventory_hostname_short }}_config*" register: backup_files @@ -56,7 +58,7 @@ - result.changed == true - name: check if the backup file-1 exist - find: + ansible.builtin.find: paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg" register: backup_file connection: local @@ -77,7 +79,7 @@ - result.changed == true - name: check if the backup file-2 exist - find: + ansible.builtin.find: paths: "{{ role_path }}/backup/backup.cfg" register: backup_file connection: local @@ -98,7 +100,7 @@ - result.changed == true - name: check if the backup file-3 exist - find: + ansible.builtin.find: paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" pattern: "{{ inventory_hostname_short }}_config*" register: backup_file |
