0006-dm-commands 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #! /bin/bash
  2. #
  3. # © 2020 Ivo De Decker <ivodd@debian.org>
  4. # License: GPL-2+
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. set -e
  19. set -u
  20. . ${DAK_ROOT:?}/integration-tests/common
  21. . ${DAK_ROOT:?}/integration-tests/setup
  22. . ${DAK_ROOT:?}/integration-tests/dinstall
  23. packages=$(fixture-package-dir)
  24. # copy the keyring multiple times, so that we can modify them
  25. DDRING=${DAKBASE:?}/keyrings/dd/
  26. DMRING=${DAKBASE:?}/keyrings/dm/
  27. # snowman
  28. FP_snowman=589E8FA542378066E944B6222F7C63E8F3A2C549
  29. # Développeur
  30. FP_dev=22865D3DA7CF3DE67C1AF9A74014AB2D03010AA9
  31. # A Maintainer
  32. FP_maint=993C2870F54D83789E55323C13D986C3912E851C
  33. (
  34. cp -Ta ${packages:?}/gpg/ $DDRING
  35. ln -sf $DDRING/pubring.gpg ${DAKBASE:?}/keyrings/dd.gpg
  36. export GNUPGHOME=$DDRING
  37. # only keep A Maintainer, delete the other 2
  38. gpg --batch --yes --delete-secret-and-public-key $FP_snowman
  39. gpg --batch --yes --delete-secret-and-public-key $FP_dev
  40. )
  41. (
  42. cp -Ta ${packages:?}/gpg/ $DMRING
  43. ln -sf $DMRING/pubring.gpg ${DAKBASE:?}/keyrings/dm.gpg
  44. export GNUPGHOME=$DMRING
  45. # keep snowman and Développeur
  46. gpg --batch --yes --delete-secret-and-public-key $FP_maint
  47. )
  48. (
  49. export GNUPGHOME=${DAKBASE:?}/keyrings/tmp
  50. mkdir ${DAKBASE:?}/keyrings/tmp
  51. for kr in dd dm; do
  52. echo $kr
  53. krpath="${DAKBASE}/keyrings/${kr}.gpg"
  54. psql -c "INSERT INTO keyrings (name, acl_id)
  55. VALUES ('$krpath',
  56. (SELECT id FROM acl WHERE name='$kr'))"
  57. dak import-keyring -U "%s" $krpath
  58. done
  59. )
  60. cat >> ${DAKBASE}/etc/dak.conf << EOF
  61. Command::DM {
  62. ACL "dm";
  63. AdminKeyrings {
  64. "${DAKBASE}/keyrings/dd.gpg";
  65. };
  66. Keyrings {
  67. "${DAKBASE}/keyrings/dm.gpg";
  68. };
  69. };
  70. # commands in the test are processed almost immediately after they are signed,
  71. # so don't reject them for being too new
  72. Dinstall::SkipTime 0;
  73. EOF
  74. dm_command() {
  75. export GNUPGHOME=$DDRING
  76. signer=$1
  77. dm=$2
  78. action=$3
  79. pkg=$4
  80. dcut --force -k $signer -O $upload_dir/debian-${dm}-${action}-${pkg}-`date +%s`.dak-commands dm --uid $dm --$action $pkg
  81. }
  82. setup_empty_archive
  83. setup_unstable
  84. (
  85. upload_changes ${packages:?}/binnmupkg_0.1-1_amd64.changes
  86. upload_changes ${packages:?}/package_0.1-1_amd64.changes
  87. upload_changes ${packages:?}/pkgnew_0.1-1_amd64.changes
  88. process_uploads
  89. echo a | dak process-new binnmupkg_0.1-1_amd64.changes
  90. echo a | dak process-new package_0.1-1_amd64.changes
  91. echo a | dak process-new pkgnew_0.1-1_amd64.changes
  92. do_new
  93. )
  94. (
  95. dm_command $FP_maint $FP_snowman allow package
  96. dm_command $FP_maint $FP_snowman allow binnmupkg
  97. dm_command $FP_maint $FP_snowman allow pkgnew
  98. dm_command $FP_maint $FP_dev allow package
  99. # not a DM: should fail
  100. dm_command $FP_maint $FP_maint allow package
  101. dak process-commands -d $upload_dir
  102. check_output dm_1.txt "dak acl export-per-source dm"
  103. )
  104. (
  105. # signed by dev, only allowed by snowman, should fail
  106. upload_changes ${packages:?}/binnmupkg_0.1-2_source.changes
  107. # signed by snowman, allowed by both, should be accepted
  108. upload_changes ${packages:?}/package_0.2-1_amd64.changes
  109. # signed by snowman, allowed by snowman, but NEW, should be rejected
  110. upload_changes ${packages:?}/pkgnew_0.1-3_amd64.changes
  111. # NEW and not allowed should fail
  112. upload_changes ${packages:?}/grave_0.1-1_amd64.changes
  113. process_uploads
  114. )
  115. (
  116. dm_command $FP_maint $FP_dev deny package
  117. dak process-commands -d $upload_dir
  118. check_output dm_2.txt "dak acl export-per-source dm"
  119. )
  120. check_all_suites end