Add tests for oversize directive and signature files
authorJacob Bachmeyer <jcb@gnu.org>
Thu, 27 Jan 2022 04:06:42 +0000 (22:06 -0600)
committerJacob Bachmeyer <jcb@gnu.org>
Thu, 27 Jan 2022 04:06:42 +0000 (22:06 -0600)
testsuite/lib/upload.exp
testsuite/upload.all/00_idle.exp

index 8eb582e535f4d365cd127db2e85c52634ec44ede..8bc4907a50d629e078d2ff46738b899708aff7b2 100644 (file)
@@ -564,6 +564,30 @@ proc analyze_log { base_dir name assess } {
                     set A(skip-loose,$expect_out(1,string)) 1
                     exp_continue
                 }
+       -re {^ftp-upload\[[0-9]+\]: \(Test\)\
+                directive file \(([^ ]+)\) larger than[^\r\n]+} {
+                    # from scan_incoming, on finding an oversize directive
+                    set A(oversize-directive,$expect_out(1,string)) 1
+                    exp_continue
+                }
+       -re {^ftp-upload\[[0-9]+\]: \(Test\)\
+                The directive file [^ ]+ is larger than[^\r\n]+} {
+                    # from scan_incoming, on finding an oversize directive
+                    # already noted above; both messages are produced
+                    exp_continue
+                }
+       -re {^ftp-upload\[[0-9]+\]: \(Test\)\
+                signature file \(([^ ]+)\) larger than[^\r\n]+} {
+                    # from scan_incoming, on finding an oversize signature
+                    set A(oversize-signature,$expect_out(1,string)) 1
+                    exp_continue
+                }
+       -re {^ftp-upload\[[0-9]+\]: \(Test\)\
+                The signature file [^ ]+ is larger than[^\r\n]+} {
+                    # from scan_incoming, on finding an oversize signature
+                    # already noted above; both messages are produced
+                    exp_continue
+                }
 
        -re {^ftp-upload\[[0-9]+\]: \(Test\)\
                 DEBUG: found keyring [^\r\n]+} {
index 9085b1ccc0c9082ecc2f5c99a2471f2a48083223..9730c522e11723bf467c65de1de562007e8ce6d7 100644 (file)
@@ -349,4 +349,84 @@ check_recent_upload 0 0 1
 
 # ----------------------------------------
 
+proc check_oversize_part { oversize_directive oversize_signature } {
+    set tenv [new_test_environment [file join test.tmp tenv]]
+
+    set msglist {
+       start "ftp-upload start message"
+
+       scan,oversize.bin "scan found main file"
+       consider,oversize.bin "considered main file"
+       scan,oversize.bin.sig "scan found signature file"
+       scan,oversize.bin.directive.asc "scan found directive file"
+    }
+
+    set filelist { oversize.bin }
+
+    make_test_case $tenv {
+       oversize.bin {
+           directive {
+               version 1.2
+               filename oversize.bin
+               directory oversize
+           } dsig { good 00 0000 }
+           file { oversize auxiliary test } fsig { good 00 0000 }
+       }
+    }
+    if { $oversize_directive } {
+       set chan [open [file join $tenv incoming oversize.bin.directive.asc] a]
+       puts $chan [string repeat \
+                       "[string repeat { bogon } 11]\n" 1024]
+       close $chan
+       age_file [file join $tenv incoming oversize.bin.directive.asc] \
+           "3 minutes ago"
+       lappend msglist oversize-directive,oversize.bin.directive.asc \
+           "detected oversize directive file"
+       lappend filelist .oversize.bin.directive.asc
+    } else {
+       lappend filelist oversize.bin.directive.asc
+    }
+    if { $oversize_signature } {
+       set chan [open [file join $tenv incoming oversize.bin.sig] a]
+       puts $chan [string repeat \
+                       "[string repeat { bogon } 11]\n" 1024]
+       close $chan
+       age_file [file join $tenv incoming oversize.bin.sig] \
+           "3 minutes ago"
+       if { ! $oversize_directive } {
+           # a signature will not be checked if the directive is oversize
+           # TODO: fix this so both will be reported if appropriate
+           lappend msglist oversize-signature,oversize.bin.sig \
+               "detected oversize signature file"
+           lappend filelist .oversize.bin.sig
+       } else {
+           lappend filelist oversize.bin.sig
+       }
+    } else {
+       lappend filelist oversize.bin.sig
+    }
+
+    start_test_services $tenv
+    run_upload_batch_test
+    stop_test_services
+
+    set Name "idle processing: oversize directive/signature\
+               \[${oversize_directive}${oversize_signature}\]"
+
+    analyze_file_tree $tenv $Name {
+       incoming
+    } files $filelist
+    analyze_file_tree $tenv $Name {
+       in-stage stage pub archive
+    } empty
+    analyze_log $tenv $Name $msglist
+    analyze_mail $tenv $Name to { ftp-upload-script@gnu.org }
+
+    close_test_environment $tenv
+}
+
+check_oversize_part 1 1
+check_oversize_part 1 0
+check_oversize_part 0 1
+
 #EOF