From: Ian Jackson Date: Tue, 27 Oct 2015 16:50:05 +0000 (+0000) Subject: Testing: Provide test-wrap script X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=b7f76b8d0d95ef36b323f19741eb5355f4be28ee;p=cgi-auth-flexible.git Testing: Provide test-wrap script w3m in local cgi mode does not appear to honour our attempts to set cookies. Provide a test-wrap script which fishes the cookie out of CAF's output and passes it back in on the next run. Document the necessary rune. Signed-off-by: Ian Jackson --- diff --git a/TODO b/TODO index 301c3b8..8061b33 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,7 @@ REQUEST_METHOD=post CAHTEST_HOME=`pwd` ./test.cgi ; echo +CAFTEST_URL=file:/cgi-bin/test-wrap CAHTEST_HOME=`pwd` w3m -cookie -config /dev/null -o cgi_bin=`pwd` file:///cgi-bin/test-wrap + update last in db when we return undef from check_divert diff --git a/test-wrap b/test-wrap new file mode 100755 index 0000000..b896e82 --- /dev/null +++ b/test-wrap @@ -0,0 +1,13 @@ +#!/bin/sh +set -e +exec 2>>"$CAHTEST_HOME/test-data/log" +export HTTP_COOKIE=$(cat "$CAHTEST_HOME/test-data/cookie") +./test.cgi "$@" | perl -pe ' + next if m/^$/..0; + next unless m/Set-Cookie: (\w+=[^; ]+)/; + my $cf = "$ENV{CAHTEST_HOME}/test-data/cookie"; + open C, ">", "$cf.new" or die "$cf $!"; + print C $1 or die $!; + close C or die $!; + rename "$cf.new", $cf or die "$cf $!"; +'