summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/Makefile5
-rw-r--r--regress/connect-uri.sh29
-rw-r--r--regress/scp-uri.sh66
-rw-r--r--regress/sftp-uri.sh63
4 files changed, 162 insertions, 1 deletions
diff --git a/regress/Makefile b/regress/Makefile
index 7d50f9cfa..d15898ad0 100644
--- a/regress/Makefile
+++ b/regress/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.95 2017/06/24 06:35:24 djm Exp $ 1# $OpenBSD: Makefile,v 1.96 2017/10/24 19:33:32 millert Exp $
2 2
3REGRESS_TARGETS= unit t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t-exec 3REGRESS_TARGETS= unit t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t-exec
4tests: prep $(REGRESS_TARGETS) 4tests: prep $(REGRESS_TARGETS)
@@ -19,6 +19,7 @@ distclean: clean
19LTESTS= connect \ 19LTESTS= connect \
20 proxy-connect \ 20 proxy-connect \
21 connect-privsep \ 21 connect-privsep \
22 connect-uri \
22 proto-version \ 23 proto-version \
23 proto-mismatch \ 24 proto-mismatch \
24 exit-status \ 25 exit-status \
@@ -42,6 +43,7 @@ LTESTS= connect \
42 keygen-moduli \ 43 keygen-moduli \
43 key-options \ 44 key-options \
44 scp \ 45 scp \
46 scp-uri \
45 sftp \ 47 sftp \
46 sftp-chroot \ 48 sftp-chroot \
47 sftp-cmds \ 49 sftp-cmds \
@@ -49,6 +51,7 @@ LTESTS= connect \
49 sftp-batch \ 51 sftp-batch \
50 sftp-glob \ 52 sftp-glob \
51 sftp-perm \ 53 sftp-perm \
54 sftp-uri \
52 reconfigure \ 55 reconfigure \
53 dynamic-forward \ 56 dynamic-forward \
54 forwarding \ 57 forwarding \
diff --git a/regress/connect-uri.sh b/regress/connect-uri.sh
new file mode 100644
index 000000000..f13f15e66
--- /dev/null
+++ b/regress/connect-uri.sh
@@ -0,0 +1,29 @@
1# $OpenBSD: connect-uri.sh,v 1.1 2017/10/24 19:33:32 millert Exp $
2# Placed in the Public Domain.
3
4tid="uri connect"
5
6# Remove Port and User from ssh_config, we want to rely on the URI
7cp $OBJ/ssh_config $OBJ/ssh_config.orig
8egrep -v '^ +(Port|User) +.*$' $OBJ/ssh_config.orig > $OBJ/ssh_config
9
10start_sshd
11
12verbose "$tid: no trailing slash"
13${SSH} -F $OBJ/ssh_config "ssh://${USER}@somehost:${PORT}" true
14if [ $? -ne 0 ]; then
15 fail "ssh connection failed"
16fi
17
18verbose "$tid: trailing slash"
19${SSH} -F $OBJ/ssh_config "ssh://${USER}@somehost:${PORT}/" true
20if [ $? -ne 0 ]; then
21 fail "ssh connection failed"
22fi
23
24verbose "$tid: with path name"
25${SSH} -F $OBJ/ssh_config "ssh://${USER}@somehost:${PORT}/${DATA}" true \
26 > /dev/null 2>&1
27if [ $? -eq 0 ]; then
28 fail "ssh connection succeeded, expected failure"
29fi
diff --git a/regress/scp-uri.sh b/regress/scp-uri.sh
new file mode 100644
index 000000000..bf21bf32e
--- /dev/null
+++ b/regress/scp-uri.sh
@@ -0,0 +1,66 @@
1# $OpenBSD: scp-uri.sh,v 1.1 2017/10/24 19:33:32 millert Exp $
2# Placed in the Public Domain.
3
4tid="scp-uri"
5
6#set -x
7
8COPY2=${OBJ}/copy2
9DIR=${COPY}.dd
10DIR2=${COPY}.dd2
11
12SRC=`dirname ${SCRIPT}`
13cp ${SRC}/scp-ssh-wrapper.sh ${OBJ}/scp-ssh-wrapper.scp
14chmod 755 ${OBJ}/scp-ssh-wrapper.scp
15scpopts="-q -S ${OBJ}/scp-ssh-wrapper.scp"
16export SCP # used in scp-ssh-wrapper.scp
17
18scpclean() {
19 rm -rf ${COPY} ${COPY2} ${DIR} ${DIR2}
20 mkdir ${DIR} ${DIR2}
21}
22
23# Remove Port and User from ssh_config, we want to rely on the URI
24cp $OBJ/ssh_config $OBJ/ssh_config.orig
25egrep -v '^ +(Port|User) +.*$' $OBJ/ssh_config.orig > $OBJ/ssh_config
26
27verbose "$tid: simple copy local file to remote file"
28scpclean
29$SCP $scpopts ${DATA} "scp://${USER}@somehost:${PORT}/${COPY}" || fail "copy failed"
30cmp ${DATA} ${COPY} || fail "corrupted copy"
31
32verbose "$tid: simple copy remote file to local file"
33scpclean
34$SCP $scpopts "scp://${USER}@somehost:${PORT}/${DATA}" ${COPY} || fail "copy failed"
35cmp ${DATA} ${COPY} || fail "corrupted copy"
36
37verbose "$tid: simple copy local file to remote dir"
38scpclean
39cp ${DATA} ${COPY}
40$SCP $scpopts ${COPY} "scp://${USER}@somehost:${PORT}/${DIR}" || fail "copy failed"
41cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
42
43verbose "$tid: simple copy remote file to local dir"
44scpclean
45cp ${DATA} ${COPY}
46$SCP $scpopts "scp://${USER}@somehost:${PORT}/${COPY}" ${DIR} || fail "copy failed"
47cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
48
49verbose "$tid: recursive local dir to remote dir"
50scpclean
51rm -rf ${DIR2}
52cp ${DATA} ${DIR}/copy
53$SCP $scpopts -r ${DIR} "scp://${USER}@somehost:${PORT}/${DIR2}" || fail "copy failed"
54diff -rN ${DIR} ${DIR2} || fail "corrupted copy"
55
56verbose "$tid: recursive remote dir to local dir"
57scpclean
58rm -rf ${DIR2}
59cp ${DATA} ${DIR}/copy
60$SCP $scpopts -r "scp://${USER}@somehost:${PORT}/${DIR}" ${DIR2} || fail "copy failed"
61diff -rN ${DIR} ${DIR2} || fail "corrupted copy"
62
63# TODO: scp -3
64
65scpclean
66rm -f ${OBJ}/scp-ssh-wrapper.exe
diff --git a/regress/sftp-uri.sh b/regress/sftp-uri.sh
new file mode 100644
index 000000000..4d19dd716
--- /dev/null
+++ b/regress/sftp-uri.sh
@@ -0,0 +1,63 @@
1# $OpenBSD: sftp-uri.sh,v 1.1 2017/10/24 19:33:32 millert Exp $
2# Placed in the Public Domain.
3
4tid="sftp-uri"
5
6#set -x
7
8COPY2=${OBJ}/copy2
9DIR=${COPY}.dd
10DIR2=${COPY}.dd2
11SRC=`dirname ${SCRIPT}`
12
13sftpclean() {
14 rm -rf ${COPY} ${COPY2} ${DIR} ${DIR2}
15 mkdir ${DIR} ${DIR2}
16}
17
18start_sshd -oForceCommand="internal-sftp -d /"
19
20# Remove Port and User from ssh_config, we want to rely on the URI
21cp $OBJ/ssh_config $OBJ/ssh_config.orig
22egrep -v '^ +(Port|User) +.*$' $OBJ/ssh_config.orig > $OBJ/ssh_config
23
24verbose "$tid: non-interactive fetch to local file"
25sftpclean
26${SFTP} -q -S "$SSH" -F $OBJ/ssh_config "sftp://${USER}@somehost:${PORT}/${DATA}" ${COPY} || fail "copy failed"
27cmp ${DATA} ${COPY} || fail "corrupted copy"
28
29verbose "$tid: non-interactive fetch to local dir"
30sftpclean
31cp ${DATA} ${COPY}
32${SFTP} -q -S "$SSH" -F $OBJ/ssh_config "sftp://${USER}@somehost:${PORT}/${COPY}" ${DIR} || fail "copy failed"
33cmp ${COPY} ${DIR}/copy || fail "corrupted copy"
34
35verbose "$tid: put to remote directory (trailing slash)"
36sftpclean
37${SFTP} -q -S "$SSH" -F $OBJ/ssh_config -b /dev/stdin \
38 "sftp://${USER}@somehost:${PORT}/${DIR}/" > /dev/null 2>&1 << EOF
39 version
40 put ${DATA} copy
41EOF
42r=$?
43if [ $r -ne 0 ]; then
44 fail "sftp failed with $r"
45else
46 cmp ${DATA} ${DIR}/copy || fail "corrupted copy"
47fi
48
49verbose "$tid: put to remote directory (no slash)"
50sftpclean
51${SFTP} -q -S "$SSH" -F $OBJ/ssh_config -b /dev/stdin \
52 "sftp://${USER}@somehost:${PORT}/${DIR}" > /dev/null 2>&1 << EOF
53 version
54 put ${DATA} copy
55EOF
56r=$?
57if [ $r -ne 0 ]; then
58 fail "sftp failed with $r"
59else
60 cmp ${DATA} ${DIR}/copy || fail "corrupted copy"
61fi
62
63sftpclean