test(cloudflared): add the default molecule scenario
Runs without Cloudflare and without a real cloudflared: a stub of the Cloudflare API on the controller's loopback answers the tunnel, zone and DNS record calls through cloudflared_api_base_url, a stub binary stands in for the daemon, and the releases come from file:// URLs. Covers the converge with an update through _binary_update and its idempotence, the rendered files and the running unit, the input asserts, the deleted-tunnel and DNS guards, a stale hash and a failed checksum, the mint entry point (as child processes outside CI) and the remove path. The cloudflare_dns calls cannot reach the stub and are not run. Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
1 parent
e308683431
commit
9a626962a5
8 files changed
+831
No files matched your search
@@ -0,0 +1,48 @@
|
||||
---
|
||||
# Run by verify.yml in a child ansible-playbook process, because the mint guard reads the
|
||||
# controller's environment (lookup env), which a play cannot change; the child gets its
|
||||
# environment from the task that starts it, so the result does not depend on what the runner
|
||||
# exports. The child uses `-i localhost,` and so does not see the molecule group_vars: verify.yml
|
||||
# passes the inputs with -e, and cloudflared_test_expect_minted says what to assert afterwards.
|
||||
- name: Mint with a controlled environment
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Run the mint entry point
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.cloudflared
|
||||
tasks_from: mint
|
||||
vars:
|
||||
cloudflared_mint_confirm: true
|
||||
|
||||
- name: No tunnel fact was registered
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- cloudflared_minted_tunnel_id is not defined
|
||||
- cloudflared_minted_credentials_json is not defined
|
||||
quiet: true
|
||||
when: not (cloudflared_test_expect_minted | default(false) | bool)
|
||||
|
||||
- name: Parse the minted credentials
|
||||
ansible.builtin.set_fact:
|
||||
cloudflared_test_minted: "{{ cloudflared_minted_credentials_json | from_json }}"
|
||||
no_log: true
|
||||
when: cloudflared_test_expect_minted | default(false) | bool
|
||||
|
||||
# The stub accepted the secret only as base64 of at least 32 bytes; 32 bytes are 44
|
||||
# characters. The secret and the API response must not stay in the host's variables.
|
||||
- name: The tunnel facts were registered and the intermediates cleared
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- cloudflared_minted_tunnel_id is match('^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$')
|
||||
- cloudflared_test_minted.TunnelID == cloudflared_minted_tunnel_id
|
||||
- cloudflared_test_minted.AccountTag == cloudflared_account_id
|
||||
- cloudflared_test_minted.TunnelName == cloudflared_tunnel_name
|
||||
- cloudflared_test_minted.TunnelSecret | length == 44
|
||||
- __cloudflared_tunnel_secret == ""
|
||||
- __cloudflared_tunnel_create == ""
|
||||
fail_msg: The minted tunnel facts are missing or wrong, or an intermediate was kept
|
||||
quiet: true
|
||||
no_log: true
|
||||
when: cloudflared_test_expect_minted | default(false) | bool
|
||||
Reference in new issue
Block a user