chiark / gitweb /
Testing: autotest: Move some code about
[cgi-auth-flexible.git] / tests / autotest
index 2561f5667fb24e268f2a344baf996d633477a943..4ba46dc5fbf8d801d0044d88065e91651136a692 100755 (executable)
@@ -14,9 +14,6 @@ set env(TERM) vt100
 log_user 0
 log_file -a $tt/expect.log
 
-spawn -nottycopy \
-w3m -config /dev/null -o cgi_bin=$pwd/tests file:///cgi-bin/wrap/Tsuffix
-
 proc timeout-abort {} {
      send_log "\r\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
      error "aborting due to timeout"
@@ -41,7 +38,14 @@ proc epage {str} {
     etxt $str
 }
 
-epage {You need to log in}
+proc dospawn {} {
+     global pwd spawn_id
+
+     spawn -nottycopy \
+     w3m -config /dev/null -o cgi_bin=$pwd/tests file:///cgi-bin/wrap/Tsuffix
+
+     epage {You need to log in}
+}
 
 proc fillformfield {value} {
     send "\t\r$value\r"
@@ -53,15 +57,18 @@ proc submitform-expect {wanttxt} {
     epage $wanttxt
 }
 
-fillformfield alice
-fillformfield bogus
-send "\t"
-submitform-expect "wrong password"
+proc loginas {user {password sesame} {wanttxt ACCESSGRANTED}} {
+     fillformfield $user
+     fillformfield $password
+     send "\t"
+     submitform-expect $wanttxt
+}
+
+dospawn
+
+loginas alice bogus "wrong password"
 
-fillformfield alice
-fillformfield sesame
-send "\t"
-submitform-expect "ACCESSGRANTED"
+loginas alice
 
 etxt {path = '/Tsuffix'}
 
@@ -72,6 +79,19 @@ send "/Logout\r"
 submitform-expect "You have been logged out"
 
 send "B\x10/Make sponges\r"
-#submitform-expect "Something sane"
+submitform-expect "You need to log in"
+
+loginas bob
+
+send "/Logout\r"
+submitform-expect "You have been logged out"
+
+send "/Log in again\r"
+submitform-expect "need to log in"
+
+loginas bob
+
+send "BBB\x10/Make sponges\r"
+submitform-expect "Login session interrupted"
 
 puts ok