summaryrefslogtreecommitdiff
path: root/test/tests.sh
diff options
context:
space:
mode:
Diffstat (limited to 'test/tests.sh')
-rw-r--r--test/tests.sh66
1 files changed, 66 insertions, 0 deletions
diff --git a/test/tests.sh b/test/tests.sh
new file mode 100644
index 0000000..5d221b6
--- /dev/null
+++ b/test/tests.sh
@@ -0,0 +1,66 @@
1#!/bin/sh
2set -ex
3USER=u
4DIR=src/anonymous-ssh
5HOST=localhost
6SSH_ID=~/.ssh/id_ed25519
7
8get_sshfp()
9{
10 (
11 key="$1"
12 r="${2:-.}"
13 dns=$(mktemp) || exit
14 trap 'rm -rf "$dns"' EXIT
15
16 ssh-keygen -r "$r" -f "$key" > "$dns"
17 exec < "$dns"
18 while read line
19 do
20 set -- $line
21 if [ "$3 $5" = "SSHFP 2" ]
22 then
23 echo "$line"
24 break
25 fi
26 done
27 )
28}
29
30make_test_commit()
31{
32 newfile=newfile.$(date -Ins|tr -d :)
33 touch "$newfile"
34 git add "$newfile"
35 git commit -m "$newfile"
36}
37
38[ -e "$SSH_ID" ] || ssh-keygen -t ed25519 -f "$SSH_ID" -P ''
39
40git_namespace=$(set -- $(get_sshfp "$SSH_ID") && echo $6)
41
42ssh -o NoHostAuthenticationForLocalhost=yes $USER@$HOST -- test || true
43[ ! -e anonymous-ssh ] || rm -rf anonymous-ssh
44export GIT_SSH_COMMAND="ssh -o NoHostAuthenticationForLocalhost=yes -i $SSH_ID"
45git clone -v ${USER}@${HOST}:${DIR}
46cd anonymous-ssh
47
48make
49
50git pull --ff-only
51make_test_commit
52git push -f
53make_test_commit
54git push
55git log -n4
56git pull --ff-only
57git log -n4
58git push
59
60# branch=$(git branch -q --show-current)
61# forkname=origin-myfork
62# ns_branch=refs/namespaces/$git_namespace/refs/heads/$branch
63# git remote add -m "$ns_branch" "$forkname" $(git remote get-url origin)
64# git push "$forkname"
65# git pull "$forkname" --ff-only "$branch"
66exit