chiark / gitweb /
Testing: More realistic mutating checks
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 27 Oct 2015 19:12:39 +0000 (19:12 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 27 Oct 2015 19:12:39 +0000 (19:12 +0000)
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
tests/cgi

index 764480d..da7b2f7 100755 (executable)
--- a/tests/cgi
+++ b/tests/cgi
@@ -58,17 +58,28 @@ my $incrurl = $authreq->url_with_query_params
     ({ counter => [ ($q->param('counter')//0) + 1 ]});
 my $incrurl_esc = escapeHTML($incrurl);
 
+my @critters = qw(sponges worms);
+
+foreach my $make (@critters) {
+    my $param = $q->param("test_cgi_$make");
+    if (!$param) {
+        print "NO-$make\n";
+    } else {
+        $authreq->check_mutate();
+        print "MAKING-$make\n";
+    }
+}
+
 print <<END;
 <h1>info<h1>
 <pre>
 END
 
 my $txt = Data::Dumper->Dump([$authreq->get_username(),
- $q->request_method eq 'POST' ? $authreq->check_mutate() : "(not POST)",
                               $q->path_info(),
                               $authreq->chain_params(),
                               scalar $q->Vars()],
-                             [qw(username mutate_ok path
+                             [qw(username path
                                  authreq->chain_params() cgi->params())]);
 foreach my $l (split /\n/, $txt) {
     print escapeHTML($l),"\n";
@@ -80,8 +91,13 @@ self=<a href="$newurl_esc">$newurl_esc</a>
 increment=<a href="$incrurl_esc">$incrurl_esc</a>
 <form method="POST" action="$url">
 $hiddenhtml
-<input type="submit" name="test_cgi_sponges" value="Make sponges">
-<input type="submit" name="test_cgi_worms" value="Make worms">
+END
+
+print <<END foreach @critters;
+<input type="submit" name="test_cgi_$_" value="Make $_">
+END
+
+print <<END
 <input type="submit" name="caf_logout" value="Logout">
 </form>
 <form method="POST" action="$url/extra">