| 1 | # shellcheck shell=bash |
| 2 | # Paths and fixtures come from the derivation environment. |
| 3 | # shellcheck disable=SC2154 |
| 4 | cue vet -c "$schema" "$statements/pure.json" |
| 5 | cue vet -c "$schema" "$statements/effectful.json" |
| 6 | |
| 7 | # Each rejected statement is the pure or effectful one with a single thing |
| 8 | # wrong; the file name says which. |
| 9 | for bad in "$statements"/rejected/*.json; do |
| 10 | name="$(basename "$bad" .json)" |
| 11 | if cue vet -c "$schema" "$bad" > "$name.err" 2>&1; then |
| 12 | echo "attest-schema: expected invalid statement '$name' to be rejected" >&2 |
| 13 | exit 1 |
| 14 | fi |
| 15 | done |
| 16 | |
| 17 | # A map whose keys come from a caller is written as |
| 18 | # #SegmentKeyed. A field's name is written into the key that |
| 19 | # names its line, so a name holding the dot that separates |
| 20 | # segments, the space that separates key from value, or |
| 21 | # anything a line cannot carry is a statement with no written |
| 22 | # form. It fails vet rather than reaching a signer. |
| 23 | cue vet -d '#SegmentKeyed' "$schema" "$statements/segment-keys.json" |
| 24 | for bad in "$statements"/rejected-keys/*.json; do |
| 25 | name="$(basename "$bad" .json)" |
| 26 | if cue vet -d '#SegmentKeyed' "$schema" "$bad" > "$name.err" 2>&1; then |
| 27 | echo "attest-schema: expected the key in '$name' to be rejected" >&2 |
| 28 | exit 1 |
| 29 | fi |
| 30 | grep -q 'field not allowed' "$name.err" |
| 31 | done |
| 32 | |
| 33 | # A rejection that does not name the field leaves the reader |
| 34 | # to find the breakage themselves. |
| 35 | grep -q 'signature: conflicting values' signature-in-statement.err |
| 36 | grep -q 'subject.digest."valley-tree-v1"' no-content-addressed-subject.err |
| 37 | grep -q 'predicate.environment: field not allowed' effectful-claiming-pure.err |
| 38 | grep -q 'predicate.check.command' command-over-two-lines.err |
| 39 | touch "$out" |