summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/dns/tests/ee
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:04:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:04:41 +0000
commit975f66f2eebe9dadba04f275774d4ab83f74cf25 (patch)
tree89bd26a93aaae6a25749145b7e4bca4a1e75b2be /ansible_collections/community/dns/tests/ee
parentInitial commit. (diff)
downloadansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.tar.xz
ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.zip
Adding upstream version 7.7.0+dfsg.upstream/7.7.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/dns/tests/ee')
-rw-r--r--ansible_collections/community/dns/tests/ee/all.yml18
-rw-r--r--ansible_collections/community/dns/tests/ee/roles/filter_domain_suffix/tasks/main.yml78
-rw-r--r--ansible_collections/community/dns/tests/ee/roles/wait_for_txt/tasks/main.yml77
3 files changed, 173 insertions, 0 deletions
diff --git a/ansible_collections/community/dns/tests/ee/all.yml b/ansible_collections/community/dns/tests/ee/all.yml
new file mode 100644
index 000000000..26f198b4f
--- /dev/null
+++ b/ansible_collections/community/dns/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/dns/tests/ee/roles/filter_domain_suffix/tasks/main.yml b/ansible_collections/community/dns/tests/ee/roles/filter_domain_suffix/tasks/main.yml
new file mode 100644
index 000000000..4473a743a
--- /dev/null
+++ b/ansible_collections/community/dns/tests/ee/roles/filter_domain_suffix/tasks/main.yml
@@ -0,0 +1,78 @@
+---
+# 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 get_public_suffix filter"
+ assert:
+ that:
+ - "'' | community.dns.get_public_suffix == ''"
+ - "'' | community.dns.get_public_suffix(keep_leading_period=false) == ''"
+ - "'www.ansible.com' | community.dns.get_public_suffix == '.com'"
+ - "'www.ansible.com' | community.dns.get_public_suffix(keep_leading_period=false) == 'com'"
+ - "'some.random.prefixes.ansible.co.uk' | community.dns.get_public_suffix == '.co.uk'"
+ - "'no.known.suffixafdlkjsaflkjsaflkjslkjfds' | community.dns.get_public_suffix == '.suffixafdlkjsaflkjsaflkjslkjfds'"
+ - "'no.known.suffixafdlkjsaflkjsaflkjslkjfds' | community.dns.get_public_suffix(keep_unknown_suffix=False) == ''"
+ - "'ëçãmplê' | community.dns.get_public_suffix(normalize_result=True) == 'xn--mpl-llatwb'"
+ - "'www.example.cloudfront.net' | community.dns.get_public_suffix(icann_only=false) == '.cloudfront.net'"
+ - "'www.example.cloudfront.net' | community.dns.get_public_suffix(icann_only=true) == '.net'"
+ - "'www.ck' | community.dns.get_public_suffix == '.ck'"
+ - "'thisisaninvalidlabelbecauseitiswaytoolongitscharacterlengthislargerthan63' | community.dns.get_public_suffix == ''"
+
+- name: "Test remove_public_suffix filter"
+ assert:
+ that:
+ - "'' | community.dns.remove_public_suffix == ''"
+ - "'' | community.dns.remove_public_suffix(keep_trailing_period=true) == ''"
+ - "'com' | community.dns.remove_public_suffix == ''"
+ - "'com' | community.dns.remove_public_suffix(keep_trailing_period=true) == ''"
+ - "'www.ansible.com' | community.dns.remove_public_suffix == 'www.ansible'"
+ - "'www.ansible.com' | community.dns.remove_public_suffix(keep_trailing_period=true) == 'www.ansible.'"
+ - "'some.random.prefixes.ansible.co.uk' | community.dns.remove_public_suffix == 'some.random.prefixes.ansible'"
+ - "'no.known.suffixafdlkjsaflkjsaflkjslkjfds' | community.dns.remove_public_suffix == 'no.known'"
+ - "'no.known.suffixafdlkjsaflkjsaflkjslkjfds' | community.dns.remove_public_suffix(keep_unknown_suffix=False) == 'no.known.suffixafdlkjsaflkjsaflkjslkjfds'"
+ - "'www.example.cloudfront.net' | community.dns.remove_public_suffix(icann_only=false) == 'www.example'"
+ - "'www.example.cloudfront.net' | community.dns.remove_public_suffix(icann_only=true) == 'www.example.cloudfront'"
+ - "'www.ck' | community.dns.remove_public_suffix == 'www'"
+ - "'thisisaninvalidlabelbecauseitiswaytoolongitscharacterlengthislargerthan63' | community.dns.remove_public_suffix == 'thisisaninvalidlabelbecauseitiswaytoolongitscharacterlengthislargerthan63'"
+
+- name: "Test get_registrable_domain filter"
+ assert:
+ that:
+ - "'' | community.dns.get_registrable_domain == ''"
+ - "'com' | community.dns.get_registrable_domain == ''"
+ - "'com' | community.dns.get_registrable_domain(only_if_registerable=true) == ''"
+ - "'com' | community.dns.get_registrable_domain(only_if_registerable=false) == 'com'"
+ - "'www.ansible.com' | community.dns.get_registrable_domain == 'ansible.com'"
+ - "'www.ansible.com.' | community.dns.get_registrable_domain == 'ansible.com.'"
+ - "'www.ansible.com' | community.dns.get_registrable_domain(only_if_registerable=true) == 'ansible.com'"
+ - "'some.random.prefixes.ansible.co.uk' | community.dns.get_registrable_domain == 'ansible.co.uk'"
+ - "'some.invalid.example' | community.dns.get_registrable_domain == 'invalid.example'"
+ - "'some.invalid.example' | community.dns.get_registrable_domain(keep_unknown_suffix=False) == ''"
+ - "'ëçãmplê.com' | community.dns.get_registrable_domain(normalize_result=True) == 'xn--mpl-llatwb.com'"
+ - "'www.example.cloudfront.net' | community.dns.get_registrable_domain(icann_only=false) == 'example.cloudfront.net'"
+ - "'www.example.cloudfront.net' | community.dns.get_registrable_domain(icann_only=true) == 'cloudfront.net'"
+ - "'prefix.www.ck' | community.dns.get_registrable_domain == 'www.ck'"
+ - "'thisisaninvalidlabelbecauseitiswaytoolongitscharacterlengthislargerthan63' | community.dns.get_registrable_domain == ''"
+
+- name: "Test remove_registrable_domain filter"
+ assert:
+ that:
+ - "'' | community.dns.remove_registrable_domain == ''"
+ - "'' | community.dns.remove_registrable_domain(keep_trailing_period=true) == ''"
+ - "'com' | community.dns.remove_registrable_domain == 'com'"
+ - "'com' | community.dns.remove_registrable_domain(only_if_registerable=true) == 'com'"
+ - "'com' | community.dns.remove_registrable_domain(only_if_registerable=false) == ''"
+ - "'com' | community.dns.remove_registrable_domain(keep_trailing_period=true) == 'com'"
+ - "'www.ansible.com' | community.dns.remove_registrable_domain == 'www'"
+ - "'www.ansible.com' | community.dns.remove_registrable_domain(only_if_registerable=true) == 'www'"
+ - "'www.ansible.com' | community.dns.remove_registrable_domain(keep_trailing_period=true) == 'www.'"
+ - "'www.ansible.com.' | community.dns.remove_registrable_domain == 'www'"
+ - "'ansible.com.' | community.dns.remove_registrable_domain == ''"
+ - "'some.random.prefixes.ansible.co.uk' | community.dns.remove_registrable_domain == 'some.random.prefixes'"
+ - "'some.invalid.example' | community.dns.remove_registrable_domain == 'some'"
+ - "'some.invalid.example' | community.dns.remove_registrable_domain(keep_unknown_suffix=False) == 'some.invalid.example'"
+ - "'www.example.cloudfront.net' | community.dns.remove_registrable_domain(icann_only=false) == 'www'"
+ - "'www.example.cloudfront.net' | community.dns.remove_registrable_domain(icann_only=true) == 'www.example'"
+ - "'prefix.www.ck' | community.dns.remove_registrable_domain == 'prefix'"
+ - "'thisisaninvalidlabelbecauseitiswaytoolongitscharacterlengthislargerthan63' | community.dns.remove_registrable_domain == 'thisisaninvalidlabelbecauseitiswaytoolongitscharacterlengthislargerthan63'"
diff --git a/ansible_collections/community/dns/tests/ee/roles/wait_for_txt/tasks/main.yml b/ansible_collections/community/dns/tests/ee/roles/wait_for_txt/tasks/main.yml
new file mode 100644
index 000000000..43941d042
--- /dev/null
+++ b/ansible_collections/community/dns/tests/ee/roles/wait_for_txt/tasks/main.yml
@@ -0,0 +1,77 @@
+---
+# 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: Get TXT records for github.com
+ shell: |
+ dig -t TXT github.com +short | sed -e 's/" "//g' -e 's/"//g'
+ register: dig
+
+- name: Wait for existing TXT entry
+ community.dns.wait_for_txt:
+ records:
+ - name: github.com
+ values: "{{ dig.stdout_lines }}"
+ - name: github.io
+ values: []
+ query_timeout: 20
+ timeout: 60
+ register: success
+
+- name: Validate results
+ assert:
+ that:
+ - success is not changed
+ - success.msg == 'All checks passed'
+ - success.completed == 2
+ - success.records | length == 2
+ - success.records[0].name == 'github.com'
+ - success.records[0].done == true
+ - "'values' in success.records[0]"
+ - success.records[0].check_count == 1
+ - success.records[1].name == 'github.io'
+ - success.records[1].done == true
+ - "'values' in success.records[1]"
+ - success.records[1].check_count == 1
+
+- name: Wait for non-existing TXT entry
+ community.dns.wait_for_txt:
+ records:
+ - name: does_not_exist.ansible.com
+ values: test
+ timeout: 0
+ register: timeout
+ failed_when: timeout is not failed
+
+- name: Validate results
+ assert:
+ that:
+ - timeout.msg == 'Timeout (0 out of 1 check(s) passed).'
+ - timeout.completed == 0
+ - timeout.records | length == 1
+ - timeout.records[0].name == 'does_not_exist.ansible.com'
+ - timeout.records[0].done == false
+ - "'values' in timeout.records[0]"
+ - timeout.records[0].check_count == 1
+
+- name: Wait for non-existing TXT value
+ community.dns.wait_for_txt:
+ records:
+ - name: github.com
+ # random digits generated by https://www.random.org/
+ values: x9717627475397185312575692320809591701005198751588993668249007340758823426405452359342719842260291210
+ timeout: 0
+ register: timeout
+ failed_when: timeout is not failed
+
+- name: Validate results
+ assert:
+ that:
+ - timeout.msg == 'Timeout (0 out of 1 check(s) passed).'
+ - timeout.completed == 0
+ - timeout.records | length == 1
+ - timeout.records[0].name == 'github.com'
+ - timeout.records[0].done == false
+ - "'values' in timeout.records[0]"
+ - timeout.records[0].check_count == 1