• [gentoo-dev] [PATCH v2 1/4] eclass/tests: Add initial tests for verify-

    From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Fri Sep 8 12:20:01 2023
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/tests/verify-sig.sh | 65 ++++++++++++++++++++++++++++++++++++++
    1 file changed, 65 insertions(+)
    create mode 100755 eclass/tests/verify-sig.sh

    diff --git a/eclass/tests/verify-sig.sh b/eclass/tests/verify-sig.sh
    new file mode 100755
    index 000000000000..fcd2ee7480a2
    --- /dev/null
    +++ b/eclass/tests/verify-sig.sh
    @@ -0,0 +1,65 @@
    +#!/bin/bash
    +# Copyright 2023 Gentoo Authors
    +# Distributed under the terms of the GNU General Public License v2
    +
    +EAPI=8
    +source tests-common.sh || exit
    +
    +inherit verify-sig
    +
    +TMP=$(mktemp -d)
    +trap 'rm -rf "${TMP}"' EXIT
    +cd "${TMP}" || die
    empty || die
    fail || die
    +echo "The quick brown fox jumps over the lazy dog." > text || die
    +
    +testit() {
    + local expect=${1}
    + shift
    +
    + tbegin "${*@Q}"
    + ( "${@}" )
    + [[ ${?} -eq ${expect} ]]
    + tend "${?}"
    +}
    +
    +test_verify_unsigned_checksums() {
    + local format=${1}
    +
    + testit 0 verify-sig_verify_unsigned_checksums checksums.txt "${format}" empty
    + testit 0 verify-sig_verify_unsig
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Fri Sep 8 12:20:01 2023
    Thanks to ulm for reporting.

    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/verify-sig.eclass | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)

    diff --git a/eclass/verify-sig.eclass b/eclass/verify-sig.eclass
    index 010361bfbc98..49557b633c87 100644
    --- a/eclass/verify-sig.eclass
    +++ b/eclass/verify-sig.eclass
    @@ -55,8 +55,8 @@ IUSE="verify-sig"
    # @DESCRIPTION:
    # Signature verification method to use. The allowed value are:
    #
    -# - openpgp -- verify PGP signatures using app-crypt/gnupg (the default)
    -# - signify -- verify signatures with Ed25519 public key using app-crypt/signify
    +# - openpgp -- verify PGP signatures using app-crypt/gnupg (the default)
    +# - signify -- verify signatures with Ed25519 public key using app-crypt/signify
    : "${VERIFY_SIG_METHOD:=openpgp}"

    case ${VERIFY_SIG_METHOD} in
    --
    2.42.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sam James@21:1/5 to mgorny@gentoo.org on Fri Sep 8 12:30:02 2023
    Michał Górny <mgorny@gentoo.org> writes:

    Signed-off-by: Michał Górny <mgorny@gentoo.org>

    The lot lgtm with Bug/Closes tags for https://bugs.gentoo.org/913394.

    ---
    eclass/tests/verify-sig.sh | 65 ++++++++++++++++++++++++++++++++++++++
    1 file changed, 65 insertions(+)
    create mode 100755 eclass/tests/verify-sig.sh

    diff --git a/eclass/tests/verify-sig.sh b/eclass/tests/verify-sig.sh
    new file mode 100755
    index 000000000000..fcd2ee7480a2
    --- /dev/null
    +++ b/eclass/tests/verify-sig.sh
    @@ -0,0 +1,65 @@
    +#!/bin/bash
    +# Copyright 2023 Gentoo Authors
    +# Distributed under the terms of the GNU General Public License v2
    +
    +EAPI=8
    +source tests-common.sh || exit
    +
    +inherit verify-sig
    +
    +TMP=$(mktemp -d)
    +trap 'rm -rf "${TMP}"' EXIT
    +cd "${TMP}" || die
    empty || die
    fail || die
    +echo "The quick brown fox jumps over the lazy dog." > text || die
    +
    +testit() {
    + local expect=${1}
    + shift
    +
    + tbegin "${*@Q}"
    + ( "${@}" )
    + [[ ${?} -eq ${expect} ]]
    + tend "${?}"
    +}
    +
    +test_verify_unsigned_checksums() {
    + local format=${1}
    +
    + testit 0 verify-sig_verify_unsigned_checksums checksums.txt "${format}" empty
    + testit 0 verify-sig_verify_unsigned_checksums checksums.txt "${format}" "empty text"
    + testit 1 verify-sig_verify_unsigned_checksums checksums.txt "${format}" other
    + testit 1 verify-sig_verify_unsigned_checksums checksums.txt "${format}" "empty other"
    + testit 1 verify-sig_verify_unsigned_checksums checksums.txt "${format}" fail
    + testit 1 verify-sig_verify_unsigned_checksums checksums.txt "${format}" "empty fail"
    +}
    +
    +einfo "Testing coreutils format."
    +eindent
    +
    +cat > checksums.txt <<-EOF || die
    + # some junk to test junk protection
    + b47cc0f104b62d4c7c30bcd68fd8e67613e287dc4ad8c310ef10cbadea9c4380 empty junk line
    + b47cc0f104b62d4c7c30bcd68gd8e67613e287dc4ad8c310ef10cbadea9c4380 empty +
    + # sha1sums
    + da39a3ee5e6b4b0d3255bfef95601890afd80709 empty
    + 9c04cd6372077e9b11f70ca111c9807dc7137e4b text
    + 9c04cd6372077e9b11f70ca111c9807dc7137e4b fail
    +
    + # sha256sums
    + e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 empty + b47cc0f104b62d4c7c30bcd68fd8e67613e287dc4ad8c310ef10cbadea9c4380 text
    + b47cc0f104b62d4c7c30bcd68fd8e67613e287dc4ad8c310ef10cbadea9c4380 fail
    +
    + # sha512sums
    + cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e empty
    + 020da0f4d8a4c8bfbc98274027740061d7df52ee07091ed6595a083e0f45327bbe59424312d86f218b74ed2e25507abaf5c7a5fcf4cafcf9538b705808fd55ec text
    + 020da0f4d8a4c8bfbc98274027740061d7df52ee07091ed6595a083e0f45327bbe59424312d86f218b74ed2e25507abaf5c7a5fcf4cafcf9538b705808fd55ec fail
    +EOF
    +
    +test_verify_unsigned_checksums sha256
    +eoutdent
    +
    +texit

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Fri Sep 8 12:20:01 2023
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/tests/verify-sig.sh | 18 +++++++++++++
    eclass/verify-sig.eclass | 54 +++++++++++++++++++++++++-------------
    2 files changed, 54 insertions(+), 18 deletions(-)

    Changes:
    - referring to the var as `format` consistently
    - fixed eclassdoc
    - used explicit if;fi

    diff --git a/eclass/tests/verify-sig.sh b/eclass/tests/verify-sig.sh
    index fcd2ee7480a2..fb7f2cdb2a5d 100755
    --- a/eclass/tests/verify-sig.sh
    +++ b/eclass/tests/verify-sig.sh
    @@ -62,4 +62,22 @@ EOF
    test_verify_unsigned_checksums sha256
    eoutdent

    +einfo "Testing openssl-dgst format."
    +eindent
    +
    "annoying ( filename )= yes ).txt" || die
    +
    +cat > checksums.txt <<-EOF || die
    + junk text that ought to be ignored
    +
    + SHA256(empty)=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
    + SHA256(text)= b47cc0f104b62d4c7c30bcd68fd8e67613e287dc4ad8c310ef10cbadea9c4380
    + SHA256(fail)=b47cc0f104b62d4c7c30bcd68fd8e67613e287dc4ad8c310ef10cbadea9c4380
    +
    + SHA256(annoying ( filename )= yes )= e3b0c44298fc1c149af