From 2063866c084bab5d735b6eb0be58d7c8fc746c4d Mon Sep 17 00:00:00 2001
From: Lukas Braun <no25qusu@cip.cs.fau.de>
Date: Tue, 29 Aug 2017 14:54:20 +0200
Subject: [PATCH] Fixes for building with pbuilder

Also make sure tests don't fail if a goatherd instance is running on the
build host.
---
 test_pam_goatherd.sh | 13 ++++++++-----
 test_pg.sh           |  2 +-
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/test_pam_goatherd.sh b/test_pam_goatherd.sh
index a634ffc..6611a8b 100644
--- a/test_pam_goatherd.sh
+++ b/test_pam_goatherd.sh
@@ -10,7 +10,7 @@ export PGHOST="$PWD/pg_pam_test"
 cleanup() {
     start_pg_cleanup
 
-    pkill goatherd
+    pkill -u $USER goatherd
 }
 trap 'cleanup' EXIT INT
 
@@ -35,12 +35,15 @@ for i in $(seq 1 3); do
     ghdb $i init-db
 done
 
+servicedir=$PWD/test_pam_goatherd_services
+mkdir -p $servicedir
+
 
 echo
 echo ===== Tests =====
 echo == Single server tests ==
 
-echo auth requisite $PWD/pam_goatherd.so certs=test.crt server=localhost:9999 >$PWD/test_pam_goatherd_services/single_server
+echo auth requisite $PWD/pam_goatherd.so certs=test.crt server=localhost:9989 >$servicedir/single_server
 
 echo blub | if pw pamtester single_server someuser authenticate; then
     die "FAIL: Auth succeeded but no server is running"
@@ -48,7 +51,7 @@ else
     echo "(failure expected)"
 fi
 
-ghdb 1 serve -addr 127.0.0.1:9999 -tls-key test.key -tls-cert test.crt &
+ghdb 1 serve -addr 127.0.0.1:9989 -tls-key test.key -tls-cert test.crt &
 
 echo blub | if pw pamtester single_server someuser authenticate; then
     die "FAIL: Auth succeeded but user is not valid"
@@ -74,7 +77,7 @@ fi
 echo
 echo "== Multi server tests =="
 
-echo auth requisite $PWD/pam_goatherd.so certs=test.crt server=localhost:9999 server=localhost:9998 server=localhost:9997 >$PWD/test_pam_goatherd_services/three_servers
+echo auth requisite $PWD/pam_goatherd.so certs=test.crt server=localhost:9989 server=localhost:9988 server=localhost:9987 >$servicedir/three_servers
 
 oathtool -d 8 -c 2 $(echo -n $secret | xxd -p) | \
     if pw pamtester three_servers someuser authenticate; then
@@ -83,7 +86,7 @@ else
     echo "(failure expected)"
 fi
 
-ghdb 2 serve -addr 127.0.0.1:9998 -tls-key test.key -tls-cert test.crt &
+ghdb 2 serve -addr 127.0.0.1:9988 -tls-key test.key -tls-cert test.crt &
 
 oathtool -d 8 -c 2 $(echo -n $secret | xxd -p) | \
     if pw pamtester three_servers someuser authenticate; then
diff --git a/test_pg.sh b/test_pg.sh
index b9b9665..b575631 100644
--- a/test_pg.sh
+++ b/test_pg.sh
@@ -2,7 +2,7 @@
 
 set -eu
 
-go test -c &
+go test -c -o ./goatherd.test &
 
 PGHOST="$PWD/postgres_test"
 if [ $# -ge 1 ]; then
-- 
GitLab