summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/dns/tests/unit
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-26 04:05:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-26 04:05:56 +0000
commit67c6a4d1dccb62159b9d9b2dea4e2f487446e276 (patch)
tree9ccbb35137f480bbbdb899accbda52a8135d3416 /ansible_collections/community/dns/tests/unit
parentAdding upstream version 9.4.0+dfsg. (diff)
downloadansible-67c6a4d1dccb62159b9d9b2dea4e2f487446e276.tar.xz
ansible-67c6a4d1dccb62159b9d9b2dea4e2f487446e276.zip
Adding upstream version 9.5.1+dfsg.upstream/9.5.1+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/dns/tests/unit')
-rw-r--r--ansible_collections/community/dns/tests/unit/plugins/inventory/test_hetzner_dns_records.py72
-rw-r--r--ansible_collections/community/dns/tests/unit/plugins/inventory/test_hosttech_dns_records.py76
-rw-r--r--ansible_collections/community/dns/tests/unit/requirements-stable-2.10.txt2
3 files changed, 143 insertions, 7 deletions
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