feat(validation): add a strict validate_inputs action for user input
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
---
|
||||
inputs_fixtures:
|
||||
- name: valid
|
||||
value:
|
||||
name: web01
|
||||
enabled: true
|
||||
count: "3"
|
||||
servers: [10.0.0.1, 10.0.0.2]
|
||||
kind: a
|
||||
disks:
|
||||
- size: 30
|
||||
users:
|
||||
alice:
|
||||
password: pw
|
||||
keys: [ssh-ed25519 AAAA alice]
|
||||
retired: ~
|
||||
expect: []
|
||||
|
||||
- name: list-for-dict
|
||||
value:
|
||||
name: web01
|
||||
users:
|
||||
- name: alice
|
||||
expect: ["fixture.users: expected dict, got list"]
|
||||
|
||||
- name: comma-string-for-list
|
||||
value:
|
||||
name: web01
|
||||
servers: 10.0.0.1,10.0.0.2
|
||||
expect: ["fixture.servers: expected list, got str"]
|
||||
|
||||
- name: yes-string-for-bool
|
||||
value:
|
||||
name: web01
|
||||
enabled: "yes"
|
||||
expect: ["fixture.enabled: expected bool, got str"]
|
||||
|
||||
- name: typo-key
|
||||
value:
|
||||
name: web01
|
||||
userz: {}
|
||||
expect: ["fixture.userz: unsupported key, fixture accepts count, disks, enabled, kind, name, secret, servers, users"]
|
||||
|
||||
- name: wrong-element-type
|
||||
value:
|
||||
name: web01
|
||||
disks:
|
||||
- size: 30
|
||||
- size: big
|
||||
expect: ["fixture.disks[1].size: expected int, got str"]
|
||||
|
||||
- name: missing-required
|
||||
value:
|
||||
enabled: false
|
||||
expect: ["fixture.name: required key is missing"]
|
||||
|
||||
- name: choice-mismatch
|
||||
value:
|
||||
name: web01
|
||||
kind: c
|
||||
expect: ["fixture.kind: must be one of a, b, got 'c'"]
|
||||
|
||||
- name: secrets-never-echoed
|
||||
value:
|
||||
name: web01
|
||||
secret: [topsecret-value]
|
||||
users:
|
||||
alice:
|
||||
password: [topsecret-value]
|
||||
expect:
|
||||
- "fixture.secret: expected str, got list"
|
||||
- "fixture.users.alice.password: expected str, got list"
|
||||
|
||||
- name: keyed-entry-not-a-dict
|
||||
value:
|
||||
name: web01
|
||||
users:
|
||||
alice: pw
|
||||
expect: ["fixture.users.alice: expected dict, got str"]
|
||||
|
||||
- name: two-violations-at-once
|
||||
value:
|
||||
name: web01
|
||||
enabled: "true"
|
||||
userz: {}
|
||||
expect:
|
||||
- "fixture.userz: unsupported key, fixture accepts count, disks, enabled, kind, name, secret, servers, users"
|
||||
- "fixture.enabled: expected bool, got str"
|
||||
Reference in New Issue
Block a user