feat(validation): add a strict validate_inputs action for user input
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
---
|
||||
- name: "Validate the fixture ({{ inf.name }})"
|
||||
block:
|
||||
- name: "Run the validator ({{ inf.name }})"
|
||||
validate_inputs:
|
||||
specs:
|
||||
- "{{ playbook_dir }}/fixture_spec.yml"
|
||||
vars:
|
||||
fixture: "{{ inf.value }}"
|
||||
register: inputs_result
|
||||
rescue:
|
||||
- name: "Keep the failed result ({{ inf.name }})"
|
||||
ansible.builtin.set_fact:
|
||||
inputs_result: "{{ ansible_failed_result }}"
|
||||
|
||||
- name: "Assert the reported violations ({{ inf.name }})"
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- (inputs_result.errors | default([])) | sort == inf.expect | sort
|
||||
- "'topsecret-value' not in (inputs_result | to_json)"
|
||||
fail_msg: "[inputs {{ inf.name }}] expected {{ inf.expect }}, got {{ inputs_result.errors | default([]) }}"
|
||||
success_msg: "[inputs {{ inf.name }}] OK"
|
||||
Reference in New Issue
Block a user