Add basic integration tests

This commit is contained in:
Manfred Touron 2017-11-15 11:24:57 +01:00
parent 2261d27c94
commit 7f754e2ab9
2 changed files with 48 additions and 0 deletions

View file

@ -8,6 +8,14 @@ VERSION ?= $(shell grep 'VERSION =' main.go | cut -d'"' -f2)
install:
go install -ldflags '$(LDFLAGS)' .
.PHONY: docker.build
docker.build:
docker build -t moul/sshportal .
.PHONY: integration
integration:
bash ./examples/integration/test.sh
.PHONY: _docker_install
_docker_install:
CGO_ENABLED=1 go build -ldflags '-extldflags "-static" $(LDFLAGS)' -tags netgo -v -o /go/bin/sshportal

40
examples/integration/test.sh Executable file
View file

@ -0,0 +1,40 @@
#!/bin/sh -e
# Setup a new sshportal and performs some checks
PORT=${PORT:-2222}
SSHPORTAL_DEFAULT_ADMIN_INVITE_TOKEN=integration
# pre cleanup
cleanup() {
docker rm -f -v sshportal-integration 2>/dev/null >/dev/null || true
}
cleanup
# start server
( set -xe;
docker run \
-d \
-e SSHPORTAL_DEFAULT_ADMIN_INVITE_TOKEN=${SSHPORTAL_DEFAULT_ADMIN_INVITE_TOKEN} \
--name=sshportal-integration \
-p${PORT}:2222 \
moul/sshportal
)
sleep 3 # FIXME: replace with port checker
# integration suite
xssh() {
set -e
echo "+ ssh {sshportal} $@"
ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no localhost -p ${PORT} $@
}
xssh -l invite:integration
xssh -l admin host create bob@example.org:1234
xssh -l admin host inspect example
xssh -l admin host create test42
xssh -l admin host inspect test42
xssh -l admin host create --name=testtest --comment=test --password=test test@test.test
xssh -l admin host inspect testtest
xssh -l admin host ls
# post cleanup
#cleanup