1000-external-signatures 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #! /bin/bash
  2. #
  3. # © 2018 Ansgar Burchardt <ansgar@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. shopt -s extglob
  21. . ${DAK_ROOT:?}/integration-tests/common
  22. . ${DAK_ROOT:?}/integration-tests/setup
  23. # add a unstable suite with amd64
  24. dak admin architecture add amd64 AMD64
  25. dak admin suite add unstable "" codename=sid
  26. dak admin suite-architecture add unstable source all amd64
  27. dak admin suite-component add unstable main contrib non-free
  28. dak admin suite add-build-queue unstable buildd-unstable buildd-sid ${DAKHOST}
  29. dak admin suite-config set unstable allowcsset=yes
  30. packages=${DAK_ROOT:?}/tests/fixtures/packages
  31. ln -sf ${packages:?}/gpg/pubring.gpg ${DAKBASE:?}/keyrings/upload-keyring.gpg
  32. dak import-keyring -U "%s" ${DAKBASE}/keyrings/upload-keyring.gpg
  33. cat >> ${DAKBASE}/etc/dak.conf <<-EOT
  34. External-Signature-Requests {
  35. Sources {
  36. linux {
  37. Packages { "linux-image-all-signed-template"; };
  38. Architectures { "all"; } ;
  39. };
  40. };
  41. Default-Suites { "unstable"; "proposed-updates"; };
  42. Export "${DAKBASE}/ftp/external-signature-requests.json";
  43. };
  44. EOT
  45. expected='
  46. {
  47. "packages": [
  48. {
  49. "suite": "unstable",
  50. "codename": "sid",
  51. "version": "42.0-1",
  52. "architecture": "all",
  53. "package": "linux-image-all-signed-template"
  54. }
  55. ]
  56. }
  57. '
  58. expected_empty='
  59. {
  60. "packages": []
  61. }
  62. '
  63. # try NEW upload
  64. (
  65. cp ${packages:?}/linux@(_|-image)* ${DAKBASE}/tmp
  66. dak process-upload -d ${DAKBASE}/tmp --automatic
  67. # TODO: test upload is in NEW
  68. dak control-override -s unstable --add <<-EOT
  69. linux-image-all-signed-template optional misc
  70. linux-image-all optional misc
  71. EOT
  72. dak control-override -s unstable -t dsc --add <<-EOT
  73. linux misc
  74. EOT
  75. dak process-new --automatic
  76. dak process-policy new
  77. dak manage-external-signature-requests
  78. if ! diff -u <(jq -S . <<< "${expected}") <(jq -S . ${DAKBASE}/ftp/external-signature-requests.json); then
  79. echo >&2 "E: external-signature-requests.json differs from expected value"
  80. exit 1
  81. fi
  82. )
  83. # remove upload, should go away from external-signature-requests
  84. (
  85. dak control-suite --set unstable </dev/null
  86. dak manage-build-queues
  87. dak manage-external-signature-requests
  88. if ! diff -u <(jq -S . <<< "${expected_empty}") <(jq -S . ${DAKBASE}/ftp/external-signature-requests.json); then
  89. echo >&2 "E: external-signature-requests.json differs from expected value"
  90. exit 1
  91. fi
  92. )
  93. # try non-NEW upload
  94. (
  95. cp ${packages:?}/linux@(_|-image)* ${DAKBASE}/tmp
  96. dak admin forget-signature ${DAKBASE}/tmp/linux_*.changes
  97. dak process-upload -d ${DAKBASE}/tmp --automatic
  98. dak manage-external-signature-requests
  99. if ! diff -u <(jq -S . <<< "${expected}") <(jq -S . ${DAKBASE}/ftp/external-signature-requests.json); then
  100. echo >&2 "E: external-signature-requests.json differs from expected value"
  101. exit 1
  102. fi
  103. )
  104. # try upload to policy queue w/ build queue (like on security-master)
  105. (
  106. # configure a policy queue first...
  107. dak admin suite add embargoed "" codename=embargoed
  108. dak admin suite-architecture add unstable source all amd64
  109. dak admin suite-component add unstable main contrib non-free
  110. psql -1 -d projectb <<-EOT
  111. \set ON_ERROR_STOP
  112. INSERT INTO policy_queue (queue_name, path, send_to_build_queues, suite_id)
  113. VALUES ('embargoed',
  114. '${DAKBASE}/queue/embargoed',
  115. TRUE,
  116. (SELECT id FROM suite WHERE suite_name = 'embargoed'));
  117. UPDATE suite
  118. SET policy_queue_id = (SELECT id FROM policy_queue WHERE queue_name = 'embargoed')
  119. WHERE suite_name = 'unstable';
  120. EOT
  121. dak control-suite --set unstable </dev/null
  122. dak manage-build-queues
  123. cp ${packages:?}/linux@(_|-image)* ${DAKBASE}/tmp
  124. dak admin forget-signature ${DAKBASE}/tmp/linux_*.changes
  125. dak process-upload -d ${DAKBASE}/tmp --automatic
  126. dak manage-external-signature-requests
  127. if ! diff -u <(jq -S . <<< "${expected}") <(jq -S . ${DAKBASE}/ftp/external-signature-requests.json); then
  128. echo >&2 "E: external-signature-requests.json differs from expected value"
  129. exit 1
  130. fi
  131. commentdir=${DAKBASE}/queue/embargoed/COMMENTS
  132. mkdir -p ${commentdir}
  133. echo OK > ${commentdir}/ACCEPT.linux_42.0-1
  134. dak process-policy embargoed
  135. dak manage-external-signature-requests
  136. if ! diff -u <(jq -S . <<< "${expected}") <(jq -S . ${DAKBASE}/ftp/external-signature-requests.json); then
  137. echo >&2 "E: external-signature-requests.json differs from expected value"
  138. exit 1
  139. fi
  140. )