From 7f754e2ab9b172ad84e1f362a2851efdadcc7ce8 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Wed, 15 Nov 2017 11:24:57 +0100 Subject: [PATCH] Add basic integration tests --- Makefile | 8 ++++++++ examples/integration/test.sh | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100755 examples/integration/test.sh diff --git a/Makefile b/Makefile index 2f504c7..8702e4f 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/examples/integration/test.sh b/examples/integration/test.sh new file mode 100755 index 0000000..13aa6c1 --- /dev/null +++ b/examples/integration/test.sh @@ -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