Ingress hostnames must be lowercase, with an optional leading *. and no whitespace: they land unquoted in config.yml. The service account names and directories must hold no newline or %, which the unit would read as directives, and the directories must be absolute. A set tunnel id must be a lowercase UUID, the shape the stale-credentials search relies on. Each refusal has a negative case in the scenario. Assisted-by: Claude Code:claude-opus-5-5
43 lines
2.9 KiB
YAML
43 lines
2.9 KiB
YAML
---
|
|
# One failing run: runs the main entry point with the inputs of the case and asserts that the
|
|
# expected message, not something else, stopped it. Input: cloudflared_test_case (name, vars,
|
|
# expect). Task vars cannot come from a template as a whole, so each input a case may change is
|
|
# passed with its scenario value as the default.
|
|
- name: "Run the role, case {{ cloudflared_test_case.name }}"
|
|
block:
|
|
- name: "Include the role, case {{ cloudflared_test_case.name }}"
|
|
ansible.builtin.include_role:
|
|
name: mortis.kamino.cloudflared
|
|
vars:
|
|
cloudflared_version: "{{ cloudflared_test_case.vars.cloudflared_version | default('2026.2.0') }}"
|
|
cloudflared_sha256_amd64: >-
|
|
{{ cloudflared_test_case.vars.cloudflared_sha256_amd64
|
|
| default(cloudflared_test_stub | replace('@VERSION@', '2026.2.0') | hash('sha256')) }}
|
|
cloudflared_tunnel_id: "{{ cloudflared_test_case.vars.cloudflared_tunnel_id | default(cloudflared_test_tunnel_id) }}"
|
|
cloudflared_credentials_json: "{{ cloudflared_test_case.vars.cloudflared_credentials_json | default(cloudflared_test_credentials_json) }}"
|
|
cloudflared_account_id: "{{ cloudflared_test_case.vars.cloudflared_account_id | default('molecule-account') }}"
|
|
cloudflared_tunnel_api_token: "{{ cloudflared_test_case.vars.cloudflared_tunnel_api_token | default('molecule-not-a-token') }}"
|
|
cloudflared_manage_dns: "{{ cloudflared_test_case.vars.cloudflared_manage_dns | default(false) }}"
|
|
cloudflared_zone_name: "{{ cloudflared_test_case.vars.cloudflared_zone_name | default('') }}"
|
|
cloudflared_ingress: "{{ cloudflared_test_case.vars.cloudflared_ingress | default(cloudflared_test_ingress) }}"
|
|
cloudflared_user: "{{ cloudflared_test_case.vars.cloudflared_user | default('cloudflared') }}"
|
|
cloudflared_install_dir: "{{ cloudflared_test_case.vars.cloudflared_install_dir | default('/usr/local/bin') }}"
|
|
cloudflared_config_dir: "{{ cloudflared_test_case.vars.cloudflared_config_dir | default('/etc/cloudflared') }}"
|
|
|
|
# Only reached when the include returned. The message must not contain the expected
|
|
# text, so the rescue below cannot mistake it for the failure under test.
|
|
- name: "Fail because the include returned, case {{ cloudflared_test_case.name }}"
|
|
ansible.builtin.fail:
|
|
msg: The role accepted the input
|
|
rescue:
|
|
# A failed loop task reports its message per item.
|
|
- name: "The expected failure stopped the run, case {{ cloudflared_test_case.name }}"
|
|
vars:
|
|
cloudflared_test_messages: >-
|
|
{{ (ansible_failed_result.msg | default('')) ~ ' '
|
|
~ (ansible_failed_result.results | default([]) | map(attribute='msg', default='') | join(' ')) }}
|
|
ansible.builtin.assert:
|
|
that: cloudflared_test_case.expect in cloudflared_test_messages
|
|
fail_msg: "Expected '{{ cloudflared_test_case.expect }}', got: {{ cloudflared_test_messages }}"
|
|
quiet: true
|