From ecea5d8be4f2d9dffc54635e2e584769ccc2136f Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Thu, 27 Jan 2022 21:34:12 -0600 Subject: [PATCH] Add more tests for invalid directives in triplets --- testsuite/lib/upload.exp | 27 +++++- testsuite/upload.all/03_triplet.exp | 144 +++++++++++++++++++++++++++- 2 files changed, 169 insertions(+), 2 deletions(-) diff --git a/testsuite/lib/upload.exp b/testsuite/lib/upload.exp index 8bc4907..beddd8b 100644 --- a/testsuite/lib/upload.exp +++ b/testsuite/lib/upload.exp @@ -649,7 +649,13 @@ proc analyze_log { base_dir name assess } { } -re {^ftp-upload\[[0-9]+\]: \(Test\)\ invalid version [0-9.]+, not supported} { - # from read_directive_file, if bad version + # from read_directive_file, if unsupported version + set A(validate,bad-version) 1 + exp_continue + } + -re {^ftp-upload\[[0-9]+\]: \(Test\)\ + invalid version [^\r\n]+} { + # from read_directive_file, if unparsable version set A(validate,bad-version) 1 exp_continue } @@ -667,12 +673,31 @@ proc analyze_log { base_dir name assess } { set A(validate,no-version,$expect_out(1,string)) 1 exp_continue } + -re {^ftp-upload\[[0-9]+\]: \(Test\)\ + invalid filename [^\r\n]+} { + # from read_directive_file, if filename is bogus + set A(validate,bad-filename) 1 + exp_continue + } -re {^ftp-upload\[[0-9]+\]: \(Test\)\ Only one filename directive is allowed per [^\r\n]+} { # from read_directive_file, if filename repeated set A(validate,bad-filename-repeat) 1 exp_continue } + -re {^ftp-upload\[[0-9]+\]: \(Test\)\ + invalid parameters for ([^ ]+) command[^\r\n]+} { + # from read_directive_file, when most commands have + # unrecognized or invalid parameters + set A(validate,bad-parameter,$expect_out(1,string)) 1 + exp_continue + } + -re {^ftp-upload\[[0-9]+\]: \(Test\)\ + Invalid directive line:[^\r\n]+} { + # from read_directive_file, if a line is unrecognized + set A(validate,bad-directive-line) 1 + exp_continue + } -re {^ftp-upload\[[0-9]+\]: \(Test\)\ no filename directive specified in ([^\r\n]+)[.]\ Upgrade to the latest version![^\r\n]+} { diff --git a/testsuite/upload.all/03_triplet.exp b/testsuite/upload.all/03_triplet.exp index 32203fd..9ac4d7b 100644 --- a/testsuite/upload.all/03_triplet.exp +++ b/testsuite/upload.all/03_triplet.exp @@ -261,6 +261,41 @@ check_triplet "bogus: empty directive" setup { } } +check_triplet "bogus: directive with unknown key" setup { + packages { + foo { + email { "foo@example.org" } + keys { { id 1000 name "foo " } } + maintainers { "foo " } + } + } +} upload { + foo.bin { + directive { + version 1.2 + filename foo.bin + directory foo + bogus-key-name bogus! + } dsig { good 03 1000 } + file { test } fsig { good 04 1000 } + } +} check { + file-tree { + { incoming stage pub archive } empty {} + { in-stage } files { + foo.bin foo.bin.sig foo.bin.directive.asc + } + } log { + found,foo.bin.directive.asc "found directive in triplet" + found-triplet,foo.bin.directive.asc:foo.bin.sig:foo.bin \ + "found triplet" + validate,bad-directive-line "bogus directive line detected" + } email-to { + ftp-upload-script@gnu.org foo@example.gnu.org + foo@example.org foo@example.net + } +} + check_triplet "bogus: signed for unknown package" setup { packages { foo { @@ -437,6 +472,39 @@ check_triplet "bogus: signed with wrong key on file" setup { # ---------------------------------------- +check_triplet "bogus: version field not a number" setup { + packages { + foo { + email { "foo@example.org" } + keys { { id 1000 name "foo " } } + maintainers { "foo " } + } + } +} upload { + foo.bin { + directive { + version bogus + directory foo + filename foo.bin + } dsig { good 00 1000 } + file { test } fsig { good 01 1000 } + } +} check { + file-tree { + { incoming stage pub archive } empty {} + { in-stage } files { + foo.bin.directive.asc foo.bin.sig foo.bin + } + } log { + found,foo.bin.directive.asc "found directive in triplet" + found-triplet,foo.bin.directive.asc:foo.bin.sig:foo.bin \ + "found triplet" + validate,bad-version "invalid version rejected" + } email-to { + ftp-upload-script@gnu.org foo@example.gnu.org + } +} + # version 1.0 did not use the version field at all check_triplet "bogus: invalid v1.0 format directive" setup { packages { @@ -609,6 +677,40 @@ foreach FVER $DIRECTIVE_FORMAT_VERSIONS { } } + check_triplet "bogus: v$FVER format directive with bogus filename" setup { + packages { + foo { + email { "foo@example.org" } + keys { { id 1000 name "foo " } } + maintainers { "foo " } + } + } + } upload [subst { + foo.bin { + directive { + version $FVER + filename -bogus=filename + directory foo/v$FVER + } dsig { good 04 1000 } + file { test } fsig { good 05 1000 } + } + }] check { + file-tree { + { incoming stage pub archive } empty {} + { in-stage } files { + foo.bin.directive.asc foo.bin.sig foo.bin + } + } log { + found,foo.bin.directive.asc "found directive in triplet" + found-triplet,foo.bin.directive.asc:foo.bin.sig:foo.bin \ + "found triplet" + validate,bad-filename \ + "directive file with bogus filename rejected" + } email-to { + ftp-upload-script@gnu.org foo@example.gnu.org + } + } + check_triplet "bogus: v$FVER format directive with repeated filename" setup { packages { foo { @@ -1014,7 +1116,6 @@ foreach FVER $DIRECTIVE_FORMAT_VERSIONS { } }] - check_triplet "v$FVER format directive with subtree key at top" setup { packages { foo { @@ -1259,6 +1360,47 @@ check_triplet "v1.2 format directive to replace file" setup { } } +check_triplet "bogus: v1.2 format directive with bogus replace value" setup { + packages { + foo { + email { "foo@example.org" } + keys { { id 1000 name "foo " } } + maintainers { "foo " } + } + } + files { + pub { foo/foo.bin { good 01 1000 } } + } +} upload { + foo.bin { + directive { + version 1.2 + replace bogus! + filename foo.bin + directory foo + } dsig { good 0E 1000 } + file { test } fsig { good 0F 1000 } + } +} check { + file-tree { + { incoming stage archive } empty {} + { in-stage } files { + foo.bin.directive.asc foo.bin.sig foo.bin + } + { pub } files { + foo/foo.bin foo/foo.bin.sig + } + } log { + found,foo.bin.directive.asc "found directive in triplet" + found-triplet,foo.bin.directive.asc:foo.bin.sig:foo.bin \ + "found triplet" + validate,bad-parameter,replace \ + "invalid replace flag value rejected" + } email-to { + ftp-upload-script@gnu.org foo@example.gnu.org + } +} + # ---------------------------------------- #EOF -- 2.25.1