chiark / gitweb /
Testing: test srcdump
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 29 Oct 2015 00:38:26 +0000 (00:38 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 3 Nov 2015 18:36:04 +0000 (18:36 +0000)
We should test that the srcdump machinery works.
We test with needlogin=1 because that's more complicated.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
tests/cgi
tests/srcdump.at [new file with mode: 0644]

index e440948d6e530f559d4cfa4223c19c1a24754346..1e486d3cd8c2eded4617858dc6e07fe0fea80723 100755 (executable)
--- a/tests/cgi
+++ b/tests/cgi
@@ -46,6 +46,7 @@ my @verifier_params =(
     promise_check_mutate => 1,
     dir => $dump,
     srcdump_filter_cwd => 0,
+    srcdump_needlogin => 1,
     debug => sub { print STDERR "DEBUG ", @_[2..@_-1]; },
     get_url => sub { return $url },
 );
diff --git a/tests/srcdump.at b/tests/srcdump.at
new file mode 100644 (file)
index 0000000..76554ab
--- /dev/null
@@ -0,0 +1,84 @@
+# -*- Tcl -*-
+
+# This is part of CGI::Auth::Flexible, a perl CGI authentication module.
+#
+# Copyright 2012,2013,2015 Ian Jackson.
+# Copyright 2012,2013,2015 Citrix.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version, with the "CAF Login Exception"
+# as published by Ian Jackson (version 1, or at your option any 
+# later version) as an Additional Permission.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+
+set env(CAFTEST_NOSRCDUMP) 0
+
+set timeout [expr {$timeout * 3}]
+
+dospawn
+
+loginas alice
+
+send "B/source available\r\r"
+
+etxt "Save file to"
+
+set outertar $tt/t-srcdump.tgz
+set sd $tt/t-srcdump.d
+
+send "\x15$outertar\r"
+etxt "Download complete"
+
+exec mkdir $sd
+
+set files [exec tar -C $sd -zvxf - < $outertar]
+
+foreach f {
+    manifest.txt
+    licence.data       
+    cgi-auth-flexible.pm
+    .gitignore
+} {
+    set got($f) 0
+}
+
+if {[file exists .git]} {
+    set got(.git/objects/) 0
+}
+
+foreach f $files {
+    switch -glob -- $f {
+       licence.data - manifest.txt {
+           set got($f) 1
+       }
+       *.tar {
+           foreach g [exec tar -C $sd -tf - < $sd/$f] {
+               switch -glob -- $g {
+                   cgi-auth-flexible.pm - .gitignore - .git/objects/ {
+                       set got($g) 1
+                   }
+                   *~ {
+                       error "file $g inside $f !"
+                   }
+                   .git/* {
+                   }
+                   *.db {
+                       error "file $g inside $f outside .git !"
+                   }
+               }
+           }
+       }
+    }
+}
+
+foreach g [array names got] {
+    if {!$got($g)} {
+       error "file $g missing"
+    }
+}