You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

59 lines
2.2 KiB

#!/usr/bin/env bash
set -eE
shellcheck "$0"
# Before we build...
go fmt
go doc
go test
go build
strip -s ipxeplease
./ipxeplease web :5555 http://localhost:2323/ &
PID=$!
cleanup() {
echo "Cleaning up."
kill "$PID"
}
trap fail $(seq 1 15)
fail() {
echo "FAIL: $1"
cleanup
exit 1
}
# Very unfinished
curl -s --show-error --fail "http://localhost:5555"/list || fail "Should be able to list.."
curl -s --show-error --fail "http://localhost:5555"/list | grep 'debian-9' || fail "debian-9 should be in list"
curl -s --show-error --fail "http://localhost:5555"/list | grep 'debian-10' || fail "debian-10 should be in list"
curl -s --show-error --fail "http://localhost:5555"/list | grep 'ubuntu-16-04' || fail "ubuntu-16-04 should be in list"
curl -s --show-error --fail "http://localhost:5555"/list | grep 'ubuntu-18-04' || fail "ubuntu-18-04 should be in list"
echo '{"operating_system": "coreos-stable", "ssh_key": "ssh-rsa AAAA"}' | curl -d@- -s --show-error --fail "http://localhost:5555"/ipxe | grep -100 'http' || fail "coreos-stable ipxe failed."
# shellcheck disable=SC2028
echo '{"operating_system": "coreos-stable", "ssh_key": "ssh-rsa AAAA\n"}' | curl -d@- -s --show-error --fail "http://localhost:5555"/ipxe | grep -100 'AAAA\n' && fail "SSH key newline stripping failed."
# These require burnpaste to be running.
# burnpaste :2323
# shellcheck disable=SC2028
echo '{"operating_system": "debian-9", "ssh_key": "ssh-rsa AAAA\n"}' | curl -d@- -s --show-error --fail "http://localhost:5555"/ipxe | grep -q 'stretch' || fail "No stretch in debian-9"
# shellcheck disable=SC2028
echo '{"operating_system": "debian-10", "ssh_key": "ssh-rsa AAAA\n"}' | curl -d@- -s --show-error --fail "http://localhost:5555"/ipxe | grep -q 'buster' || fail "No buster in debian-9"
# shellcheck disable=SC2028
echo '{"operating_system": "ubuntu-18-04", "ssh_key": "ssh-rsa AAAA\n"}' | curl -d@- -s --show-error --fail "http://localhost:5555"/ipxe | grep -q 'bionic' || fail "No bionic in ubuntu-18-04"
# shellcheck disable=SC2028
echo '{"operating_system": "ubuntu-16-04", "ssh_key": "ssh-rsa AAAA\n"}' | curl -d@- -s --show-error --fail "http://localhost:5555"/ipxe | grep -q 'xenial' || fail "No xenial in ubuntu-16-04"
cleanup
./ipxeplease list
echo Success