summaryrefslogtreecommitdiff
path: root/regress/sftp-uri.sh
diff options
context:
space:
mode:
authormillert@openbsd.org@openbsd.org <millert@openbsd.org@openbsd.org>2017-10-24 19:33:32 +0000
committerDamien Miller <djm@mindrot.org>2017-10-31 09:08:51 +1100
commit116b1b439413a724ebb3320633a64dd0f3ee1fe7 (patch)
tree55da5d72989b0d26d1296f1689016664ae60f4d5 /regress/sftp-uri.sh
parentdbe0662e9cd482593a4a8bf58c6481bfe8a747a4 (diff)
upstream commit
Add tests for URI parsing. OK markus@ OpenBSD-Regress-ID: 5d1df19874f3b916d1a2256a905526e17a98bd3b
Diffstat (limited to 'regress/sftp-uri.sh')
-rw-r--r--regress/sftp-uri.sh63
1 files changed, 63 insertions, 0 deletions
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