_acs-tcl__test_set_cookie_procs (private)
_acs-tcl__test_set_cookie_procs
Defined in packages/acs-tcl/tcl/test/test-set-cookie-procs.tcl
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set _aa_export {} set body_count 1 foreach testcase_body {{ aa_run_with_teardown -rollback -test_code { aa_section "Set and get cookie" # # Set the cookie # set data [ad_generate_random_string] ad_set_cookie testcookie "$data" # # Get the cookie # set cookie_info_p [ad_get_cookie -include_set_cookies t testcookie "" ] aa_equals "Check if the new cookie exists (content: $data)" $cookie_info_p $data # # Set cookie with known secret # aa_section "Cookie with known secret" set secret_token hello ad_set_signed_cookie -secret $secret_token -max_age 100 -token_id 101 testcookie2 "as,df" set cookie_value [ns_urldecode [ad_get_cookie testcookie2]] set cookie_payload [lindex $cookie_value 0] set cookie_meta [lindex $cookie_value 1] lassign $cookie_meta token_id expire hash # # Check payload # aa_equals "Cookie payload" "as,df" $cookie_payload # # Check meta length # aa_equals "Cookie meta length" 3 [llength $cookie_meta] # # Check meta token_id # aa_equals "Cookie meta token_id" 101 $token_id # # Check hash # set computed_hash [ns_sha1 "$cookie_payload$token_id$expire$secret_token"] aa_equals "Cookie hash" $computed_hash $hash # # Set cookie with random secret # aa_section "Cookie with random secret" ad_set_signed_cookie -max_age 1 testcookie3 "lots,of,,commas" set cookie_payload [lindex [ad_get_signed_cookie testcookie3] 0] # # Check payload # aa_equals "Cookie payload" "lots,of,,commas" $cookie_payload # # Clear the cookies # aa_section "Clear cookies" foreach cookie {testcookie testcookie2 testcookie3} { ad_set_cookie -replace t -max_age 0 $cookie "" set cookie_info_d [ad_get_cookie -include_set_cookies t $cookie ""] aa_false "Check if the cookie ($cookie) was cleared" [string equal $cookie_info_d $data] } } }} { 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" "test_set_cookie_procs (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo" } incr body_count }XQL Not present: Generic, PostgreSQL, Oracle