_acs-tcl__login_logout_urls (private)

 _acs-tcl__login_logout_urls

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

Partial Call Graph (max 5 caller/called nodes):
%3 aa_false aa_false (public) aa_log aa_log (public) aa_log_result aa_log_result (public) aa_section aa_section (public) aa_true aa_true (public) _acs-tcl__login_logout_urls _acs-tcl__login_logout_urls _acs-tcl__login_logout_urls->aa_false _acs-tcl__login_logout_urls->aa_log _acs-tcl__login_logout_urls->aa_log_result _acs-tcl__login_logout_urls->aa_section _acs-tcl__login_logout_urls->aa_true

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


        aa_section {Login URL}

        db_foreach get_user_info {
            select username, authority_id
            from users
            fetch first 10 rows only
        } {
            set login_url [ad_get_login_url -authority_id $authority_id -username $username]
            aa_true "Login URL '$login_url' is a local URL" [util_url_valid_p -relative $login_url]
            aa_false "Login URL '$login_url' is not external" [util::external_url_p $login_url]

            set login_url [ad_get_login_url -authority_id $authority_id -username $username -return]
            aa_true "Login URL '$login_url' is a local URL" [util_url_valid_p -relative $login_url]
            aa_false "Login URL '$login_url' is not external" [util::external_url_p $login_url]
            aa_true "Login URL '$login_url' contains the return URL" {
                [string first [ns_urlencode $return_url$login_url] >= 0
            }
        }


        aa_section {Logout URL}

        set logout_url [ad_get_logout_url]
        aa_true "Logout URL '$logout_url' is a local URL" [util_url_valid_p -relative $logout_url]
        aa_false "Logout URL '$logout_url' is not external" [util::external_url_p $logout_url]

        set logout_url [ad_get_logout_url -return]
        aa_true "Logout URL '$logout_url' is a local URL" [util_url_valid_p -relative $logout_url]
        aa_false "Logout URL '$logout_url' is not external" [util::external_url_p $logout_url]
        aa_true "Logout URL '$logout_url' contains the return URL" {
            [string first [ns_urlencode $return_url$logout_url] >= 0
        }

        set logout_url [ad_get_logout_url -return -return_url __test__return__url]
        aa_true "Logout URL '$logout_url' is a local URL" [util_url_valid_p -relative $logout_url]
        aa_false "Logout URL '$logout_url' is not external" [util::external_url_p $logout_url]
        aa_true "Logout URL '$logout_url' contains the return URL" {
            [string first [ns_urlencode __test__return__url] $logout_url] >= 0
        }

        try {

            set test_url acs-tcl-test-security-procs-login-logout-url
            ns_register_proc GET $test_url {
                if {[ad_conn user_id] == 0} {
                    ns_return 403 text/plain Forbidden
                } else {
                    ns_return 200 text/plain OK
                }
            }

            set user_info [::acs::test::user::create]
            set user_id [dict get $user_info user_id]
            set d [::acs::test::login $user_info]

            aa_log "Requesting test endpoint as logged-in user"
            set d [acs::test::http -last_request $d /$test_url]
            acs::test::reply_has_status_code $d 200

            aa_log "Call the logout URL"
            set d [acs::test::http -last_request $d $logout_url]

            aa_log "Requesting test endpoint as logged out"
            set d [acs::test::http -last_request $d /$test_url]
            acs::test::reply_has_status_code $d 403

        } finally {
            ns_unregister_op GET $test_url
            acs::test::user::delete -user_id $user_id
        }

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