gunk-dev/the-valley

identity-schema.sh

source0a11b2de4864main's published tip history
1.3 KiB
1# shellcheck shell=bash
2# Paths and fixtures come from the derivation environment.
3# shellcheck disable=SC2154
4cue vet -c "$schema" "$registry"/*.cue
5cue export "$schema" "$registry"/*.cue > registry.json
6grep -q '"genesis": "patrick"' registry.json
7# The signing name is per key, not per entry: one entry holds keys signing
8# under two different names, and that is what the compiler renders from.
9grep -q '"signs": "makers-mark/attestations"' registry.json
10grep -q '"signs": "patrick"' registry.json
11
12# The registries the schema must reject, and the words each rejection must
13# name. The floor's properties are here — mandatory expiry where a raw key
14# is held, no external principal governing the registry, a genesis entry
15# that governs it — and a rejection that stopped naming its field would be a
16# floor nobody can act on.
17while IFS=$'\t' read -r name names; do
18 case "$name" in '' | '#'*) continue ;; esac
19 if cue vet -c "$schema" "$rejected/$name.cue" > "$name.err" 2>&1; then
20 echo "identity-schema: expected invalid registry '$name' to be rejected" >&2
21 exit 1
22 fi
23 if [ -n "$names" ] && ! grep -qF -- "$names" "$name.err"; then
24 echo "identity-schema: '$name' was rejected without naming $names" >&2
25 cat "$name.err" >&2
26 exit 1
27 fi
28done < "$rejectedCases"
29touch "$out"