_acs-authentication__auth_create_user (private)

 _acs-authentication__auth_create_user

Defined in packages/acs-authentication/tcl/test/acs-authentication-procs.tcl

Partial Call Graph (max 5 caller/called nodes):
aa_equals aa_equals (public) aa_false aa_false (public) aa_log aa_log (public) aa_log_result aa_log_result (public) aa_run_with_teardown aa_run_with_teardown (public) _acs-authentication__auth_create_user _acs-authentication__auth_create_user _acs-authentication__auth_create_user->aa_equals _acs-authentication__auth_create_user->aa_false _acs-authentication__auth_create_user->aa_log _acs-authentication__auth_create_user->aa_log_result _acs-authentication__auth_create_user->aa_run_with_teardown

Testcases:
No testcase defined.
Source code:
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{

    # create_user returns ok when trying to create a user
    # whose email already lives in the db. We should test
    # against that

    aa_run_with_teardown  -rollback  -test_code {

            # Successful creation
            set user_info [acs::test::user::create]
            set user [acs_user::get -user_id [dict get $user_info user_id]]
            set username     [dict get $user username]
            set email        [dict get $user email]
            set authority_id [dict get $user authority_id]

            aa_true "returns creation_status" [dict exists $user_info creation_status]

            if { [dict exists $user_info creation_status] } {
                aa_equals "creation_status for successful creation" [dict get $user_info creation_status] "ok"

                if { [dict get $user_info creation_status] ne "ok" } {
                    aa_log "Element messages:  '[dict get $user_info element_messages]'"
                    aa_log "Creation messages: '[dict get $user_info creation_message]'"
                }
            }

            aa_false "No creation_message for successful creation"  {[dict exists $user_info creation_message] && [dict get $user_info creation_message] ne ""}

            aa_true "returns integer user_id ($user_info)" [regexp {[1-9][0-9]*} [dict get $user_info user_id]]

            # Duplicate email and username
            set user_info [auth::create_user  -username $username  -email $email  -authority_id $authority_id  -first_names "Test3"  -last_name "User"  -password "changeme"  -secret_question "no_question"  -secret_answer "no_answer"]

            aa_equals "creation_status for duplicate email and username" [dict get $user_info creation_status] "data_error"

            aa_true "element_messages exists" [dict exists $user_info element_messages]
            if { [dict exists $user_info element_messages] && [dict get $user_info element_messages] ne "" } {
                set elm_msgs [dict get $user_info element_messages]
                aa_true "element_message for username exists"  {[dict exists $elm_msgs username] && [dict exists $elm_msgs username] ne ""}
                aa_true "element_message for email exists"  {[dict exists $elm_msgs email] && [dict exists $elm_msgs email] ne ""}
            }
            set user_id [acs_user::get_by_username -authority_id $authority_id -username $username]
            if { $user_id ne "" } {
                acs_user::delete -user_id $user_id
            }

            # Missing first_names, last_name, email
            set user_info [auth::create_user  -authority_id $authority_id  -username "auth_create_user2"  -email ""  -first_names ""  -last_name ""  -password "changeme"  -secret_question "no_question"  -secret_answer "no_answer"]

            aa_equals "creation_status is data_error" [dict get $user_info creation_status] "data_error"

            aa_true "element_messages exists" [dict exists $user_info element_messages]
            if { [dict exists $user_info element_messages] && [dict get $user_info element_messages] ne "" } {
                set elm_msgs [dict get $user_info element_messages]

                if { [aa_true "element_message(email) exists"  {[dict exists $elm_msgs email] && [dict get $elm_msgs email] ne ""} ]} {
                    aa_log "element_message(email) = [dict get $elm_msgs email]"
                }
                if { [aa_true "element_message(first_names) exists" [dict exists $elm_msgs first_names] ]} {
                    aa_log "element_message(first_names) = [dict get $elm_msgs first_names]"
                }
                if { [aa_true "element_message(last_name) exists" [dict exists $elm_msgs last_name] ]} {
                    aa_log "element_message(last_name) = [dict get $elm_msgs last_name]"
                }
            }
            set user_id [acs_user::get_by_username -authority_id $authority_id -username auth_create_user2]
            if { $user_id ne "" } {
                acs_user::delete -user_id $user_id
            }

            # Malformed email
            set user_info [auth::create_user  -authority_id $authority_id  -username [ad_generate_random_string]  -email "not an email"  -first_names "[ad_generate_random_string]<[ad_generate_random_string]"  -last_name "[ad_generate_random_string]<[ad_generate_random_string]"  -password [ad_generate_random_string]  -secret_question [ad_generate_random_string]  -secret_answer [ad_generate_random_string]]

            aa_equals "creation_status is data_error" [dict get $user_info creation_status] "data_error"

            aa_true "element_messages exists" [dict exists $user_info element_messages]
            if { [dict exists $user_info element_messages] && [dict get $user_info element_messages] ne "" } {
                set elm_msgs [dict get $user_info element_messages]

                if { [aa_true "element_message(email) exists" [dict exists $elm_msgs email]] } {
                    aa_log "element_message(email) = [dict get $elm_msgs email]"
                }
                if { [aa_true "element_message(first_names) exists" [dict exists $elm_msgs first_names]] } {
                    aa_log "element_message(first_names) = [dict get $elm_msgs first_names]"
                }
                if { [aa_true "element_message(last_name) exists" [dict exists $elm_msgs last_name]] } {
                    aa_log "element_message(last_name) = [dict get $elm_msgs last_name]"
                }
            }

        }
}} {
          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_create_user (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo"
          }
          incr body_count
        }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: