_acs-tcl__postman_echo (private)

 _acs-tcl__postman_echo

Defined in packages/acs-tcl/tcl/test/http-client-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) dom dom _acs-tcl__postman_echo _acs-tcl__postman_echo _acs-tcl__postman_echo->aa_equals _acs-tcl__postman_echo->aa_log _acs-tcl__postman_echo->aa_log_result _acs-tcl__postman_echo->aa_section _acs-tcl__postman_echo->dom

Testcases:
No testcase defined.
Source code:
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{
        set url "https://postman-echo.com"

        set test_key "string"
        set test_string "Umlaut ÜÄ"
        set json_data "{\"$test_key\": \"$test_string\"}"

        set get_url [export_vars -base $url/get [list [list $test_key $test_string]]]

        set content_types {
            "application/json;charset=UTF-8"
            "application/json"
        }
        set implementations {
            native curl ns_http
        }

        foreach impl $implementations {
            foreach content_type $content_types {
                set headers [ns_set create headers]
                ns_set update $headers "Content-Type" $content_type

                aa_section " - POST request - ContentType: '$content_type' - Implementation: '$impl'"
                if {$impl ne "ns_http"} {
                    set r [util::http::post -preference $impl -url $url/post -body $json_data -headers $headers]
                    set json_response [dict get $r page]
                } else {
                    set r [ns_http run -method POST -body $json_data -headers $headers $url/post]
                    set json_response [dict get $r body]
                }

                set status [dict get $r status]
                aa_equals "Server '$url' answers correctly with - status='$status'" $status 200

                aa_log "Server responded with: $json_response"

                set root [dom parse -json $json_response]
                set resp_key ""
                set resp_value ""
                foreach node [$root childNodes] {
                    if {[$node nodeName] eq "data"} {
                        set child [$node firstChild]
                        set resp_key    [$child nodeName]
                        set resp_string [$child text]
                    }
                }

                aa_equals "Format seems correct" $resp_key $test_key
                aa_equals "Value is correct" $resp_string $test_string


                aa_section " - GET request - ContentType: '$content_type' - Implementation: '$impl'"
                if {$impl ne "ns_http"} {
                    set r [util::http::get -preference $impl -url $get_url -headers $headers]
                    set json_response [dict get $r page]
                } else {
                    set r [ns_http run -method GET -headers $headers $get_url]
                    set json_response [dict get $r body]
                }

                set status [dict get $r status]
                aa_equals "Server '$url' answers correctly with - status='$status'" $status 200

                aa_log "Server responded with: $json_response"

                set root [dom parse -json $json_response]
                set resp_key ""
                set resp_value ""
                foreach node [$root childNodes] {
                    if {[$node nodeName] eq "args"} {
                        set child [$node firstChild]
                        set resp_key    [$child nodeName]
                        set resp_string [$child text]
                    }
                }

                aa_equals "Format seems correct" $resp_key $test_key
                aa_equals "Value is correct" $resp_string $test_string
            }
        }
    }} {
          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" "postman_echo (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: