_acs-authentication__auth_authenticate (private)
_acs-authentication__auth_authenticate
Defined in packages/acs-authentication/tcl/test/acs-authentication-procs.tcl
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set _aa_export {} set body_count 1 foreach testcase_body {{ aa_run_with_teardown -rollback -test_code { array set result [acs::test::user::create] set password $result(password) if { ![aa_equals "creation_status for successful creation" $result(creation_status) "ok"] } { aa_log "Creation result: [array get result]" } set user [acs_user::get_user_info -user_id $result(user_id)] set authority_id [dict get $user authority_id] set username [dict get $user username] set user_id [acs_user::get_by_username -authority_id $authority_id -username $username] aa_equals "Username from apis matches" $result(user_id) $user_id ## Portrait api test set old_portrait_id [acs_user::get_portrait_id -user_id $user_id] # use a bogus image from a core package as test portrait set portrait_file [acs_package_root_dir acs-templating]/www/resources/sort-neither.png set new_portrait_id [acs_user::create_portrait -user_id $user_id -description [ad_generate_random_string] -filename [ad_generate_random_string] -file $portrait_file] aa_true "A portrait was correctly created" [string is integer -strict $new_portrait_id] aa_true "Old and new portrait differ" {$new_portrait_id ne $old_portrait_id} set old_portrait_id [acs_user::get_portrait_id -user_id $user_id] aa_equals "Portrait retrieval returns the new portrait" $new_portrait_id $old_portrait_id acs_user::erase_portrait -user_id $user_id set new_portrait_id [acs_user::get_portrait_id -user_id $user_id] aa_equals "Portrait was erased correctly" $new_portrait_id 0 ### # Successful authentication array unset result array set result [auth::authenticate -authority_id $authority_id -no_cookie -username $username -password $password] aa_log "Result: [array get result]" aa_equals "auth_status for successful authentication" $result(auth_status) "ok" # Failed authentications # Incorrect password array unset auth_info array set auth_info [auth::authenticate -authority_id $authority_id -no_cookie -username $username -password "blabla"] aa_equals "auth_status for bad password authentication" $auth_info(auth_status) "bad_password" aa_true "auth_message for bad password authentication" {$auth_info(auth_message) ne ""} # Blank password array unset auth_info array set auth_info [auth::authenticate -authority_id $authority_id -no_cookie -username $username -password ""] aa_equals "auth_status for blank password authentication" $auth_info(auth_status) "bad_password" aa_true "auth_message for blank password authentication" {$auth_info(auth_message) ne ""} # Incorrect username array unset auth_info array set auth_info [auth::authenticate -authority_id $authority_id -no_cookie -username "blabla" -password $password] aa_equals "auth_status for bad username authentication" $auth_info(auth_status) "no_account" aa_true "auth_message for bad username authentication" {$auth_info(auth_message) ne ""} # Blank username array unset auth_info array set auth_info [auth::authenticate -authority_id $authority_id -no_cookie -username "" -password $password] aa_equals "auth_status for blank username authentication" $auth_info(auth_status) "auth_error" aa_true "auth_message for blank username authentication" {$auth_info(auth_message) ne ""} # Authority bogus array unset auth_info aa_silence_log_entries -severities error { array set auth_info [auth::authenticate -no_cookie -authority_id -123 -username $username -password $password] } aa_equals "auth_status for bad authority_id authentication" $auth_info(auth_status) "failed_to_connect" aa_true "auth_message for bad authority_id authentication" {$auth_info(auth_message) ne ""} # Closed account status set closed_states {banned rejected "needs approval" deleted} foreach closed_state $closed_states { acs_user::change_state -user_id $user_id -state $closed_state # Successful authentication array unset auth_info array set auth_info [auth::authenticate -authority_id $authority_id -no_cookie -username $username -password $password] aa_equals "auth_status for '$closed_state' user" $auth_info(auth_status) "ok" if {$auth_info(auth_status) eq "ok"} { # Only perform this test if auth_status is ok, otherwise account_status won't be set aa_equals "account_status for '$closed_state' user" $auth_info(account_status) "closed" } } if { $user_id ne "" } { acs_user::delete -user_id $user_id } # Error handling # TODO or too hard? } }} { aa_log "Running testcase body $body_count" set ::__aa_test_indent [info level] set catch_val [catch $testcase_body msg] if {$catch_val != 0 && $catch_val != 2} { aa_log_result "fail" "auth_authenticate (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo" } incr body_count }XQL Not present: Generic, PostgreSQL, Oracle