From a2c731e1edad1a88f1c15ddacb5ea3d5ed3931c6 Mon Sep 17 00:00:00 2001 From: halex Date: Wed, 14 Jul 2010 06:19:26 +0000 Subject: [PATCH] add regress tests for upcoming redirection changes to ftp --- regress/usr.bin/ftp/Makefile | 69 +++++++++++++++++++++++++++++++-- regress/usr.bin/ftp/redirect.sh | 27 +++++++++++++ 2 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 regress/usr.bin/ftp/redirect.sh diff --git a/regress/usr.bin/ftp/Makefile b/regress/usr.bin/ftp/Makefile index 95397e6d0eb..e27c4550a07 100644 --- a/regress/usr.bin/ftp/Makefile +++ b/regress/usr.bin/ftp/Makefile @@ -1,9 +1,8 @@ -# $OpenBSD: Makefile,v 1.1 2010/06/29 21:22:03 halex Exp $ - -DASHO_TARGETS=1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 +# $OpenBSD: Makefile,v 1.2 2010/07/14 06:19:26 halex Exp $ REGRESS_TARGETS= \ - ${DASHO_TARGETS:C/^/t-dasho-/} + ${DASHO_TARGETS:C/^/t-dasho-/} \ + ${REDIRECT_TARGETS:C/^/t-redirect-/} dfile=file:../src/- xfile=file:../src/X @@ -60,4 +59,66 @@ t-dasho-15: t-dasho-16: ${dasho} "-V -o- -o '' ${dfile}" 0 "" "" "[-] DASH" +DASHO_TARGETS=1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 + + +rport1?= 9000 +rport2?= 9001 +rbase1= http://localhost:${rport1} +rbase2= http://localhost:${rport2} +rbase_1= http://[localhost]:${rport1} +rbase_2= http://[localhost]:${rport2} + +redirect= @rport1=${rport1} rport2=${rport2} sh ${.CURDIR}/redirect.sh + +# ${redirect} request Location: request + +t-redirect-1: + ${redirect} ${rbase1}/path/to/file ${rbase2}/another/file ${rbase2}/another/file + +t-redirect-2: + ${redirect} ${rbase1}/path/to/file ${rbase2}/ ${rbase2}/ + +t-redirect-3: + ${redirect} ${rbase1}/path/to/file /another/file ${rbase1}/another/file + +t-redirect-4: + ${redirect} ${rbase1}/path/to/file / ${rbase1}/ + +t-redirect-5: + ${redirect} ${rbase1}/path/to/file another/file ${rbase1}/path/to/another/file + +t-redirect-6: + ${redirect} ${rbase1}/path/to/file/ another/file ${rbase1}/path/to/file/another/file + +t-redirect-7: + ${redirect} ${rbase1}/path/to/file ../ ${rbase1}/path/to/../ + +t-redirect-8: + ${redirect} ${rbase1}/path/to/file ${rbase_2}/another/file ${rbase_2}/another/file + +t-redirect-9: + ${redirect} ${rbase1}/path/to/file ${rbase_2}/ ${rbase_2}/ + +t-redirect-10: + ${redirect} ${rbase1}/p/x?a#b?c#d another/file ${rbase1}/p/another/file + +t-redirect-11: + ${redirect} ${rbase1}/p/x#b?c#d another/file ${rbase1}/p/another/file + +t-redirect-12: + ${redirect} ${rbase1}/p/x/#b?c#d another/file ${rbase1}/p/x/another/file + +t-redirect-13: + ${redirect} ${rbase1}/p/x?aa#bb another/file?x#yz ${rbase1}/p/another/file?x + +t-redirect-14: + ${redirect} ${rbase1}/p/x/?aa#bb another/file?x#yz ${rbase1}/p/x/another/file?x + +t-redirect-15: + ${redirect} ${rbase1}/p/x#y?z/k#l?m file?a#b?c#d ${rbase1}/p/file?a + +REDIRECT_TARGETS=1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + + .include diff --git a/regress/usr.bin/ftp/redirect.sh b/regress/usr.bin/ftp/redirect.sh new file mode 100644 index 00000000000..6e365d2e56f --- /dev/null +++ b/regress/usr.bin/ftp/redirect.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +: ${FTP:=ftp} + +: ${rport1:=9000} +: ${rport2:=9001} + +req1=$1 +loc=$2 +req2=$3 + +echo "Testing $req1 => $loc => $req2" + +# Be sure to kill any previous nc running on our port +while pkill -fx "nc -l $rport1" && sleep 1; do done + +echo "HTTP/1.0 302 Found\r\nLocation: $loc\r\n\r" | nc -l $rport1 >&- & + +# Give the "server" some time to start +sleep .1 + +res=$(${FTP} -o/dev/null $req1 2>&1 | sed '/^Redirected to /{s///;x;};$!d;x') + +if [ X"$res" != X"$req2" ]; then + echo "*** Fail; expected \"$req2\", got \"$res\"" + exit 1 +fi -- 2.20.1