acs::test::user::create (public)
acs::test::user::create [ -admin ] [ -email email ] [ -locale locale ] \ [ -password password ] [ -user_id user_id ]
Defined in packages/acs-automated-testing/tcl/aa-test-procs.tcl
Create a test user with random email and password for testing. If an email is passed in and the party identified by the password exists, the user_id of this party is returned in the dict.
- Switches:
- -admin (optional, boolean)
- provide this switch to make the user site-wide admin
- -email (optional)
- email for the user to be created
- -locale (optional, defaults to
"en_US"
)- locale for the user to be created
- -password (optional)
- password for the user to be created
- -user_id (optional)
- user_id for the user to be created
- Returns:
- The user_info dict returned by auth::create_user. Contains the additional keys email and password.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- acs_admin_merge_MergeUserInfo, auth_authenticate, auth_create_user, auth_password_change, auth_password_reset, auth_email_on_password_change, webtest_example, acs_subsite_expose_bug_1144, acs_subsite_check_composite_group, acs_subsite_test_email_confirmation, community_cc_procs, demote_promote_a_user, ad_proc_change_state_member, ad_proc_permission_grant_and_revoke, ad_proc_permission_permission_p, calendar_basic_api, create_form_with_form_instance, create_form_with_numeric, form_validate, nested_self_references
Source code: # # Currently, we are not able to reuse the testing account # based on email, since a later login attempt for that account # fails, since we have no cookie yet, and the testing # authority does not allow logins via /login. # if {$email ne "" && 0} { set party_info [party::get -email $email] if {[llength $party_info] > 0} { # # We have such a party already. Return the usual # elements like on new creation. # set d [acs_user::get -user_id [dict get $party_info party_id]] dict set user_info user_id [dict get $party_info party_id] dict set user_info password [dict get $d password] dict set user_info email [dict get $d email] dict set user_info first_names [dict get $d first_names] dict set user_info last_name [dict get $d last_name] return $user_info } } if {$password eq ""} { set password [ad_generate_random_string] } set username "__test_user_[ad_generate_random_string]" set email "$username@test.test" set first_names [ad_generate_random_string] set last_name [ad_generate_random_string] set user_info [auth::create_user -user_id $user_id -username $username -email $email -first_names $first_names -last_name $last_name -password $password -secret_question [ad_generate_random_string] -secret_answer [ad_generate_random_string] -authority_id [auth::authority::get_id -short_name "acs_testing"]] if {![dict exists $user_info user_id]} { aa_error "invalid USER_INFO (does not contain user_id): $user_info" } lang::user::set_locale -user_id [dict get $user_info user_id] $locale if { [dict get $user_info creation_status] ne "ok" } { # Could not create user error "Could not create test user with username=$username user_info=[array get user_info]" } dict set user_info password $password dict set user_info email $email dict set user_info first_names $first_names dict set user_info last_name $last_name #aa_log "Created user with email='$email' and password='$password'" aa_log "Created user with email='$email'" if { $admin_p } { aa_log "Making user site-wide admin" permission::grant -object_id [acs_magic_object "security_context_root"] -party_id [dict get $user_info user_id] -privilege "admin" } return $user_infoXQL Not present: Generic, PostgreSQL, Oracle