_acs-authentication__auth_registration_implementations (private)

 _acs-authentication__auth_registration_implementations

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

Partial Call Graph (max 5 caller/called nodes):
%3 aa_equals aa_equals (public) aa_log aa_log (public) aa_log_result aa_log_result (public) aa_section aa_section (public) aa_stub aa_stub (public) _acs-authentication__auth_registration_implementations _acs-authentication__auth_registration_implementations _acs-authentication__auth_registration_implementations->aa_equals _acs-authentication__auth_registration_implementations->aa_log _acs-authentication__auth_registration_implementations->aa_log_result _acs-authentication__auth_registration_implementations->aa_section _acs-authentication__auth_registration_implementations->aa_stub

Testcases:
No testcase defined.
Source code:
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{
        aa_section auth::local::registration::GetElements

        set kernel_id [ad_acs_kernel_id]
        set subsite_id [subsite::main_site_id]

        set UseEmailForLoginP [parameter::get -boolean -parameter UseEmailForLoginP -package_id $kernel_id -default 1]
        set RegistrationProvidesRandomPasswordP [parameter::get -package_id $subsite_id -parameter RegistrationProvidesRandomPasswordP -default 0]
        set RequireQuestionForPasswordResetP [parameter::get -package_id $kernel_id -parameter RequireQuestionForPasswordResetP -default 0]
        set UseCustomQuestionForPasswordReset [parameter::get -package_id $kernel_id -parameter UseCustomQuestionForPasswordReset -default 0]

        try {
            foreach {use_email_p random_password_p require_question_p use_question_p expected_elements} {
                true true true true {required {email first_names last_name secret_question secret_answer} optional {url}}

                false false true true {required {username email first_names last_name secret_question secret_answer} optional {url password}}

                false false false true {required {username email first_names last_name} optional {url password}}

                false false true false {required {username email first_names last_name} optional {url password}}
            } {
                aa_log "UseEmailForLoginP = $use_email_p"
                parameter::set_value -parameter UseEmailForLoginP -package_id $kernel_id -value $use_email_p
                aa_log "RegistrationProvidesRandomPasswordP = $random_password_p"
                parameter::set_value -package_id $subsite_id -parameter RegistrationProvidesRandomPasswordP -value $random_password_p
                aa_log "RequireQuestionForPasswordResetP = $require_question_p"
                parameter::set_value -package_id $kernel_id -parameter RequireQuestionForPasswordResetP -value $require_question_p
                aa_log "UseCustomQuestionForPasswordReset = $use_question_p"
                parameter::set_value -package_id $kernel_id -parameter UseCustomQuestionForPasswordReset -value $use_question_p

                set elements [acs_sc::invoke  -contract auth_registration  -operation GetElements  -impl local  -call_args [list [list]]]
                aa_equals "GetElements returns correct required fields"  [lsort [dict get $elements required]] [lsort [dict get $expected_elements required]]
                aa_equals "GetElements returns correct optional fields"  [lsort [dict get $elements optional]] [lsort [dict get $expected_elements optional]]

                set elements [acs_sc::invoke  -contract auth_registration  -operation GetElements  -impl acs_testing  -call_args [list [list]]]
                aa_equals "GetElements returns correct required fields"  [lsort [dict get $elements required]] [lsort [dict get $expected_elements required]]
                aa_equals "GetElements returns correct optional fields"  [lsort [dict get $elements optional]] [lsort [dict get $expected_elements optional]]

            }
        } finally {
            aa_log "Resetting parameters"
            parameter::set_value -parameter UseEmailForLoginP -package_id $kernel_id -value $UseEmailForLoginP
            parameter::set_value -package_id $subsite_id -parameter RegistrationProvidesRandomPasswordP -value $RegistrationProvidesRandomPasswordP
            parameter::set_value -package_id $kernel_id -parameter RequireQuestionForPasswordResetP -value $RequireQuestionForPasswordResetP
            parameter::set_value -package_id $kernel_id -parameter UseCustomQuestionForPasswordReset -value $UseCustomQuestionForPasswordReset
        }

        aa_section auth::local::registration::GetParameters

        aa_stub acs_mail_lite::send {
            lappend ::auth_registration_implementations_from_addr $from_addr
            lappend ::auth_registration_implementations_to_addr $to_addr
        }

        aa_equals "GetParameters returns nothing"  [acs_sc::invoke  -contract auth_registration  -operation GetParameters  -impl local]  ""
        aa_equals "GetParameters returns nothing"  [acs_sc::invoke  -contract auth_registration  -operation GetParameters  -impl acs_testing]  ""

        aa_section auth::local::registration::Register

        set EmailRegistrationConfirmationToUserP [parameter::get -parameter EmailRegistrationConfirmationToUserP -package_id $subsite_id -default 1]
        set NotifyAdminOfNewRegistrationsP [parameter::get -parameter NotifyAdminOfNewRegistrationsP -package_id $subsite_id -default 0]

        set mail_package_id [apm_package_id_from_key acs-mail-lite]
        set fixed_sender [parameter::get -parameter "FixedSenderEmail" -package_id $mail_package_id]
        if { $fixed_sender ne ""} {
            set NewRegistrationEmailAddress $fixed_sender
        } else {
            set NewRegistrationEmailAddress [parameter::get -parameter NewRegistrationEmailAddress -package_id $subsite_id -default [ad_system_owner]]
        }

        set AdminNotificationEmailAddress [parameter::get -parameter NewRegistrationEmailAddress -package_id $subsite_id -default [ad_system_owner]]

        set user [acs::test::user::create]
        set user_id [dict get $user user_id]
        set user [acs_user::get -user_id $user_id]
        set parameters ""
        set username [dict get $user username]
        set authority_id [dict get $user authority_id]
        set first_names [dict get $user first_names]
        set last_name [dict get $user last_name]
        set screen_name [dict get $user screen_name]
        set email [dict get $user email]
        set url ""
        set secret_question "What are you testing here?"
        set secret_answer "...the service contracts..."

        try {
            aa_log "Password is nonempty"
            aa_log "EmailRegistrationConfirmationToUserP = 0"
            aa_log "RegistrationProvidesRandomPasswordP = 0"
            aa_log "NotifyAdminOfNewRegistrationsP = 0"

            set password [dict get $user password]
            parameter::set_value -package_id $subsite_id -parameter EmailRegistrationConfirmationToUserP -value 0
            parameter::set_value -package_id $subsite_id -parameter RegistrationProvidesRandomPasswordP -value 0
            parameter::set_value -package_id $subsite_id -parameter NotifyAdminOfNewRegistrationsP -value 0

            set ::auth_registration_implementations_from_addr [list]
            set ::auth_registration_implementations_to_addr [list]
            acs_sc::invoke  -contract auth_registration  -operation Register  -impl local  -call_args [list  $parameters  $username  $authority_id  $first_names  $last_name  $screen_name  $email  $url  $password  $secret_question  $secret_answer]

            aa_true "Password was not changed" [ad_check_password $user_id $password]
            aa_equals "No emails were sent" $::auth_registration_implementations_to_addr ""

            aa_log "Password is empty"
            aa_log "EmailRegistrationConfirmationToUserP = 0"
            aa_log "RegistrationProvidesRandomPasswordP = 0"
            aa_log "NotifyAdminOfNewRegistrationsP = 0"

            set old_password $password
            set password ""
            parameter::set_value -package_id $subsite_id -parameter EmailRegistrationConfirmationToUserP -value 0
            parameter::set_value -package_id $subsite_id -parameter RegistrationProvidesRandomPasswordP -value 0
            parameter::set_value -package_id $subsite_id -parameter NotifyAdminOfNewRegistrationsP -value 0

            set ::auth_registration_implementations_from_addr [list]
            set ::auth_registration_implementations_to_addr [list]
            set result [acs_sc::invoke  -contract auth_registration  -operation Register  -impl local  -call_args [list  $parameters  $username  $authority_id  $first_names  $last_name  $screen_name  $email  $url  $password  $secret_question  $secret_answer]]

            set new_password [dict get $result password]
            aa_true "Password was generated" [dict get $result generated_pwd_p]
            aa_true "Password was changed" {$old_password ne $new_password}
            aa_true "Password works" [ad_check_password $user_id $new_password]
            aa_equals "No emails were sent" $::auth_registration_implementations_to_addr ""

            aa_log "Password is nonempty"
            aa_log "EmailRegistrationConfirmationToUserP = 1"
            aa_log "RegistrationProvidesRandomPasswordP = 0"
            aa_log "NotifyAdminOfNewRegistrationsP = 0"

            set password $new_password
            parameter::set_value -package_id $subsite_id -parameter EmailRegistrationConfirmationToUserP -value 1
            parameter::set_value -package_id $subsite_id -parameter RegistrationProvidesRandomPasswordP -value 0
            parameter::set_value -package_id $subsite_id -parameter NotifyAdminOfNewRegistrationsP -value 0

            set ::auth_registration_implementations_from_addr [list]
            set ::auth_registration_implementations_to_addr [list]
            acs_sc::invoke  -contract auth_registration  -operation Register  -impl local  -call_args [list  $parameters  $username  $authority_id  $first_names  $last_name  $screen_name  $email  $url  $password  $secret_question  $secret_answer]

            aa_true "Password was not changed" [ad_check_password $user_id $password]
            aa_equals "One confirmation email was sent by the configured addressed"  $::auth_registration_implementations_from_addr [list $NewRegistrationEmailAddress]
            aa_equals "One confirmation email was sent to the user"  $::auth_registration_implementations_to_addr [list $email]

            aa_log "Password is nonempty"
            aa_log "EmailRegistrationConfirmationToUserP = 1"
            aa_log "RegistrationProvidesRandomPasswordP = 1"
            aa_log "NotifyAdminOfNewRegistrationsP = 1"

            parameter::set_value -package_id $subsite_id -parameter EmailRegistrationConfirmationToUserP -value 1
            parameter::set_value -package_id $subsite_id -parameter RegistrationProvidesRandomPasswordP -value 1
            parameter::set_value -package_id $subsite_id -parameter NotifyAdminOfNewRegistrationsP -value 1

            set ::auth_registration_implementations_from_addr [list]
            set ::auth_registration_implementations_to_addr [list]
            set result [acs_sc::invoke  -contract auth_registration  -operation Register  -impl local  -call_args [list  $parameters  $username  $authority_id  $first_names  $last_name  $screen_name  $email  $url  $password  $secret_question  $secret_answer]]

            set new_password [dict get $result password]
            aa_true "Password was generated" [dict get $result generated_pwd_p]
            aa_true "Password was changed" {$password ne $new_password}
            aa_true "Password works" [ad_check_password $user_id $new_password]

            aa_equals "Two emails were sent"  [llength $::auth_registration_implementations_from_addr] 2
            aa_true "One confirmation email was sent by the configured addressed"  {$NewRegistrationEmailAddress in $::auth_registration_implementations_from_addr}
            aa_true "One confirmation email was sent to the user"  {$email in $::auth_registration_implementations_to_addr}
            aa_true "One notification email was sent by the configured outgoing sender"  {[ad_outgoing_sender] in $::auth_registration_implementations_from_addr}
            aa_true "One notification email was sent to the system administrator"  {$AdminNotificationEmailAddress in $::auth_registration_implementations_to_addr}

        } finally {
            parameter::set_value -package_id $subsite_id -parameter EmailRegistrationConfirmationToUserP -value $EmailRegistrationConfirmationToUserP
            parameter::set_value -package_id $subsite_id -parameter RegistrationProvidesRandomPasswordP -value $RegistrationProvidesRandomPasswordP
            parameter::set_value -package_id $subsite_id -parameter NotifyAdminOfNewRegistrationsP -value $NotifyAdminOfNewRegistrationsP
        }


        aa_section acs::test::auth::registration::Register

        aa_log "Password is nonempty"

        set password $new_password

        set ::auth_registration_implementations_from_addr [list]
        set ::auth_registration_implementations_to_addr [list]
        acs_sc::invoke  -contract auth_registration  -operation Register  -impl acs_testing  -call_args [list  $parameters  $username  $authority_id  $first_names  $last_name  $screen_name  $email  $url  $password  $secret_question  $secret_answer]

        aa_true "Password was not changed" [ad_check_password $user_id $password]
        aa_equals "No emails were sent" $::auth_registration_implementations_to_addr ""

    }} {
          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_registration_implementations (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: