chiark / gitweb /
Testing: Log in
[cgi-auth-flexible.git] / tests / autotest
1 #!/usr/bin/expect -f
2
3 set tt tests/tmp
4
5 exec rm -rf $tt
6 exec mkdir $tt
7
8 set pwd [pwd]
9
10 set env(HOME) $tt
11 set env(CAFTEST_CAF) $pwd
12 set env(TERM) vt100
13
14 log_user 0
15 log_file -a $tt/expect.log
16
17 spawn -nottycopy \
18 w3m -config /dev/null -o cgi_bin=$pwd/tests file:///cgi-bin/wrap
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 epage {You need to log in}
45
46 proc fillformfield {value} {
47     send "\t\r$value\r"
48 }
49
50 proc submitform-expect {wanttxt} {
51     send "\t\r"
52     etxt "loading file"
53     epage $wanttxt
54 }
55
56 fillformfield alice
57 fillformfield bogus
58 submitform-expect "wrong password"
59
60 fillformfield alice
61 fillformfield sesame
62 submitform-expect "ACCESSGRANTED"
63
64 puts ok