_file-storage__fs_upload_a_notmpfile (private)

 _file-storage__fs_upload_a_notmpfile

Defined in packages/file-storage/tcl/test/file-storage-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_silence_log_entries aa_silence_log_entries (public) _file-storage__fs_upload_a_notmpfile _file-storage__fs_upload_a_notmpfile _file-storage__fs_upload_a_notmpfile->aa_false _file-storage__fs_upload_a_notmpfile->aa_log _file-storage__fs_upload_a_notmpfile->aa_log_result _file-storage__fs_upload_a_notmpfile->aa_section _file-storage__fs_upload_a_notmpfile->aa_silence_log_entries

Testcases:
No testcase defined.
Source code:
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{
    try {
        #
        # Setup of test user_id and login
        #
        set user_info [::acs::test::user::create -admin]
        aa_log "user_info = $user_info"
        set request_info [::acs::test::login $user_info]

        set d [file_storage::test::call_fs_page -last_request $request_info]
        aa_log "call_fs_page done"

        set d [acs::test::follow_link -last_request $d -label {Add File}]
        #acs::test::reply_has_status_code $d 200
        #
        # "Add File" links to a redirect page file-upload-confirm...
        #
        acs::test::reply_has_status_code $d 302
        set location [::acs::test::get_url_from_location $d]
        set d [acs::test::http -last_request $d $location]

        set response [dict get $d body]
        set form [acs::test::get_form $response {//form[@id='file-add']}]

        aa_true "add form was returned" {[llength $form] > 2}

        set file_name "I am not a tmpfile"
        set wfd [ad_opentmpfile notmpfile]
        puts $wfd "I am not a real tmpfile!"
        close $wfd
        set notmpfile_checksum [ns_md file $notmpfile]

        #
        # Try to create the file via the UI
        #
        aa_silence_log_entries -severities error {
            #
            # The uploaded file is rejected, due to the invalid tmp
            # file.
            #
            set d [::acs::test::form_reply  -last_request $d  -form $form  -update [list  upload_file [list $file_name $notmpfile "text/plain"]  title $file_name  description $file_name  ]]
        }
        ns_log notice $d
        #
        # When upload succeeds, a redirect is returned. Here we want
        # to make sure our upload was rejected, but without a server
        # error.
        #
        set status [dict get $d status]
        if {$status != 304 && $status < 500} {
            set expected_status $status
        } else {
            set expected_status 200
        }
        acs::test::reply_has_status_code $d $expected_status

        aa_true "Our notmpfile '$notmpfile' still exists"  [file exists $notmpfile]

        #
        # Now make sure that the file did not end up in the content
        # repository. We exploit the fact that the user is fresh and
        # does not own many objects.
        #
        set notmpfile_was_found_p false
        set user_id [dict get $user_info user_id]
        foreach revision_id [db_list get_revisions {
            select revision_id from cr_revisions r, acs_objects o
            where o.object_id = r.revision_id
              and o.creation_user = :user_id
        }] {
            set path [content::revision::get_cr_file_path -revision_id $revision_id]
            set path_checksum [ns_md file $path]
            aa_log "Checking revision '$revision_id', checksum '$path_checksum'"
            if {$path_checksum eq $notmpfile_checksum} {
                set notmpfile_was_found_p true
            }
        }

        aa_false "Our notmpfile file was not found in the content repository of the user"  $notmpfile_was_found_p

    } finally {
        #
        # Get rid of the user
        #
        set user_id [dict get $user_info user_id]
        aa_section "Delete test user (user_id $user_id)"
        acs::test::user::delete -user_id $user_id -delete_created_acs_objects
    }

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