mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
Fixes #203 The namespace used to differentiate the resources between CI pipelines, CI stages or even between test targets was broken and resulted in conflicting resource names. This PR ensure the resources names don't collide with each other by making sure we use the entire hcloud_prefix value as md5sum, and by including the target role names inside the resource names. Create a setup/teardown framework to handle testing resources used by the tests. To simplify the review process, additional changes such as splitting the setup/teardown task in the prepare.yml and cleanup.yml files will be done in future PRs (many files were renamed, and git will not preserve the file history after the PR squash). * chore: move integrations targets files * test: create integration common files * test: fix resources name namespace using the magic hcloud_ns * test: simplify requirements install * test: rename hcloud_server test taskfiles
155 lines
4.7 KiB
YAML
155 lines
4.7 KiB
YAML
# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
---
|
|
- name: test missing required parameters on create certificate
|
|
hetzner.hcloud.hcloud_certificate:
|
|
name: "{{ hcloud_certificate_name }}"
|
|
register: result
|
|
ignore_errors: true
|
|
- name: verify fail test missing required parameters on create certificate
|
|
assert:
|
|
that:
|
|
- result is failed
|
|
- 'result.msg == "missing required arguments: certificate, private_key"'
|
|
|
|
- name: test create certificate with check mode
|
|
hetzner.hcloud.hcloud_certificate:
|
|
name: "{{ hcloud_certificate_name }}"
|
|
certificate: "{{ certificate_example_com }}"
|
|
private_key: "{{ certificate_example_com_key }}"
|
|
register: result
|
|
check_mode: true
|
|
- name: test create certificate with check mode
|
|
assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: test create certificate
|
|
hetzner.hcloud.hcloud_certificate:
|
|
name: "{{ hcloud_certificate_name }}"
|
|
certificate: "{{ certificate_example_com }}"
|
|
private_key: "{{ certificate_example_com_key }}"
|
|
labels:
|
|
key: value
|
|
my-label: label
|
|
register: certificate
|
|
- name: verify create certificate
|
|
assert:
|
|
that:
|
|
- certificate is changed
|
|
- certificate.hcloud_certificate.name == "{{ hcloud_certificate_name }}"
|
|
- certificate.hcloud_certificate.domain_names[0] == "www.example.com"
|
|
- certificate.hcloud_certificate.labels.key == "value"
|
|
|
|
- name: test create certificate idempotence
|
|
hetzner.hcloud.hcloud_certificate:
|
|
name: "{{ hcloud_certificate_name }}"
|
|
certificate: "{{ certificate_example_com }}"
|
|
private_key: "{{ certificate_example_com_key }}"
|
|
register: result
|
|
- name: verify create certificate idempotence
|
|
assert:
|
|
that:
|
|
- result is not changed
|
|
|
|
- name: test update certificate with check mode
|
|
hetzner.hcloud.hcloud_certificate:
|
|
id: "{{ certificate.hcloud_certificate.id }}"
|
|
name: "changed-{{ hcloud_certificate_name }}"
|
|
register: result
|
|
check_mode: true
|
|
- name: test create certificate with check mode
|
|
assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: test update certificate
|
|
hetzner.hcloud.hcloud_certificate:
|
|
id: "{{ certificate.hcloud_certificate.id }}"
|
|
name: "changed-{{ hcloud_certificate_name }}"
|
|
labels:
|
|
key: value
|
|
register: result
|
|
- name: test update certificate
|
|
assert:
|
|
that:
|
|
- result is changed
|
|
- result.hcloud_certificate.name == "changed-{{ hcloud_certificate_name }}"
|
|
|
|
- name: test update certificate with same labels
|
|
hetzner.hcloud.hcloud_certificate:
|
|
id: "{{ certificate.hcloud_certificate.id }}"
|
|
name: "changed-{{ hcloud_certificate_name }}"
|
|
labels:
|
|
key: value
|
|
register: result
|
|
- name: test update certificate with same labels
|
|
assert:
|
|
that:
|
|
- result is not changed
|
|
|
|
- name: test update certificate with other labels
|
|
hetzner.hcloud.hcloud_certificate:
|
|
id: "{{ certificate.hcloud_certificate.id }}"
|
|
name: "changed-{{ hcloud_certificate_name }}"
|
|
labels:
|
|
key: value
|
|
test: "val123"
|
|
register: result
|
|
- name: test update certificate with other labels
|
|
assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: test rename certificate
|
|
hetzner.hcloud.hcloud_certificate:
|
|
id: "{{ certificate.hcloud_certificate.id }}"
|
|
name: "{{ hcloud_certificate_name }}"
|
|
register: result
|
|
- name: test rename certificate
|
|
assert:
|
|
that:
|
|
- result is changed
|
|
- result.hcloud_certificate.name == "{{ hcloud_certificate_name }}"
|
|
|
|
- name: absent certificate
|
|
hetzner.hcloud.hcloud_certificate:
|
|
id: "{{ certificate.hcloud_certificate.id }}"
|
|
state: absent
|
|
register: result
|
|
- name: verify absent server
|
|
assert:
|
|
that:
|
|
- result is success
|
|
|
|
- name: generate dns domain name
|
|
set_fact:
|
|
# hcloud_dns_test_domain uses random, which generates a new random number
|
|
# on every invocation, by saving it into a fact we generate the number once
|
|
hcloud_dns_test_domain: "{{ hcloud_dns_test_domain }}"
|
|
|
|
- name: test create managed certificate
|
|
hetzner.hcloud.hcloud_certificate:
|
|
name: "{{ hcloud_certificate_name }}"
|
|
domain_names:
|
|
- "{{ hcloud_dns_test_domain }}"
|
|
type: managed
|
|
labels:
|
|
HC-Use-Staging-CA: "true"
|
|
register: result
|
|
- name: verify create managed certificate
|
|
assert:
|
|
that:
|
|
- result is changed
|
|
- result.hcloud_certificate.name == "{{ hcloud_certificate_name }}"
|
|
- result.hcloud_certificate.domain_names[0] == "{{ hcloud_dns_test_domain }}"
|
|
|
|
- name: absent certificate
|
|
hetzner.hcloud.hcloud_certificate:
|
|
id: "{{ result.hcloud_certificate.id }}"
|
|
state: absent
|
|
register: result
|
|
- name: verify absent certificate
|
|
assert:
|
|
that:
|
|
- result is success
|