Add tests for email address handling
authorJacob Bachmeyer <jcb@gnu.org>
Fri, 28 Oct 2022 22:44:44 +0000 (17:44 -0500)
committerJacob Bachmeyer <jcb@gnu.org>
Fri, 28 Oct 2022 22:44:44 +0000 (17:44 -0500)
testsuite/gatekeeper.all/11_email.exp [new file with mode: 0644]

diff --git a/testsuite/gatekeeper.all/11_email.exp b/testsuite/gatekeeper.all/11_email.exp
new file mode 100644 (file)
index 0000000..e24e2b4
--- /dev/null
@@ -0,0 +1,260 @@
+# Tests for email address handling
+
+# Copyright (C) 2022 Jacob Bachmeyer
+#
+# This file is part of a testsuite for the GNU FTP upload system.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+proc check_email_handling {desc args} {
+    set tenv [new_test_environment]
+
+    array set data { setup {} email-to {} }
+    array set data $args
+
+    array set setup { packages {} blacklist {} }
+    array set setup $data(setup)
+
+    register_test_packages $tenv $setup(packages)
+
+    put_file [file join $tenv email.blacklist] \
+       "[join $setup(blacklist) \"\n\"]\n"
+
+    make_test_case $tenv {
+       foo.bin {
+           directive {
+               version 1.2
+               filename foo.bin
+               directory foo
+           } dsig { good 00 1000 }
+           file { test } fsig { good 01 1000 }
+       }
+    }
+
+    start_test_services $tenv
+    run_upload_batch_test
+    stop_test_services
+
+    analyze_log $tenv "email: $desc" {
+       mail,addresses "outgoing mail sent"
+       workdone,1 "1 upload processed"
+    }
+
+    analyze_mail $tenv "email: $desc" to $data(email-to)
+
+    analyze_file_tree $tenv "email: $desc" \
+       { incoming in-stage stage archive } empty {}
+    analyze_file_tree $tenv "email: $desc" \
+       { pub } files { foo/foo.bin.sig foo/foo.bin }
+
+    close_test_environment $tenv
+}
+
+# ----------------------------------------
+
+check_email_handling "basic" setup {
+    packages {
+       foo {
+           email { "foo@example.org" }
+           keys { { id 1000 name "foo <foo@example.gnu.org>" } }
+           maintainers { "foo <foo@example.net>" }
+       }
+    }
+} email-to {
+    ftp-upload-script@gnu.org foo@example.gnu.org
+    ftp-upload-report@gnu.org foo@example.org foo@example.net
+}
+
+# ----------------------------------------
+
+check_email_handling "key carries blacklisted address" setup {
+    packages {
+       foo {
+           email { "foo@example.org" }
+           keys { { id 1000 name "foo <foo@example.gnu.org>" } }
+           maintainers { "foo <foo@example.net>" }
+       }
+    }
+    blacklist { foo@example.gnu.org }
+} email-to {
+    ftp-upload-script@gnu.org
+    ftp-upload-report@gnu.org foo@example.org foo@example.net
+}
+
+check_email_handling "maintainers file contains blacklisted address" setup {
+    packages {
+       foo {
+           email { "foo@example.org" }
+           keys { { id 1000 name "foo <foo@example.gnu.org>" } }
+           maintainers { "foo <foo@example.net>" }
+       }
+    }
+    blacklist { foo@example.net }
+} email-to {
+    ftp-upload-script@gnu.org foo@example.gnu.org
+    ftp-upload-report@gnu.org foo@example.org
+}
+
+check_email_handling "package email list contains blacklisted address" setup {
+    packages {
+       foo {
+           email { "foo@example.org" }
+           keys { { id 1000 name "foo <foo@example.gnu.org>" } }
+           maintainers { "foo <foo@example.net>" }
+       }
+    }
+    blacklist { foo@example.org }
+} email-to {
+    ftp-upload-script@gnu.org foo@example.gnu.org
+    ftp-upload-report@gnu.org foo@example.net
+}
+
+# ----------------------------------------
+
+check_email_handling "repeated address across key and maintainers list" setup {
+    packages {
+       foo {
+           email { "foo@example.org" }
+           keys { { id 1000 name "foo <foo@example.gnu.org>" } }
+           maintainers { "foo <foo@example.gnu.org>" }
+       }
+    }
+} email-to {
+    ftp-upload-script@gnu.org foo@example.gnu.org
+    ftp-upload-report@gnu.org foo@example.org
+}
+
+check_email_handling "repeated address across maintainer and email lists" \
+setup {
+    packages {
+       foo {
+           email { "foo@example.net" }
+           keys { { id 1000 name "foo <foo@example.gnu.org>" } }
+           maintainers { "foo <foo@example.net>" }
+       }
+    }
+} email-to {
+    ftp-upload-script@gnu.org foo@example.gnu.org
+    ftp-upload-report@gnu.org foo@example.net
+}
+
+check_email_handling "repeated address across all three" setup {
+    packages {
+       foo {
+           email { "foo@example.gnu.org" }
+           keys { { id 1000 name "foo <foo@example.gnu.org>" } }
+           maintainers { "foo <foo@example.gnu.org>" }
+       }
+    }
+} email-to {
+    ftp-upload-script@gnu.org foo@example.gnu.org
+    ftp-upload-report@gnu.org
+}
+
+check_email_handling "repeated address in maintainers list" setup {
+    packages {
+       foo {
+           email { "foo@example.org" }
+           keys { { id 1000 name "foo <foo@example.gnu.org>" } }
+           maintainers { "foo <foo@example.net>" "bar <foo@example.net>" }
+       }
+    }
+} email-to {
+    ftp-upload-script@gnu.org foo@example.gnu.org
+    ftp-upload-report@gnu.org foo@example.org foo@example.net
+}
+
+check_email_handling "repeated address in package email list" setup {
+    packages {
+       foo {
+           email { "foo@example.org" "foo@example.org" }
+           keys { { id 1000 name "foo <foo@example.gnu.org>" } }
+           maintainers { "foo <foo@example.net>" }
+       }
+    }
+} email-to {
+    ftp-upload-script@gnu.org foo@example.gnu.org
+    ftp-upload-report@gnu.org foo@example.org foo@example.net
+}
+
+check_email_handling "repeated addresses in both lists" setup {
+    packages {
+       foo {
+           email { "foo@example.org" "foo@example.net" }
+           keys { { id 1000 name "foo <foo@example.gnu.org>" } }
+           maintainers { "foo <foo@example.net>" "bar <foo@example.org>" }
+       }
+    }
+} email-to {
+    ftp-upload-script@gnu.org foo@example.gnu.org
+    ftp-upload-report@gnu.org foo@example.org foo@example.net
+}
+
+check_email_handling "repeated addresses five ways" setup {
+    packages {
+       foo {
+           email { "foo@example.org" "foo@example.gnu.org" "foo@example.net" }
+           keys { { id 1000 name "foo <foo@example.gnu.org>" } }
+           maintainers { "foo <foo@example.net>" "bar <foo@example.gnu.org>" }
+       }
+    }
+} email-to {
+    ftp-upload-script@gnu.org foo@example.gnu.org
+    ftp-upload-report@gnu.org foo@example.org foo@example.net
+}
+
+# ----------------------------------------
+
+check_email_handling "key carries invalid address" setup {
+    packages {
+       foo {
+           email { "foo@example.org" }
+           keys { { id 1000 name "foo <foovax!barvax!kremvax!vadim>" } }
+           maintainers { "foo <foo@example.net>" }
+       }
+    }
+} email-to {
+    ftp-upload-script@gnu.org
+    ftp-upload-report@gnu.org foo@example.org foo@example.net
+}
+
+check_email_handling "maintainers list contains invalid address" setup {
+    packages {
+       foo {
+           email { "foo@example.org" }
+           keys { { id 1000 name "foo <foo@example.gnu.org>" } }
+           maintainers { "foo <foovax!barvax!kremvax!vadim>" }
+       }
+    }
+} email-to {
+    ftp-upload-script@gnu.org foo@example.gnu.org
+    ftp-upload-report@gnu.org foo@example.org
+}
+
+check_email_handling "package email list contains invalid address" setup {
+    packages {
+       foo {
+           email { "foovax!barvax!kremvax!vadim" }
+           keys { { id 1000 name "foo <foo@example.gnu.org>" } }
+           maintainers { "foo <foo@example.net>" }
+       }
+    }
+} email-to {
+    ftp-upload-script@gnu.org foo@example.gnu.org
+    ftp-upload-report@gnu.org foo@example.net
+}
+
+# ----------------------------------------
+
+#EOF