diff options
-rw-r--r-- | regress/Makefile | 5 | ||||
-rw-r--r-- | regress/connect-uri.sh | 29 | ||||
-rw-r--r-- | regress/scp-uri.sh | 66 | ||||
-rw-r--r-- | regress/sftp-uri.sh | 63 |
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 | ||
3 | REGRESS_TARGETS= unit t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t-exec | 3 | REGRESS_TARGETS= unit t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t-exec |
4 | tests: prep $(REGRESS_TARGETS) | 4 | tests: prep $(REGRESS_TARGETS) |
@@ -19,6 +19,7 @@ distclean: clean | |||
19 | LTESTS= connect \ | 19 | LTESTS= 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 | |||
4 | tid="uri connect" | ||
5 | |||
6 | # Remove Port and User from ssh_config, we want to rely on the URI | ||
7 | cp $OBJ/ssh_config $OBJ/ssh_config.orig | ||
8 | egrep -v '^ +(Port|User) +.*$' $OBJ/ssh_config.orig > $OBJ/ssh_config | ||
9 | |||
10 | start_sshd | ||
11 | |||
12 | verbose "$tid: no trailing slash" | ||
13 | ${SSH} -F $OBJ/ssh_config "ssh://${USER}@somehost:${PORT}" true | ||
14 | if [ $? -ne 0 ]; then | ||
15 | fail "ssh connection failed" | ||
16 | fi | ||
17 | |||
18 | verbose "$tid: trailing slash" | ||
19 | ${SSH} -F $OBJ/ssh_config "ssh://${USER}@somehost:${PORT}/" true | ||
20 | if [ $? -ne 0 ]; then | ||
21 | fail "ssh connection failed" | ||
22 | fi | ||
23 | |||
24 | verbose "$tid: with path name" | ||
25 | ${SSH} -F $OBJ/ssh_config "ssh://${USER}@somehost:${PORT}/${DATA}" true \ | ||
26 | > /dev/null 2>&1 | ||
27 | if [ $? -eq 0 ]; then | ||
28 | fail "ssh connection succeeded, expected failure" | ||
29 | fi | ||
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 | |||
4 | tid="scp-uri" | ||
5 | |||
6 | #set -x | ||
7 | |||
8 | COPY2=${OBJ}/copy2 | ||
9 | DIR=${COPY}.dd | ||
10 | DIR2=${COPY}.dd2 | ||
11 | |||
12 | SRC=`dirname ${SCRIPT}` | ||
13 | cp ${SRC}/scp-ssh-wrapper.sh ${OBJ}/scp-ssh-wrapper.scp | ||
14 | chmod 755 ${OBJ}/scp-ssh-wrapper.scp | ||
15 | scpopts="-q -S ${OBJ}/scp-ssh-wrapper.scp" | ||
16 | export SCP # used in scp-ssh-wrapper.scp | ||
17 | |||
18 | scpclean() { | ||
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 | ||
24 | cp $OBJ/ssh_config $OBJ/ssh_config.orig | ||
25 | egrep -v '^ +(Port|User) +.*$' $OBJ/ssh_config.orig > $OBJ/ssh_config | ||
26 | |||
27 | verbose "$tid: simple copy local file to remote file" | ||
28 | scpclean | ||
29 | $SCP $scpopts ${DATA} "scp://${USER}@somehost:${PORT}/${COPY}" || fail "copy failed" | ||
30 | cmp ${DATA} ${COPY} || fail "corrupted copy" | ||
31 | |||
32 | verbose "$tid: simple copy remote file to local file" | ||
33 | scpclean | ||
34 | $SCP $scpopts "scp://${USER}@somehost:${PORT}/${DATA}" ${COPY} || fail "copy failed" | ||
35 | cmp ${DATA} ${COPY} || fail "corrupted copy" | ||
36 | |||
37 | verbose "$tid: simple copy local file to remote dir" | ||
38 | scpclean | ||
39 | cp ${DATA} ${COPY} | ||
40 | $SCP $scpopts ${COPY} "scp://${USER}@somehost:${PORT}/${DIR}" || fail "copy failed" | ||
41 | cmp ${COPY} ${DIR}/copy || fail "corrupted copy" | ||
42 | |||
43 | verbose "$tid: simple copy remote file to local dir" | ||
44 | scpclean | ||
45 | cp ${DATA} ${COPY} | ||
46 | $SCP $scpopts "scp://${USER}@somehost:${PORT}/${COPY}" ${DIR} || fail "copy failed" | ||
47 | cmp ${COPY} ${DIR}/copy || fail "corrupted copy" | ||
48 | |||
49 | verbose "$tid: recursive local dir to remote dir" | ||
50 | scpclean | ||
51 | rm -rf ${DIR2} | ||
52 | cp ${DATA} ${DIR}/copy | ||
53 | $SCP $scpopts -r ${DIR} "scp://${USER}@somehost:${PORT}/${DIR2}" || fail "copy failed" | ||
54 | diff -rN ${DIR} ${DIR2} || fail "corrupted copy" | ||
55 | |||
56 | verbose "$tid: recursive remote dir to local dir" | ||
57 | scpclean | ||
58 | rm -rf ${DIR2} | ||
59 | cp ${DATA} ${DIR}/copy | ||
60 | $SCP $scpopts -r "scp://${USER}@somehost:${PORT}/${DIR}" ${DIR2} || fail "copy failed" | ||
61 | diff -rN ${DIR} ${DIR2} || fail "corrupted copy" | ||
62 | |||
63 | # TODO: scp -3 | ||
64 | |||
65 | scpclean | ||
66 | rm -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 | |||
4 | tid="sftp-uri" | ||
5 | |||
6 | #set -x | ||
7 | |||
8 | COPY2=${OBJ}/copy2 | ||
9 | DIR=${COPY}.dd | ||
10 | DIR2=${COPY}.dd2 | ||
11 | SRC=`dirname ${SCRIPT}` | ||
12 | |||
13 | sftpclean() { | ||
14 | rm -rf ${COPY} ${COPY2} ${DIR} ${DIR2} | ||
15 | mkdir ${DIR} ${DIR2} | ||
16 | } | ||
17 | |||
18 | start_sshd -oForceCommand="internal-sftp -d /" | ||
19 | |||
20 | # Remove Port and User from ssh_config, we want to rely on the URI | ||
21 | cp $OBJ/ssh_config $OBJ/ssh_config.orig | ||
22 | egrep -v '^ +(Port|User) +.*$' $OBJ/ssh_config.orig > $OBJ/ssh_config | ||
23 | |||
24 | verbose "$tid: non-interactive fetch to local file" | ||
25 | sftpclean | ||
26 | ${SFTP} -q -S "$SSH" -F $OBJ/ssh_config "sftp://${USER}@somehost:${PORT}/${DATA}" ${COPY} || fail "copy failed" | ||
27 | cmp ${DATA} ${COPY} || fail "corrupted copy" | ||
28 | |||
29 | verbose "$tid: non-interactive fetch to local dir" | ||
30 | sftpclean | ||
31 | cp ${DATA} ${COPY} | ||
32 | ${SFTP} -q -S "$SSH" -F $OBJ/ssh_config "sftp://${USER}@somehost:${PORT}/${COPY}" ${DIR} || fail "copy failed" | ||
33 | cmp ${COPY} ${DIR}/copy || fail "corrupted copy" | ||
34 | |||
35 | verbose "$tid: put to remote directory (trailing slash)" | ||
36 | sftpclean | ||
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 | ||
41 | EOF | ||
42 | r=$? | ||
43 | if [ $r -ne 0 ]; then | ||
44 | fail "sftp failed with $r" | ||
45 | else | ||
46 | cmp ${DATA} ${DIR}/copy || fail "corrupted copy" | ||
47 | fi | ||
48 | |||
49 | verbose "$tid: put to remote directory (no slash)" | ||
50 | sftpclean | ||
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 | ||
55 | EOF | ||
56 | r=$? | ||
57 | if [ $r -ne 0 ]; then | ||
58 | fail "sftp failed with $r" | ||
59 | else | ||
60 | cmp ${DATA} ${DIR}/copy || fail "corrupted copy" | ||
61 | fi | ||
62 | |||
63 | sftpclean | ||