diff options
Diffstat (limited to 'ansible_collections/community/routeros/tests/ee')
4 files changed, 126 insertions, 0 deletions
diff --git a/ansible_collections/community/routeros/tests/ee/all.yml b/ansible_collections/community/routeros/tests/ee/all.yml new file mode 100644 index 00000000..26f198b4 --- /dev/null +++ b/ansible_collections/community/routeros/tests/ee/all.yml @@ -0,0 +1,18 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- hosts: localhost + tasks: + - name: Find all roles + find: + paths: + - "{{ (playbook_dir | default('.')) ~ '/roles' }}" + file_type: directory + depth: 1 + register: result + - name: Include all roles + include_role: + name: "{{ item }}" + loop: "{{ result.files | map(attribute='path') | map('regex_replace', '.*/', '') | sort }}" diff --git a/ansible_collections/community/routeros/tests/ee/roles/filter_quoting/aliases b/ansible_collections/community/routeros/tests/ee/roles/filter_quoting/aliases new file mode 100644 index 00000000..ddba8181 --- /dev/null +++ b/ansible_collections/community/routeros/tests/ee/roles/filter_quoting/aliases @@ -0,0 +1,6 @@ +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +shippable/posix/group1 +skip/python2.6 diff --git a/ansible_collections/community/routeros/tests/ee/roles/filter_quoting/tasks/main.yml b/ansible_collections/community/routeros/tests/ee/roles/filter_quoting/tasks/main.yml new file mode 100644 index 00000000..e7a2d29a --- /dev/null +++ b/ansible_collections/community/routeros/tests/ee/roles/filter_quoting/tasks/main.yml @@ -0,0 +1,63 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- name: "Test split filter" + assert: + that: + - "'' | community.routeros.split == []" + - "'foo bar' | community.routeros.split == ['foo', 'bar']" + - > + 'foo bar="a b c"' | community.routeros.split == ['foo', 'bar=a b c'] + +- name: "Test split filter error handling" + set_fact: + test: >- + {{ 'a="' | community.routeros.split }} + ignore_errors: true + register: result + +- name: "Verify split filter error handling" + assert: + that: + - >- + result.msg == "Unexpected end of string during escaped parameter" + +- name: "Test quote_argument filter" + assert: + that: + - > + 'a=' | community.routeros.quote_argument == 'a=""' + - > + 'a=b' | community.routeros.quote_argument == 'a=b' + - > + 'a=b c' | community.routeros.quote_argument == 'a="b\\_c"' + - > + 'a=""' | community.routeros.quote_argument == 'a="\\"\\""' + +- name: "Test quote_argument_value filter" + assert: + that: + - > + '' | community.routeros.quote_argument_value == '""' + - > + 'foo' | community.routeros.quote_argument_value == 'foo' + - > + '"foo bar"' | community.routeros.quote_argument_value == '"\\"foo\\_bar\\""' + +- name: "Test join filter" + assert: + that: + - > + ['a=', 'b=c d'] | community.routeros.join == 'a="" b="c\\_d"' + +- name: "Test list_to_dict filter" + assert: + that: + - > + ['a=', 'b=c'] | community.routeros.list_to_dict == {'a': '', 'b': 'c'} + - > + ['a=', 'b=c'] | community.routeros.list_to_dict(skip_empty_values=True) == {'b': 'c'} + - > + ['a', 'b=c'] | community.routeros.list_to_dict(require_assignment=False) == {'a': none, 'b': 'c'} diff --git a/ansible_collections/community/routeros/tests/ee/roles/smoke/tasks/main.yml b/ansible_collections/community/routeros/tests/ee/roles/smoke/tasks/main.yml new file mode 100644 index 00000000..072f4cc2 --- /dev/null +++ b/ansible_collections/community/routeros/tests/ee/roles/smoke/tasks/main.yml @@ -0,0 +1,39 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- name: Run api module + community.routeros.api: + username: foo + password: bar + hostname: localhost + path: ip address + ignore_errors: true + register: result + +- name: Validate result + assert: + that: + - result is failed + - "'Error while connecting: [Errno 111] Connection refused' == result.msg" + +- name: Run command module + community.routeros.command: + commands: + - /ip address print + vars: + ansible_host: localhost + ansible_connection: ansible.netcommon.network_cli + ansible_network_os: community.routeros.routeros + ansible_user: foo + ansible_ssh_pass: bar + ansible_ssh_port: 12349 + ignore_errors: true + register: result + +- name: Validate result + assert: + that: + - result is failed + - "'Unable to connect to port 12349 ' in result.msg or 'ssh connect failed: Connection refused' in result.msg" |