Index: openacs-4/packages/acs-automated-testing/tcl/tclwebtest-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-automated-testing/tcl/tclwebtest-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/acs-automated-testing/tcl/tclwebtest-procs.tcl 10 Jan 2007 21:22:01 -0000 1.6 +++ openacs-4/packages/acs-automated-testing/tcl/tclwebtest-procs.tcl 14 May 2007 20:30:18 -0000 1.7 @@ -151,22 +151,38 @@ -permanent } -ad_proc twt::user::login { email password } { +ad_proc twt::user::login { email password {username ""}} { tclwebtest for logging the user in. @param email Email of user to log in. @param password Password of user to log in. } { - + if {$username eq ""} { + set username $email + } + aa_log "twt::login email $email password $password username $username" tclwebtest::cookies clear # Request the start page ::twt::do_request "[twt::server_url]/register" # Login the user tclwebtest::form find ~n login - tclwebtest::field find ~n email - tclwebtest::field fill "$email" + + set local_authority_id [auth::authority::local] + set local_authority_pretty_name [auth::authority::get_element -authority_id $local_authority_id -element pretty_name] + if {![catch {tclwebtest::field find ~n authority_id} errmsg]} { + tclwebtest::field select $local_authority_pretty_name + aa_log "twt::login selecting authority_id $local_authority_id" + } + if {[catch {tclwebtest::field find ~n email} errmsg]} { + tclwebtest::field find ~n username + tclwebtest::field fill $username + aa_log "twt::login using username instead of email" + } else { + aa_log "twt::login using email instead of username" + tclwebtest::field fill "$email" + } tclwebtest::field find ~n password tclwebtest::field fill $password tclwebtest::form submit @@ -175,6 +191,7 @@ set home_uri "/pvt/home" twt::do_request $home_uri set response_url [tclwebtest::response url] + if { ![string match "*${home_uri}*" $response_url] } { if { [empty_string_p [cc_lookup_email_user $email]] } { error "Failed to login user with email=\"$email\" and password=\"$password\". No user with such email in database."