From ffbd499e0fffe0199e7cd1029f0ab6e37094f0d6 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Wed, 26 Jan 2022 22:06:42 -0600 Subject: [PATCH] Add tests for oversize directive and signature files --- testsuite/lib/upload.exp | 24 ++++++++++ testsuite/upload.all/00_idle.exp | 80 ++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) diff --git a/testsuite/lib/upload.exp b/testsuite/lib/upload.exp index 8eb582e..8bc4907 100644 --- a/testsuite/lib/upload.exp +++ b/testsuite/lib/upload.exp @@ -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]+} { diff --git a/testsuite/upload.all/00_idle.exp b/testsuite/upload.all/00_idle.exp index 9085b1c..9730c52 100644 --- a/testsuite/upload.all/00_idle.exp +++ b/testsuite/upload.all/00_idle.exp @@ -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 -- 2.25.1