chiark / gitweb /
b3118d32047bc413eba482da362444a6bafa2a0f
[cgi-auth-flexible.git] / tests / autotest
1 #!/usr/bin/expect -f
2
3 set testfile [lindex $argv 0]
4
5 set tt tests/tmp
6
7 exec rm -rf $tt
8 exec mkdir $tt
9
10 set pwd [pwd]
11
12 set env(HOME) $tt
13 set env(CAFTEST_CAF) $pwd
14 set env(TERM) vt100
15 set env(CAFTEST_NOSRCDUMP) 1
16
17 log_user 0
18 log_file -a $tt/expect.log
19
20 proc timeout-abort {} {
21      send_log "\r\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
22      error "aborting due to timeout"
23 }
24 set timeout 5
25
26 expect_after timeout timeout-abort
27
28 proc elog {args} {
29      set m "[list expect [lindex $args end]]"
30      puts stderr $m
31 #     send_log "\n$m\n"
32      eval expect $args
33 }
34
35 proc etxt {str} {
36      regsub -all { } $str {\W{0,3}\w?} str
37      elog -re $str
38 }
39
40 proc epage {str} {
41     etxt $str
42 }
43
44 proc dospawn {} {
45      global pwd spawn_id
46
47      spawn -nottycopy \
48      w3m -config /dev/null -o cgi_bin=$pwd/tests file:///cgi-bin/wrap/Tsuffix
49
50      epage {You need to log in}
51 }
52
53 proc fillformfield {value} {
54     send "\t\r$value\r"
55 }
56
57 proc submitform-expect {wanttxt} {
58     send "\r"
59     etxt "loading file"
60     epage $wanttxt
61 }
62
63 proc loginas {user {password sesame} {wanttxt ACCESSGRANTED}} {
64      fillformfield $user
65      fillformfield $password
66      send "\t"
67      submitform-expect $wanttxt
68 }
69
70 source $testfile
71
72 puts ok