add e2e test tools

This commit is contained in:
Boshi Lian 2018-02-14 01:07:43 +08:00
parent 65bbc172d8
commit 57b7d7da57
2 changed files with 89 additions and 0 deletions

View file

@ -0,0 +1,40 @@
version: '3'
services:
client:
image: rastasheep/ubuntu-sshd
volumes:
- workingdir:/workingdir
- localkey:/local
- host1ssh:/host1
- names:/names
- ./test.sh:/test.sh
links:
- "piper:piper"
command:
- "/bin/bash"
- "/test.sh"
piper:
environment:
- "SSHPIPERD_NO_CHECK_PERM=true"
build: ../..
links:
- "host1:host1"
- "host2:host2"
volumes:
- workingdir:/var/sshpiper
host1:
image: rastasheep/ubuntu-sshd
volumes:
- host1ssh:/root/.ssh
- names:/names
host2:
image: rastasheep/ubuntu-sshd
volumes:
- names:/names
volumes:
workingdir:
localkey:
host1ssh:
names:

49
sshpiperd/e2e/test.sh Normal file
View file

@ -0,0 +1,49 @@
#!/bin/bash
apt-get update
apt-get install -y sshpass
mkdir -p /local
mkdir -p /workingdir/host{1,2}
ssh-keygen -N '' -f /local/id_rsa
ssh-keygen -N '' -f /workingdir/host1/id_rsa
/bin/cp /local/id_rsa.pub /workingdir/host1/authorized_keys
/bin/cp /workingdir/host1/id_rsa.pub /host1/authorized_keys
echo "root@host1" > /workingdir/host1/sshpiper_upstream
echo "root@host2" > /workingdir/host2/sshpiper_upstream
fail="\033[0;31mFAIL\033[0m"
succ="\033[0;32mSUCC\033[0m"
while true; do
casename="host1 with public key: "
rnd=`head -c 6 /dev/urandom | base64`
echo $rnd > /names/host1
t=`ssh host1@piper -p 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /local/id_rsa cat /names/host1`
if [ $t != $rnd ];then
echo -e $casename $fail
else
echo -e $casename $succ
fi
casename="host2 with password"
rnd=`head -c 6 /dev/urandom | base64`
echo $rnd > /names/host2
t=`sshpass -p root ssh host2@piper -p 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null cat /names/host2`
if [ $t != $rnd ];then
echo -e $casename $fail
else
echo -e $casename $succ
fi
sleep 1
done