Add more tests for invalid directives in triplets
authorJacob Bachmeyer <jcb@gnu.org>
Fri, 28 Jan 2022 03:34:12 +0000 (21:34 -0600)
committerJacob Bachmeyer <jcb@gnu.org>
Fri, 28 Jan 2022 03:34:12 +0000 (21:34 -0600)
testsuite/lib/upload.exp
testsuite/upload.all/03_triplet.exp

index 8bc4907a50d629e078d2ff46738b899708aff7b2..beddd8bc9dec18ed80afc911da000185e0ee087a 100644 (file)
@@ -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]+} {
index 32203fdb2a6a2226b4b4c31fdf12d7da1132747e..9ac4d7b591fa4b5a6ab351e432c6061aa293f328 100644 (file)
@@ -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 <foo@example.gnu.org>" } }
+           maintainers { "foo <foo@example.net>" }
+       }
+    }
+} 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 <foo@example.gnu.org>" } }
+           maintainers { "foo <foo@example.net>" }
+       }
+    }
+} 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 <foo@example.gnu.org>" } }
+               maintainers { "foo <foo@example.net>" }
+           }
+       }
+    } 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 <foo@example.gnu.org>" } }
+           maintainers { "foo <foo@example.net>" }
+       }
+    }
+    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