chiark / gitweb /
Testing: Test going back
[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/Tsuffix
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 "\r"
52     etxt "loading file"
53     epage $wanttxt
54 }
55
56 fillformfield alice
57 fillformfield bogus
58 send "\t"
59 submitform-expect "wrong password"
60
61 fillformfield alice
62 fillformfield sesame
63 send "\t"
64 submitform-expect "ACCESSGRANTED"
65
66 etxt {path = '/Tsuffix'}
67
68 send "/Make worms\r"
69 submitform-expect "MAKING-worms"
70
71 send "/Logout\r"
72 submitform-expect "You have been logged out"
73
74 send "B\x10/Make sponges\r"
75 #submitform-expect "Something sane"
76
77 puts ok