| 1 | #!/bin/sh |
| 2 | # BusyBox starts this script as the signed network packages' guest smoke test. |
| 3 | set -eu |
| 4 | export PATH=/bin:/usr/bin:/sbin:/usr/sbin HOME=/tmp TERM=dumb LC_ALL=C |
| 5 | phase=identity |
| 6 | server= |
| 7 | finish() { |
| 8 | status=$? |
| 9 | if [ -n "$server" ]; then kill "$server" 2>/dev/null || true; fi |
| 10 | if [ "$status" -ne 0 ]; then echo "VPAC NETWORK FAIL at $phase with status $status"; fi |
| 11 | /sbin/poweroff -f |
| 12 | } |
| 13 | trap finish EXIT |
| 14 | test "$(uname -o)" = Vinix |
| 15 | mkdir -p /tmp/network |
| 16 | cd /tmp/network |
| 17 | |
| 18 | phase=trust |
| 19 | openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -days 1 \ |
| 20 | -subj /CN=vinix.test -addext subjectAltName=DNS:vinix.test -keyout key.pem -out cert.pem |
| 21 | mkdir -p /usr/local/share/ca-certificates |
| 22 | cp cert.pem /usr/local/share/ca-certificates/vinix-fixture.crt |
| 23 | update-ca-certificates |
| 24 | openssl verify -CAfile /etc/ssl/cert.pem cert.pem |
| 25 | openssl verify -no-CAfile -no-CAstore -CApath /etc/ssl/certs cert.pem |
| 26 | |
| 27 | phase=https |
| 28 | openssl s_server -accept 127.0.0.1:2443 -cert cert.pem -key key.pem -www >tls.log 2>&1 & |
| 29 | server=$! |
| 30 | curl --disable --noproxy '*' --retry 5 --retry-connrefused --max-time 8 --silent --show-error \ |
| 31 | --resolve vinix.test:2443:127.0.0.1 https://vinix.test:2443/ -o page |
| 32 | grep -qi '<html>' page |
| 33 | status=0 |
| 34 | curl --disable --noproxy '*' --max-time 5 --silent --show-error --resolve wrong.test:2443:127.0.0.1 \ |
| 35 | https://wrong.test:2443/ -o wrong || status=$? |
| 36 | test "$status" -eq 60 |
| 37 | kill "$server" |
| 38 | wait "$server" || true |
| 39 | server= |
| 40 | |
| 41 | phase=git |
| 42 | git init -q repo |
| 43 | printf '%s\n' 'Vinix source ports' >repo/note |
| 44 | git -C repo add note |
| 45 | git -C repo -c user.name=Vinix -c user.email=ports@example.invalid commit -qm fixture |
| 46 | test "$(git -C repo show HEAD:note)" = 'Vinix source ports' |
| 47 | git -C repo grep -q -P '(?=source)source' |
| 48 | |
| 49 | phase=ssh |
| 50 | ssh-keygen -q -t ed25519 -N '' -f ssh-key |
| 51 | ssh-keygen -Y sign -f ssh-key -n vinix repo/note |
| 52 | printf 'builder %s\n' "$(cat ssh-key.pub)" >signers |
| 53 | ssh-keygen -Y verify -f signers -I builder -n vinix -s repo/note.sig <repo/note |
| 54 | |
| 55 | phase=xbps |
| 56 | arch=$(xbps-uhelper arch) |
| 57 | test "$arch" = "$(uname -m)-musl" |
| 58 | mkdir payload client conf |
| 59 | cp repo/note payload/note |
| 60 | xbps-create -A "$arch" -n vinix-test-1.0_1 -s 'Vinix fixture' payload |
| 61 | xbps-rindex -a "vinix-test-1.0_1.$arch.xbps" |
| 62 | test "$(xbps-query -r "$PWD/client" -C "$PWD/conf" --repository="$PWD" -R -p pkgver vinix-test)" = vinix-test-1.0_1 |
| 63 | xbps-install -y -r "$PWD/client" -C "$PWD/conf" --repository="$PWD" vinix-test |
| 64 | cmp payload/note client/note |
| 65 | test "$(xbps-query -r "$PWD/client" -C "$PWD/conf" -p pkgver vinix-test)" = vinix-test-1.0_1 |
| 66 | echo 'VPAC FIXTURE GUEST PASS' |
| 67 | |