acs::test::form_reply (public)

 acs::test::form_reply [ -user_id user_id ] \
    [ -last_request last_request ] [ -form form ] [ -url url ] \
    [ -update update ] [ -remove remove ] [ form_content ]

Defined in packages/acs-automated-testing/tcl/aa-test-procs.tcl

Send a (POST) request to the specified URL based on the provided form_content which has the form of a dict. For convenience the update fields are provided to overload the form_content.

Switches:
-user_id (optional, defaults to "0")
-last_request (optional)
pass optionally the past request, from which cookie and login-info can be taken
-form (optional)
-url (optional)
-update (optional)
key/attribute list of values to be updated in the form content
-remove (optional)
keys to be removed from the form content
Parameters:
form_content (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_folder_with_page create_folder_with_page (test xowf) acs::test::form_reply acs::test::form_reply test_create_folder_with_page->acs::test::form_reply test_create_form_with_form_instance create_form_with_form_instance (test xowiki) test_create_form_with_form_instance->acs::test::form_reply test_fs_add_file_to_folder fs_add_file_to_folder (test file-storage) test_fs_add_file_to_folder->acs::test::form_reply aa_log aa_log (public) acs::test::form_reply->aa_log acs::test::form_get_fields acs::test::form_get_fields (public) acs::test::form_reply->acs::test::form_get_fields acs::test::http acs::test::http (public) acs::test::form_reply->acs::test::http util::http::post_payload util::http::post_payload (public) acs::test::form_reply->util::http::post_payload acs::test::login acs::test::login (public) acs::test::login->acs::test::form_reply file_storage::test::create_new_folder file_storage::test::create_new_folder (private) file_storage::test::create_new_folder->acs::test::form_reply file_storage::test::delete_current_folder file_storage::test::delete_current_folder (private) file_storage::test::delete_current_folder->acs::test::form_reply file_storage::test::delete_first_file file_storage::test::delete_first_file (private) file_storage::test::delete_first_file->acs::test::form_reply file_storage::test::edit_folder file_storage::test::edit_folder (private) file_storage::test::edit_folder->acs::test::form_reply

Testcases:
fs_add_file_to_folder, create_folder_with_page, create_form_with_form_instance
Source code:
        if {$form_content eq ""} {
            set form_content [form_get_fields $form]
            aa_log "FORM-CONTENT from FORM '$form_content'"
        }
        if {$form_content eq ""} {
            error "either nonempty form or form_content has to be provided"
        }
        if {$url eq ""} {
            set url [dict get $form @action]
        }
        if {$url eq ""} {
            error "either form with action fields or URL has to be provided"
        }

        if {$remove ne ""} {
            set form_content [dict remove $form_content {*}$remove]
            ns_log notice "DEBUG: after removing <$remove> from <$form_content>"
        }

        #
        # Update the values coming from the form with our values.
        #
        foreach {att value} $update {
            if {[regexp {^(.*)\.(tmpfile|content-type)$} $att _ fieldname type]} {
                #
                # This parameter is the attribute of a file.
                #
                lappend files($fieldname$type $value
            } else {
                #
                # This is a normal parameter
                #
                dict set form_content $att $value
            }
        }

        #
        # Cleanup all form parameters that will be sent as files
        #
        set form_content [dict remove $form_content {*}[array names files]]

        #
        # Now take all of the parameters that are files and build up
        # the list to pass to the payload creation.
        #
        set fs {}
        foreach {fieldname attrs} [array get files] {
            if {![dict exists $attrs tmpfile]} {
                error "'$fieldname' looks like a file upload, but no .tmpfile was specified"
            }
            set f [list  fieldname $fieldname  file [dict get $attrs tmpfile]]
            if {[dict exists $attrs content_type]} {
                lappend f mime_type [dict get $attrs content_type]
            }
            lappend fs $f
        }

        set payload [util::http::post_payload  -files $fs  -formvars_list $form_content]
        #
        # Send the POST request
        #
        return [http  -user_id $user_id  -last_request $last_request  -method POST  -body [dict get $payload payload]  -headers [ns_set array [dict get $payload headers]]  $url]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: