diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 16:18:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 16:18:41 +0000 |
commit | b643c52cf29ce5bbab738b43290af3556efa1ca9 (patch) | |
tree | 21d5c53d7a9b696627a255777cefdf6f78968824 /ansible_collections/theforeman/foreman/tests | |
parent | Releasing progress-linux version 9.5.1+dfsg-1~progress7.99u1. (diff) | |
download | ansible-b643c52cf29ce5bbab738b43290af3556efa1ca9.tar.xz ansible-b643c52cf29ce5bbab738b43290af3556efa1ca9.zip |
Merging upstream version 10.0.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/theforeman/foreman/tests')
17 files changed, 202 insertions, 80 deletions
diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/content_view_filter.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/content_view_filter.yml index edfff36d8..5a5578b9e 100644 --- a/ansible_collections/theforeman/foreman/tests/test_playbooks/content_view_filter.yml +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/content_view_filter.yml @@ -108,33 +108,6 @@ - include_tasks: tasks/content_view_filter_package.yml vars: - version: 1 - expected_change: true - - include_tasks: tasks/content_view_filter_package.yml - vars: - version: 1 - expected_change: false - - - include_tasks: tasks/content_view_filter_package.yml - vars: - max_version: 1 - expected_change: true - - include_tasks: tasks/content_view_filter_package.yml - vars: - max_version: 1 - expected_change: false - - - include_tasks: tasks/content_view_filter_package.yml - vars: - min_version: 1 - expected_change: true - - include_tasks: tasks/content_view_filter_package.yml - vars: - min_version: 1 - expected_change: false - - - include_tasks: tasks/content_view_filter_package.yml - vars: inclusion: true expected_change: true - include_tasks: tasks/content_view_filter_package.yml @@ -167,14 +140,6 @@ expected_change: false - include_tasks: tasks/content_view_filter_errata_date.yml vars: - date_type: issued - expected_change: true - - include_tasks: tasks/content_view_filter_errata_date.yml - vars: - types: security - expected_change: true - - include_tasks: tasks/content_view_filter_errata_date.yml - vars: filter_state: absent rule_state: absent expected_change: true diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/content_view_filter_rule_info.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/content_view_filter_rule_info.yml index b956a43c8..00e91bd0e 100644 --- a/ansible_collections/theforeman/foreman/tests/test_playbooks/content_view_filter_rule_info.yml +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/content_view_filter_rule_info.yml @@ -267,7 +267,7 @@ ansible.builtin.assert: fail_msg: "Ensuring content view filter info is valid failed!" that: - - "{{ result['content_view_filter_rules']|length }} != 0" + - result['content_view_filter_rules']|length != 0 - name: "Fetch content_view_filter_info - deb exlude" diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/filters.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/filters.yml index 70c67f21e..614f9fa7e 100644 --- a/ansible_collections/theforeman/foreman/tests/test_playbooks/filters.yml +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/filters.yml @@ -10,8 +10,8 @@ msg: "{{ 'Test__String)' | theforeman.foreman.cp_label }}" - assert: that: - - "{{ 'Test String' | theforeman.foreman.cp_label == 'Test_String' }}" - - "{{ 'Test__String' | theforeman.foreman.cp_label == 'Test__String' }}" - - "{{ 'Test--String' | theforeman.foreman.cp_label == 'Test--String' }}" - - "{{ 'Test (String) 1234' | theforeman.foreman.cp_label == 'Test_String_1234' }}" + - "'Test String' | theforeman.foreman.cp_label == 'Test_String'" + - "'Test__String' | theforeman.foreman.cp_label == 'Test__String'" + - "'Test--String' | theforeman.foreman.cp_label == 'Test--String'" + - "'Test (String) 1234' | theforeman.foreman.cp_label == 'Test_String_1234'" ... diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/host_info.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/host_info.yml index 78b0eb4ab..5dc3b83d2 100644 --- a/ansible_collections/theforeman/foreman/tests/test_playbooks/host_info.yml +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/host_info.yml @@ -54,7 +54,7 @@ - name: check host details assert: that: - - host_info['host']['name'] == "test-host.{{ host.domain }}" + - host_info['host']['name'] == "test-host.{}".format(host.domain) - host_info['host']['domain_name'] == host.domain - name: search host info @@ -70,7 +70,7 @@ - name: check host details assert: that: - - host_info['hosts'][0]['name'] == "test-host.{{ host.domain }}" + - host_info['hosts'][0]['name'] == "test-host.{}".format(host.domain) - host_info['hosts'][0]['domain_name'] == host.domain - hosts: localhost diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/inventory_plugin.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/inventory_plugin.yml index 9305b22ec..f1dd29296 100644 --- a/ansible_collections/theforeman/foreman/tests/test_playbooks/inventory_plugin.yml +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/inventory_plugin.yml @@ -3,7 +3,9 @@ vars: foreman_groups: - name: group_a + label: group_a - name: group_b + label: group_b - name: group_c label: group_b/group_c parent: group_b diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/inventory_plugin_ansible.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/inventory_plugin_ansible.yml index 5e5e7c4bd..ae6c31dd9 100644 --- a/ansible_collections/theforeman/foreman/tests/test_playbooks/inventory_plugin_ansible.yml +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/inventory_plugin_ansible.yml @@ -3,7 +3,9 @@ vars: foreman_groups: - name: group_a + label: group_a - name: group_b + label: group_b - name: group_c label: group_b/group_c parent: group_b diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/registration_command.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/registration_command.yml new file mode 100644 index 000000000..f16298881 --- /dev/null +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/registration_command.yml @@ -0,0 +1,39 @@ +--- +- hosts: localhost + collections: + - theforeman.foreman + gather_facts: false + vars_files: + - vars/server.yml + tasks: + - include_tasks: tasks/location.yml + vars: + location_state: "present" + - include_tasks: tasks/organization.yml + vars: + organization_state: "present" + +- hosts: tests + collections: + - theforeman.foreman + tags: + - test + gather_facts: false + vars_files: + - vars/server.yml + tasks: + - include_tasks: tasks/registration_command.yml + +- hosts: localhost + collections: + - theforeman.foreman + gather_facts: false + vars_files: + - vars/server.yml + tasks: + - include_tasks: tasks/location.yml + vars: + location_state: "absent" + - include_tasks: tasks/organization.yml + vars: + organization_state: "absent" diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_deb.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_deb.yml index 66da53131..07098ab87 100644 --- a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_deb.yml +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_deb.yml @@ -7,7 +7,6 @@ repositories: - name: "Test Repository" product: "Test Product" - package_name: "bear" filter_state: present content_view_filter: username: "{{ foreman_username }}" @@ -19,11 +18,8 @@ content_view: "{{ content_view_name }}" filter_type: "deb" repositories: "{{ repositories }}" - package_name: "{{ package_name }}" - architecture: "{{ architecture | default(omit) }}" inclusion: "{{ inclusion | default(omit) }}" filter_state: "{{ filter_state }}" - rule_state: "{{ rule_state | default(omit) }}" register: result - assert: fail_msg: "Ensuring content view filter is {{ filter_state }} failed! (expected_change: {{ expected_change | default('unknown') }})" diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_docker.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_docker.yml index 97201f0b6..e670c8b39 100644 --- a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_docker.yml +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_docker.yml @@ -4,7 +4,6 @@ content_view_filter_name: "Test Docker Content View Filter" content_view_name: "Test Content View" organization_name: "Test Organization" - tag: "birds" filter_state: present content_view_filter: username: "{{ foreman_username }}" @@ -16,10 +15,8 @@ content_view: "{{ content_view_name }}" filter_type: "docker" repositories: "{{ repositories | default(omit) }}" - tag: "{{ tag }}" inclusion: "{{ inclusion | default(omit) }}" filter_state: "{{ filter_state }}" - rule_state: "{{ rule_state | default(omit) }}" register: result - assert: fail_msg: "Ensuring content view filter is {{ filter_state }} failed! (expected_change: {{ expected_change | default('unknown') }})" diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_errata_date.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_errata_date.yml index 524b283ad..335bc82f3 100644 --- a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_errata_date.yml +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_errata_date.yml @@ -7,8 +7,6 @@ repositories: - name: "Test Repository" product: "Test Product" - end_date: "2018-01-03" - start_date: "2017-01-03" filter_state: present content_view_filter: username: "{{ foreman_username }}" @@ -20,13 +18,8 @@ content_view: "{{ content_view_name }}" filter_type: "erratum" repositories: "{{ repositories }}" - end_date: "{{ end_date }}" - start_date: "{{ start_date }}" - types: "{{ types | default(omit) }}" - date_type: "{{ date_type | default(omit) }}" inclusion: "{{ inclusion | default(omit) }}" filter_state: "{{ filter_state }}" - rule_state: "{{ rule_state | default(omit) }}" register: result - assert: fail_msg: "Ensuring content view filter is {{ filter_state }} failed! (expected_change: {{ expected_change | default('unknown') }})" diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_errata_id.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_errata_id.yml index c4631f4ff..3c6f13996 100644 --- a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_errata_id.yml +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_errata_id.yml @@ -4,7 +4,6 @@ content_view_filter_name: "Test Errata id Content View Filter" content_view_name: "Test Content View" organization_name: "Test Organization" - errata_id: RHEA-2012:0003 filter_state: present content_view_filter: username: "{{ foreman_username }}" @@ -16,10 +15,8 @@ content_view: "{{ content_view_name }}" filter_type: "erratum" repositories: "{{ repositories | default(omit) }}" - errata_id: "{{ errata_id }}" inclusion: "{{ inclusion | default(omit) }}" filter_state: "{{ filter_state }}" - rule_state: "{{ rule_state | default(omit) }}" register: result - assert: fail_msg: "Ensuring content view filter is {{ filter_state }} failed! (expected_change: {{ expected_change | default('unknown') }})" diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_package.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_package.yml index 4fda2972d..119d16a27 100644 --- a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_package.yml +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_package.yml @@ -7,7 +7,6 @@ repositories: - name: "Test Repository" product: "Test Product" - package_name: "bear" filter_state: present content_view_filter: username: "{{ foreman_username }}" @@ -19,15 +18,9 @@ content_view: "{{ content_view_name }}" filter_type: "rpm" repositories: "{{ repositories }}" - package_name: "{{ package_name }}" - version: "{{ version | default(omit) }}" - architecture: "{{ architecture | default(omit) }}" - min_version: "{{ min_version | default(omit) }}" - max_version: "{{ max_version | default(omit) }}" inclusion: "{{ inclusion | default(omit) }}" original_packages: "{{ original_packages | default(omit) }}" filter_state: "{{ filter_state }}" - rule_state: "{{ rule_state | default(omit) }}" register: result - assert: fail_msg: "Ensuring content view filter is {{ filter_state }} failed! (expected_change: {{ expected_change | default('unknown') }})" diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_package_group.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_package_group.yml index 430ea618b..7e74baaf6 100644 --- a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_package_group.yml +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/content_view_filter_package_group.yml @@ -4,7 +4,6 @@ content_view_filter_name: "Test Package Group Content View Filter" content_view_name: "Test Content View" organization_name: "Test Organization" - package_group: "birds" filter_state: present content_view_filter: username: "{{ foreman_username }}" @@ -16,10 +15,8 @@ content_view: "{{ content_view_name }}" filter_type: "package_group" repositories: "{{ repositories | default(omit) }}" - package_group: "{{ package_group }}" inclusion: "{{ inclusion | default(omit) }}" filter_state: "{{ filter_state }}" - rule_state: "{{ rule_state | default(omit) }}" register: result - assert: fail_msg: "Ensuring content view filter is {{ filter_state }} failed! (expected_change: {{ expected_change | default('unknown') }})" diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/inventory_plugin_tests.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/inventory_plugin_tests.yml index ad2e522c9..383893575 100644 --- a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/inventory_plugin_tests.yml +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/inventory_plugin_tests.yml @@ -1,47 +1,47 @@ --- - name: test that all groups are present assert: - that: > - 'foreman_{{ item.label | default(item.name) | regex_replace('/', '_') }}' in groups + that: + - "'foreman_{}'.format(item.label.replace('/', '_')) in groups" with_items: "{{ foreman_groups }}" - name: test that all hosts are in the "all" group assert: - that: > - '{{ item.key }}' in groups['all'] + that: + - "item.key in groups['all']" with_dict: "{{ foreman_hosts }}" - name: test that all hosts are in the correct hostgroup assert: - that: > - '{{ item.key }}' in groups['foreman_{{ item.value | regex_replace('/', '_') }}'] + that: + - "item.key in groups['foreman_{}'.format(item.value.replace('/', '_'))]" with_dict: "{{ foreman_hosts }}" - name: dump all host details debug: - var: "hostvars['{{ item.key }}']" + var: "hostvars[item.key]" with_dict: "{{ foreman_hosts }}" - name: test that all hosts have the domain fact set assert: that: > - hostvars['{{ item.key }}']['foreman_facts']['domain'] == 'example.com' + hostvars[item.key]['foreman_facts']['domain'] == 'example.com' with_dict: "{{ foreman_hosts }}" - name: test that all hosts have the OS fact set assert: that: > - hostvars['{{ item.key }}']['foreman_facts']['operatingsystem'] == 'CentOS' + hostvars[item.key]['foreman_facts']['operatingsystem'] == 'CentOS' with_dict: "{{ foreman_hosts }}" - name: test that all hosts have the testparam1 assert: that: > - hostvars['{{ item.key }}']['testparam1'] == 'testvalue1' + hostvars[item.key]['testparam1'] == 'testvalue1' with_dict: "{{ foreman_hosts }}" - name: test that all hosts have the testparam2 assert: that: > - hostvars['{{ item.key }}']['testparam2'] == 'testvalue2' + hostvars[item.key]['testparam2'] == 'testvalue2' with_dict: "{{ foreman_hosts }}" diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/registration_command.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/registration_command.yml new file mode 100644 index 000000000..e8bb2a618 --- /dev/null +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/registration_command.yml @@ -0,0 +1,18 @@ +--- +- name: "Generate Registration Command" + vars: + rc_organization: Test Organization + rc_location: Test Location + registration_command: + username: "{{ foreman_username }}" + password: "{{ foreman_password }}" + server_url: "{{ foreman_server_url }}" + validate_certs: "{{ foreman_validate_certs }}" + organization: "{{ rc_organization }}" + location: "{{ rc_location }}" + register: result +- assert: + fail_msg: "Ensuring registering command is generated failed!" + that: + - "'curl' in result.registration_command" +... diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/webhook.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/webhook.yml new file mode 100644 index 000000000..70dc08ed5 --- /dev/null +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/tasks/webhook.yml @@ -0,0 +1,32 @@ +--- +- name: "Create/Update/Delete Webhook" + vars: + webhook_state: "present" + webhook: + username: "{{ foreman_username }}" + password: "{{ foreman_password }}" + server_url: "{{ foreman_server_url }}" + validate_certs: "{{ foreman_validate_certs }}" + name: "{{ webhook_name }}" + target_url: "{{ webhook_target_url | default(omit)}}" + http_method: "{{ webhook_http_method | default(omit) }}" + http_content_type: "{{ webhook_http_content_type | default(omit) }}" + event: "{{ webhook_event | default(omit) }}" + webhook_template: "{{ webhook_template | default(omit) }}" + enabled: "{{ webhook_enabled | default(true) }}" + verify_ssl: "{{ webhook_verify_ssl | default(omit) }}" + ssl_ca_certs: "{{ webhook_ssl_ca_certs | default(omit) }}" + webhook_username: "{{ webhook_username | default(omit) }}" + webhook_password: "{{ webhook_password | default(omit) }}" + http_headers: "{{ webhook_http_headers | default(omit) }}" + proxy_authorization: "{{ webhook_proxy_authorization | default(omit) }}" + locations: "{{ webhook_locations | default(omit) }}" + organizations: "{{ webhook_organizations | default(omit) }}" + state: "{{ webhook_state }}" + register: result +- assert: + fail_msg: "Ensuring webhook is {{ webhook_state }} failed! (expected_change: {{ expected_change | default('unknown') }})" + that: + - result.changed == expected_change + when: expected_change is defined +... diff --git a/ansible_collections/theforeman/foreman/tests/test_playbooks/webhook.yml b/ansible_collections/theforeman/foreman/tests/test_playbooks/webhook.yml new file mode 100644 index 000000000..2552b97ed --- /dev/null +++ b/ansible_collections/theforeman/foreman/tests/test_playbooks/webhook.yml @@ -0,0 +1,91 @@ +- hosts: tests + collections: + - theforeman.foreman + gather_facts: false + vars_files: + - vars/server.yml + tasks: + - name: create webhook + include_tasks: tasks/webhook.yml + vars: + webhook_state: "present" + webhook_name: "Test webhook" + webhook_target_url: "http://example.org:3128" + webhook_event: "actions.katello.content_view.promote_succeeded.event.foreman" + webhook_template: "Katello Publish" + expected_change: true + - name: create webhook again, no change + include_tasks: tasks/webhook.yml + vars: + webhook_state: "present" + webhook_name: "Test webhook" + webhook_target_url: "http://example.org:3128" + webhook_event: "actions.katello.content_view.promote_succeeded.event.foreman" + webhook_template: "Katello Publish" + expected_change: false + - name: delete webhook + include_tasks: tasks/webhook.yml + vars: + webhook_state: "absent" + webhook_name: "Test webhook" + expected_change: true + - name: delete webhook again, no change + include_tasks: tasks/webhook.yml + vars: + webhook_state: "absent" + webhook_name: "Test webhook" + expected_change: false + + - name: create webhook with user/pass + include_tasks: tasks/webhook.yml + vars: + webhook_state: "present" + webhook_name: "Test webhook" + webhook_target_url: "http://example.org:3128" + webhook_event: "actions.katello.content_view.promote_succeeded.event.foreman" + webhook_http_method: "POST" + webhook_username: "admin" + webhook_enabled: false + webhook_password: "secret_password" + webhook_template: "Katello Publish" + expected_change: true + - name: create webhook with user again, no change + include_tasks: tasks/webhook.yml + vars: + webhook_state: "present" + webhook_name: "Test webhook" + webhook_target_url: "http://example.org:3128" + webhook_event: "actions.katello.content_view.promote_succeeded.event.foreman" + webhook_http_method: "POST" + webhook_username: "admin" + webhook_template: "Katello Publish" + webhook_enabled: false + # don't set webhook_password here + expected_change: false + - name: update webhook with http_method + include_tasks: tasks/webhook.yml + vars: + webhook_state: "present" + webhook_name: "Test webhook" + webhook_http_method: "PUT" + expected_change: true + - name: update webhook with org/loc, no change + include_tasks: tasks/webhook.yml + vars: + webhook_state: "present" + webhook_name: "Test webhook" + webhook_http_method: "PUT" + expected_change: false + - name: delete webhook + include_tasks: tasks/webhook.yml + vars: + webhook_state: "absent" + webhook_name: "Test webhook" + expected_change: true + - name: delete webhook again, no change + include_tasks: tasks/webhook.yml + vars: + webhook_state: "absent" + webhook_name: "Test webhook" + expected_change: false +... |