Index: openacs-4/packages/acs-authentication/tcl/test/acs-authentication-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/test/acs-authentication-procs.tcl,v diff -u -N -r1.51 -r1.52 --- openacs-4/packages/acs-authentication/tcl/test/acs-authentication-procs.tcl 20 Jul 2018 13:01:06 -0000 1.51 +++ openacs-4/packages/acs-authentication/tcl/test/acs-authentication-procs.tcl 20 Jul 2018 13:38:41 -0000 1.52 @@ -6,6 +6,35 @@ @cvs-id $Id$ } +##### +# +# Helper procs +# +#### + +namespace eval auth::test {} + +ad_proc -private auth::test::get_admin_user_id {} { + Return the user id of a site-wide-admin on the system +} { + set context_root_id [acs_lookup_magic_object security_context_root] + + return [db_string select_user_id {}] +} + +ad_proc -private auth::test::get_password_vars { + {-array_name:required} +} { + Get test vars for test case. +} { + upvar $array_name test_vars + + db_1row select_vars {} -column_array test_vars +} + +#### + + aa_register_case \ -cats {api} \ -procs { @@ -14,6 +43,9 @@ acs_user::get_by_username auth::authenticate auth::create_user + acs_user::get_portrait_id + acs_user::erase_portrait + acs_user::create_portrait } \ auth_authenticate { Test the auth::authenticate proc. @@ -42,6 +74,26 @@ set user_id [acs_user::get_by_username -username $username] + ## 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 \ @@ -885,33 +937,6 @@ } } - -##### -# -# Helper procs -# -#### - -namespace eval auth::test {} - -ad_proc -private auth::test::get_admin_user_id {} { - Return the user id of a site-wide-admin on the system -} { - set context_root_id [acs_lookup_magic_object security_context_root] - - return [db_string select_user_id {}] -} - -ad_proc -private auth::test::get_password_vars { - {-array_name:required} -} { - Get test vars for test case. -} { - upvar $array_name test_vars - - db_1row select_vars {} -column_array test_vars -} - # Local variables: # mode: tcl # tcl-indent-level: 4