mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
Add test fqdn_valid (#7533)
* Add test fqdn_valid * Add integration test fqdn_valid * Add changelogs 7533-add-test-fqdn_valid * Fix changelogs filename 7533-add-test-fqdn_valid.yml * Add runme.* to install PyPI package fqdn and run the test. * Remove changelog. New tests are documented by their version_added + short_description. * Guarded import fqdn. * Update plugins/test/fqdn_valid.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/test/fqdn_valid.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/test/fqdn_valid.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/test/fqdn_valid.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update tests/integration/targets/test_fqdn_valid/aliases Co-authored-by: Felix Fontein <felix@fontein.de> * Add tests/fqdn_valid.py maintained by vbotka. * Fix integration. Add explicit collections to test_fqdn_valid * Fix integration. Remove unused import ansible.errors * Fix PEP8 E275 * Fix E402 module level import not at top of file. * Fix E275 missing whitespace after keyword * Update plugins/test/fqdn_valid.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/test/fqdn_valid.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/test/fqdn_valid.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/test/fqdn_valid.py Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
5147c49498
commit
2a5e7c33df
8 changed files with 213 additions and 0 deletions
5
tests/integration/targets/test_fqdn_valid/aliases
Normal file
5
tests/integration/targets/test_fqdn_valid/aliases
Normal file
|
@ -0,0 +1,5 @@
|
|||
# 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
|
||||
|
||||
azp/posix/2
|
15
tests/integration/targets/test_fqdn_valid/runme.sh
Executable file
15
tests/integration/targets/test_fqdn_valid/runme.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
# 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
|
||||
|
||||
set -eux
|
||||
|
||||
source virtualenv.sh
|
||||
|
||||
# Requirements have to be installed prior to running ansible-playbook
|
||||
# because plugins and requirements are loaded before the task runs
|
||||
|
||||
pip install fqdn
|
||||
|
||||
ANSIBLE_ROLES_PATH=../ ansible-playbook runme.yml "$@"
|
8
tests/integration/targets/test_fqdn_valid/runme.yml
Normal file
8
tests/integration/targets/test_fqdn_valid/runme.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
# 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
|
||||
roles:
|
||||
- {role: test_fqdn_valid}
|
|
@ -0,0 +1,58 @@
|
|||
---
|
||||
# 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: Debug ansible_version
|
||||
ansible.builtin.debug:
|
||||
var: ansible_version
|
||||
when: debug_test|d(false)|bool
|
||||
tags: t0
|
||||
|
||||
- name: 1. Test valid hostnames. Default options.
|
||||
block:
|
||||
- name: "1. Default min_labels=1, allow_underscores=False"
|
||||
ansible.builtin.debug:
|
||||
msg: "hosts_invalid: {{ hosts_invalid }}"
|
||||
when: debug_test|d(false)|bool
|
||||
- name: Assert
|
||||
ansible.builtin.assert:
|
||||
that: hosts_invalid|difference(result)|length == 0
|
||||
vars:
|
||||
hosts_valid: "{{ names1|select('community.general.fqdn_valid') }}"
|
||||
hosts_invalid: "{{ names1|difference(hosts_valid) }}"
|
||||
result: [-rv.example.com, -rv, s_v]
|
||||
tags: t1
|
||||
|
||||
- name: 2. Test valid hostnames. allow_underscores=True
|
||||
block:
|
||||
- name: "2. allow_underscores=True, default min_labels=1"
|
||||
ansible.builtin.debug:
|
||||
msg: "hosts_invalid: {{ hosts_invalid }}"
|
||||
when: debug_test|d(false)|bool
|
||||
- name: Assert
|
||||
ansible.builtin.assert:
|
||||
that: hosts_invalid|difference(result)|length == 0
|
||||
vars:
|
||||
hosts_valid: "{{ names2|select('community.general.fqdn_valid',
|
||||
allow_underscores=True) }}"
|
||||
hosts_invalid: "{{ names2|difference(hosts_valid) }}"
|
||||
result: [-rv]
|
||||
tags: t2
|
||||
|
||||
- name: 3. Test valid hostnames. min_labels=2, allow_underscores=True
|
||||
block:
|
||||
- name: "3. allow_underscores=True, min_labels=2"
|
||||
ansible.builtin.debug:
|
||||
msg: "hosts_invalid: {{ hosts_invalid }}"
|
||||
when: debug_test|d(false)|bool
|
||||
- name: Assert
|
||||
ansible.builtin.assert:
|
||||
that: hosts_invalid|difference(result)|length == 0
|
||||
vars:
|
||||
hosts_valid: "{{ names3|select('community.general.fqdn_valid',
|
||||
min_labels=2,
|
||||
allow_underscores=True) }}"
|
||||
hosts_invalid: "{{ names3|difference(hosts_valid) }}"
|
||||
result: [9rv, s_v-.x.y]
|
||||
tags: t3
|
7
tests/integration/targets/test_fqdn_valid/tasks/main.yml
Normal file
7
tests/integration/targets/test_fqdn_valid/tasks/main.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
# 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 fqdn_valid
|
||||
ansible.builtin.import_tasks: fqdn_valid_1.yml
|
15
tests/integration/targets/test_fqdn_valid/vars/main.yml
Normal file
15
tests/integration/targets/test_fqdn_valid/vars/main.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
# 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
|
||||
|
||||
names1:
|
||||
- srv.example.com
|
||||
- 9rv.example.com
|
||||
- -rv.example.com
|
||||
- srv
|
||||
- 9rv
|
||||
- -rv
|
||||
- s_v
|
||||
names2: [9rv, -rv, s_v]
|
||||
names3: [9rv, srv.x, s_v.x.y, s_v-.x.y]
|
Loading…
Add table
Add a link
Reference in a new issue