File tree Expand file tree Collapse file tree 3 files changed +92
-0
lines changed
Expand file tree Collapse file tree 3 files changed +92
-0
lines changed Original file line number Diff line number Diff line change 2020example : build
2121 ./build/Darwin/sshfront -d -p 2222 -k ~ /.ssh/id_rsa example/helloworld
2222
23+ test :
24+ docker build -t $(NAME ) -tests tests
25+ docker run --rm \
26+ -v $(PWD ) /tests:/tests \
27+ -v $(PWD ) /build/Linux/sshfront:/bin/sshfront \
28+ $(NAME ) -tests \
29+ basht /tests/* .bash
2330
2431release :
2532 rm -rf release && mkdir release
Original file line number Diff line number Diff line change 1+ FROM alpine
2+ RUN apk --update add expect bash openssh curl \
3+ && ssh-keygen -t rsa -N "" -f /root/.ssh/id_rsa \
4+ && curl -Ls https://github.com/progrium/basht/releases/download/v0.1.0/basht_0.1.0_Linux_x86_64.tgz \
5+ | tar -zxC /bin
Original file line number Diff line number Diff line change 1+
2+ write-script () {
3+ declare script=" $1 "
4+ echo " #!/bin/sh"
5+ echo " $script "
6+ }
7+
8+ setup-daemon () {
9+ write-script " true" > /tmp/auth
10+ write-script " true" > /tmp/handler
11+ chmod +x /tmp/auth /tmp/handler
12+ sshfront -a /tmp/auth /tmp/handler &
13+ sleep 1
14+ expect << -EOF
15+ set timeout 1
16+ spawn ssh test@localhost
17+ expect {
18+ timeout { exit 1 }
19+ eof { exit 1 }
20+ "Are you sure" {
21+ send "yes\r"
22+ sleep 1
23+ exit 0
24+ }
25+ }
26+ exit 1
27+ EOF
28+ echo
29+ }
30+ setup-daemon
31+
32+ T_user-env () {
33+ write-script " env" > /tmp/handler
34+ expect << -EOF
35+ set timeout 1
36+ spawn ssh foobar@localhost
37+ expect {
38+ timeout { exit 1 }
39+ eof { exit 1 }
40+ "USER=foobar" { exit 0 }
41+ }
42+ exit 1
43+ EOF
44+ }
45+
46+
47+ T_echo-handler () {
48+ write-script ' echo $@' > /tmp/handler
49+ expect << -EOF
50+ set timeout 1
51+ spawn ssh test@localhost foo bar baz
52+ expect {
53+ timeout { exit 1 }
54+ eof { exit 1 }
55+ "foo bar baz" { exit 0 }
56+ }
57+ exit 1
58+ EOF
59+ }
60+
61+ T_interactive-handler () {
62+ write-script ' exec bash' > /tmp/handler
63+ expect << -EOF
64+ set timeout 1
65+ spawn ssh test@localhost
66+ expect {
67+ timeout { exit 1 }
68+ eof { exit 1 }
69+ "bash-4.3#" {
70+ send "echo hello\r"
71+ expect {
72+ timeout { exit 1 }
73+ eof { exit 1 }
74+ "hello" { exit 0 }
75+ }
76+ }
77+ }
78+ exit 1
79+ EOF
80+ }
You can’t perform that action at this time.
0 commit comments