chiark / gitweb /
Testing: Provide test-wrap script
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 27 Oct 2015 16:50:05 +0000 (16:50 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 27 Oct 2015 17:15:43 +0000 (17:15 +0000)
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 <Ian.Jackson@eu.citrix.com>
TODO
test-wrap [new file with mode: 0755]

diff --git a/TODO b/TODO
index 301c3b8731990cba56ffa65d04e7e84b77904c14..8061b338c3bed7ae0bb57cd914fd256db323af05 100644 (file)
--- 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 (executable)
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 $!";
+'