diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-26 04:05:57 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-26 04:05:57 +0000 |
commit | 0dcbb2c58231264c2f0a0374733b5e9cf8747e1f (patch) | |
tree | 7f133117f9ebecefdc96e42e01ee7557247d5d8a /ansible_collections/community/dns/tests | |
parent | Adding debian version 9.4.0+dfsg-1. (diff) | |
download | ansible-0dcbb2c58231264c2f0a0374733b5e9cf8747e1f.tar.xz ansible-0dcbb2c58231264c2f0a0374733b5e9cf8747e1f.zip |
Merging upstream version 9.5.1+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/dns/tests')
7 files changed, 202 insertions, 7 deletions
diff --git a/ansible_collections/community/dns/tests/integration/targets/filter_txt/aliases b/ansible_collections/community/dns/tests/integration/targets/filter_txt/aliases new file mode 100644 index 000000000..b7419a24d --- /dev/null +++ b/ansible_collections/community/dns/tests/integration/targets/filter_txt/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 # filters are controller only, and we no longer support Python 2.6 on the controller diff --git a/ansible_collections/community/dns/tests/integration/targets/filter_txt/tasks/main.yml b/ansible_collections/community/dns/tests/integration/targets/filter_txt/tasks/main.yml new file mode 100644 index 000000000..c0afffcea --- /dev/null +++ b/ansible_collections/community/dns/tests/integration/targets/filter_txt/tasks/main.yml @@ -0,0 +1,49 @@ +--- +# 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 quote_txt filter" + assert: + that: + - >- + '' | community.dns.quote_txt == '""' + - >- + "this is a test" | community.dns.quote_txt == '"this is a test"' + - >- + "test" | community.dns.quote_txt == 'test' + - >- + "test" | community.dns.quote_txt(always_quote=true) == '"test"' + - >- + '"' | community.dns.quote_txt == '\\"' + - >- + ' ' | community.dns.quote_txt == '" "' + - >- + "ä" | community.dns.quote_txt() == '\\195\\164' + - >- + "ä" | community.dns.quote_txt(character_encoding='octal') == '\\303\\244' + - >- + "ä" | community.dns.quote_txt(character_encoding='octal', always_quote=true) == '"\\303\\244"' + - >- + very_long_input | community.dns.quote_txt == very_long_output + vars: + very_long_input: >- + this is a very1, very2, very3, very4, very5, very6, very7, very8, very9, very10, very11, very12, very13, very14, very15, + very16, very17, very18, very19, very20, very21, very22, very23, very24, very25, very26, very27, very28, very29, very30, + very31, very32, very33, very34, very35, very36, very37, very38, very39 long text + very_long_output: >- + "this is a very1, very2, very3, very4, very5, very6, very7, very8, very9, very10, very11, very12, very13, very14, very15, + very16, very17, very18, very19, very20, very21, very22, very23, very24, very25, very26, very27, very28, very29, very30, + very31, very32" ", very33, very34, very35, very36, very37, very38, very39 long text" + +- name: "Test unquote_txt filter" + assert: + that: + - >- + '' | community.dns.unquote_txt == '' + - >- + '""' | community.dns.unquote_txt == '' + - > + '"foo" "bar"' | community.dns.unquote_txt == "foobar" + - > + 'foo "bar baz" bam' | community.dns.unquote_txt == "foobar bazbam" diff --git a/ansible_collections/community/dns/tests/sanity/ignore-2.18.txt b/ansible_collections/community/dns/tests/sanity/ignore-2.18.txt new file mode 100644 index 000000000..dc9da1161 --- /dev/null +++ b/ansible_collections/community/dns/tests/sanity/ignore-2.18.txt @@ -0,0 +1 @@ +plugins/public_suffix_list.dat no-smart-quotes diff --git a/ansible_collections/community/dns/tests/sanity/ignore-2.18.txt.license b/ansible_collections/community/dns/tests/sanity/ignore-2.18.txt.license new file mode 100644 index 000000000..edff8c768 --- /dev/null +++ b/ansible_collections/community/dns/tests/sanity/ignore-2.18.txt.license @@ -0,0 +1,3 @@ +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 +SPDX-FileCopyrightText: Ansible Project diff --git a/ansible_collections/community/dns/tests/unit/plugins/inventory/test_hetzner_dns_records.py b/ansible_collections/community/dns/tests/unit/plugins/inventory/test_hetzner_dns_records.py index bfaa4886d..44f694708 100644 --- a/ansible_collections/community/dns/tests/unit/plugins/inventory/test_hetzner_dns_records.py +++ b/ansible_collections/community/dns/tests/unit/plugins/inventory/test_hetzner_dns_records.py @@ -108,6 +108,68 @@ HETZNER_JSON_DEFAULT_ENTRIES = [ }, ] +HETZNER_JSON_DEFAULT_ENTRIES_UNSAFE = [ + { + 'id': '125', + 'type': 'A', + 'name': '@', + 'value': '1.2.{3.4', + 'ttl': 3600, + 'zone_id': '42', + 'created': '2021-07-09T11:18:37Z', + 'modified': '2021-07-09T11:18:37Z', + }, + { + 'id': '126', + 'type': 'A', + 'name': '*', + 'value': '1.2.{3.5', + 'ttl': 3600, + 'zone_id': '42', + 'created': '2021-07-09T11:18:37Z', + 'modified': '2021-07-09T11:18:37Z', + }, + { + 'id': '127', + 'type': 'AAAA', + 'name': '@', + 'value': '2001:1:2::{3', + 'ttl': 3600, + 'zone_id': '42', + 'created': '2021-07-09T11:18:37Z', + 'modified': '2021-07-09T11:18:37Z', + }, + { + 'id': '128', + 'type': 'AAAA', + 'name': 'foo', + 'value': '2001:1:2::{4', + 'ttl': 3600, + 'zone_id': '42', + 'created': '2021-07-09T11:18:37Z', + 'modified': '2021-07-09T11:18:37Z', + }, + { + 'id': '129', + 'type': 'MX', + 'name': '@', + 'value': '10 example.com', + 'ttl': 3600, + 'zone_id': '42', + 'created': '2021-07-09T11:18:37Z', + 'modified': '2021-07-09T11:18:37Z', + }, + { + 'id': '130', + 'type': 'CNAME', + 'name': 'bar', + 'value': 'example.org.', + 'zone_id': '42', + 'created': '2021-07-09T11:18:37Z', + 'modified': '2021-07-09T11:18:37Z', + }, +] + HETZNER_JSON_BAD_ENTRIES = [ { 'id': '125', @@ -135,6 +197,10 @@ HETZNER_JSON_ZONE_RECORDS_GET_RESULT = { 'records': HETZNER_JSON_DEFAULT_ENTRIES, } +HETZNER_JSON_ZONE_RECORDS_GET_RESULT_UNSAFE = { + 'records': HETZNER_JSON_DEFAULT_ENTRIES_UNSAFE, +} + HETZNER_JSON_ZONE_RECORDS_GET_RESULT_2 = { 'records': HETZNER_JSON_BAD_ENTRIES, } @@ -190,7 +256,7 @@ def test_inventory_file_simple(mocker): .expect_query_values('page', '1') .expect_query_values('per_page', '100') .return_header('Content-Type', 'application/json') - .result_json(HETZNER_JSON_ZONE_RECORDS_GET_RESULT), + .result_json(HETZNER_JSON_ZONE_RECORDS_GET_RESULT_UNSAFE), ]) mocker.patch('ansible_collections.community.dns.plugins.module_utils.http.open_url', open_url) mocker.patch('ansible.inventory.manager.unfrackpath', mock_unfrackpath_noop) @@ -207,8 +273,8 @@ def test_inventory_file_simple(mocker): assert 'bar.example.com' not in im._inventory.hosts assert im._inventory.get_host('example.com') in im._inventory.groups['ungrouped'].hosts assert im._inventory.get_host('*.example.com') in im._inventory.groups['ungrouped'].hosts - assert im._inventory.get_host('example.com').get_vars()['ansible_host'] == '1.2.3.4' - assert im._inventory.get_host('*.example.com').get_vars()['ansible_host'] == '1.2.3.5' + assert im._inventory.get_host('example.com').get_vars()['ansible_host'] == '1.2.{3.4' + assert im._inventory.get_host('*.example.com').get_vars()['ansible_host'] == '1.2.{3.5' assert isinstance(im._inventory.get_host('example.com').get_vars()['ansible_host'], AnsibleUnsafe) assert isinstance(im._inventory.get_host('*.example.com').get_vars()['ansible_host'], AnsibleUnsafe) assert len(im._inventory.groups['ungrouped'].hosts) == 2 diff --git a/ansible_collections/community/dns/tests/unit/plugins/inventory/test_hosttech_dns_records.py b/ansible_collections/community/dns/tests/unit/plugins/inventory/test_hosttech_dns_records.py index cefd02a06..11995198c 100644 --- a/ansible_collections/community/dns/tests/unit/plugins/inventory/test_hosttech_dns_records.py +++ b/ansible_collections/community/dns/tests/unit/plugins/inventory/test_hosttech_dns_records.py @@ -89,6 +89,64 @@ HOSTTECH_JSON_DEFAULT_ENTRIES = [ }, ] +HOSTTECH_JSON_DEFAULT_ENTRIES_UNSAFE = [ + # (125, 42, 'A', '', '1.2.{3.4', 3600, None, None), + { + 'id': 125, + 'type': 'A', + 'name': '', + 'ipv4': '1.2.{3.4', + 'ttl': 3600, + 'comment': '', + }, + # (126, 42, 'A', '*', '1.2.{3.5', 3600, None, None), + { + 'id': 126, + 'type': 'A', + 'name': '*', + 'ipv4': '1.2.{3.5', + 'ttl': 3600, + 'comment': '', + }, + # (127, 42, 'AAAA', '', '2001:1:2::{3', 3600, None, None), + { + 'id': 127, + 'type': 'AAAA', + 'name': '', + 'ipv6': '2001:1:2::{3', + 'ttl': 3600, + 'comment': '', + }, + # (128, 42, 'AAAA', '*', '2001:1:2::{4', 3600, None, None), + { + 'id': 128, + 'type': 'AAAA', + 'name': 'foo', + 'ipv6': '2001:1:2::{4', + 'ttl': 3600, + 'comment': '', + }, + # (129, 42, 'MX', '', 'example.com', 3600, None, '10'), + { + 'id': 129, + 'type': 'MX', + 'ownername': '', + 'name': 'example.com', + 'pref': 10, + 'ttl': 3600, + 'comment': '', + }, + # (130, 42, 'CNAME', 'bar', 'example.org.', 10800, None, None), + { + 'id': 130, + 'type': 'CNAME', + 'name': 'bar', + 'cname': 'example.org.', + 'ttl': 10800, + 'comment': '', + }, +] + HOSTTECH_JSON_ZONE_LIST_RESULT = { "data": [ @@ -119,6 +177,18 @@ HOSTTECH_JSON_ZONE_RECORDS_GET_RESULT = { "data": HOSTTECH_JSON_DEFAULT_ENTRIES, } +HOSTTECH_JSON_ZONE_GET_RESULT_UNSAFE = { + "data": { + "id": 42, + "name": "example.com", + "email": "test@example.com", + "ttl": 10800, + "nameserver": "ns1.hosttech.ch", + "dnssec": False, + "records": HOSTTECH_JSON_DEFAULT_ENTRIES_UNSAFE, + } +} + original_exists = os.path.exists original_access = os.access @@ -167,7 +237,7 @@ def test_inventory_file_simple(mocker): .expect_header('authorization', 'Bearer foo') .expect_url('https://api.ns1.hosttech.eu/api/user/v1/zones/42') .return_header('Content-Type', 'application/json') - .result_json(HOSTTECH_JSON_ZONE_GET_RESULT), + .result_json(HOSTTECH_JSON_ZONE_GET_RESULT_UNSAFE), ]) mocker.patch('ansible_collections.community.dns.plugins.module_utils.http.open_url', open_url) mocker.patch('ansible.inventory.manager.unfrackpath', mock_unfrackpath_noop) @@ -184,8 +254,8 @@ def test_inventory_file_simple(mocker): assert 'bar.example.com' not in im._inventory.hosts assert im._inventory.get_host('example.com') in im._inventory.groups['ungrouped'].hosts assert im._inventory.get_host('*.example.com') in im._inventory.groups['ungrouped'].hosts - assert im._inventory.get_host('example.com').get_vars()['ansible_host'] == '1.2.3.4' - assert im._inventory.get_host('*.example.com').get_vars()['ansible_host'] == '1.2.3.5' + assert im._inventory.get_host('example.com').get_vars()['ansible_host'] == '1.2.{3.4' + assert im._inventory.get_host('*.example.com').get_vars()['ansible_host'] == '1.2.{3.5' assert isinstance(im._inventory.get_host('example.com').get_vars()['ansible_host'], AnsibleUnsafe) assert isinstance(im._inventory.get_host('*.example.com').get_vars()['ansible_host'], AnsibleUnsafe) assert len(im._inventory.groups['ungrouped'].hosts) == 2 diff --git a/ansible_collections/community/dns/tests/unit/requirements-stable-2.10.txt b/ansible_collections/community/dns/tests/unit/requirements-stable-2.10.txt index 126caabdc..49df5eff9 100644 --- a/ansible_collections/community/dns/tests/unit/requirements-stable-2.10.txt +++ b/ansible_collections/community/dns/tests/unit/requirements-stable-2.10.txt @@ -10,4 +10,4 @@ ipaddress ; python_version < '3.3' dnspython < 2.4.0 lxml < 4.3.0 ; python_version < '2.7' # lxml 4.3.0 and later require python 2.7 or later -lxml ; python_version >= '2.7' +lxml < 5.2.0 ; python_version >= '2.7' # lxml 5.2.0 does fail with Python 3.6 due to TOML loading failure |