-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.sh
executable file
·27 lines (22 loc) · 764 Bytes
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
set -euxo pipefail
export SSH_AGENT_PID=
cleanup() {
set +e
docker kill ssh-agent-inject-test
kill -9 $SSH_AGENT_PID $(jobs -p)
}
trap cleanup INT TERM EXIT
docker run -d --name ssh-agent-inject-test --rm \
-e SSH_AUTH_SOCK=/tmp/.ssh-auth-inject -l com.ensody.ssh-agent-inject \
alpine sh -c 'apk add --no-cache openssh-client && sleep 1800'
# Test in a clean environment with custom ssh-agent and ssh-key
eval "$(ssh-agent)"
tmpkey="$(mktemp)"
! yes y | ssh-keygen -t ed25519 -N "" -C "$tmpkey" -f "$tmpkey"
ssh-add "$tmpkey"
rm "$tmpkey"
# Inject ssh-agent and wait for injection to finish
./dist/unix_linux_amd64/ssh-agent-inject -v &
sleep 2
docker exec -t ssh-agent-inject-test ssh-add -l | grep -i ed25519 | grep "$tmpkey"