chiark / gitweb /
Testing: Break out loginout.at
[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
16 log_user 0
17 log_file -a $tt/expect.log
18
19 proc timeout-abort {} {
20      send_log "\r\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
21      error "aborting due to timeout"
22 }
23 set timeout 5
24
25 expect_after timeout timeout-abort
26
27 proc elog {args} {
28      set m "[list expect [lindex $args end]]"
29      puts stderr $m
30 #     send_log "\n$m\n"
31      eval expect $args
32 }
33
34 proc etxt {str} {
35      regsub -all { } $str {\W{0,3}\w?} str
36      elog -re $str
37 }
38
39 proc epage {str} {
40     etxt $str
41 }
42
43 proc dospawn {} {
44      global pwd spawn_id
45
46      spawn -nottycopy \
47      w3m -config /dev/null -o cgi_bin=$pwd/tests file:///cgi-bin/wrap/Tsuffix
48
49      epage {You need to log in}
50 }
51
52 proc fillformfield {value} {
53     send "\t\r$value\r"
54 }
55
56 proc submitform-expect {wanttxt} {
57     send "\r"
58     etxt "loading file"
59     epage $wanttxt
60 }
61
62 proc loginas {user {password sesame} {wanttxt ACCESSGRANTED}} {
63      fillformfield $user
64      fillformfield $password
65      send "\t"
66      submitform-expect $wanttxt
67 }
68
69 source $testfile
70
71 puts ok