]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix "pkcs11" system test
authorMichal Nowak <mnowak@isc.org>
Mon, 24 Feb 2020 15:37:25 +0000 (15:37 +0000)
committerMichal Nowak <mnowak@isc.org>
Thu, 5 Mar 2020 06:57:12 +0000 (07:57 +0100)
  - Define the SLOT environment variable before starting the test.  This
    variable defaults to 0 and that does not work with SoftHSM 2.

  - The system test expects the PIN environment variable to be set to
    "1234" while bin/tests/prepare-softhsm2.sh sets it to "0000".
    Update bin/tests/prepare-softhsm2.sh so that it sets the PIN to
    "1234".

  - Move contents of bin/tests/system/pkcs11/prereq.sh to
    bin/tests/system/pkcs11/setup.sh as the former was creating a file
    called "supported" that was getting removed by the latter before
    bin/tests/system/pkcs11/tests.sh could access it.

  - Fix typo in "have_ecx".

(cherry picked from commit 100a230e80f01a777b917b135b4bae9a4ac0e8ae)

.gitlab-ci.yml
bin/tests/prepare-softhsm2.sh
bin/tests/system/pkcs11/clean.sh
bin/tests/system/pkcs11/prereq.sh [deleted file]
bin/tests/system/pkcs11/setup.sh
bin/tests/system/pkcs11/tests.sh
util/copyrights

index 56905b61590922ffc08a28721e9f2cbda6062c2c..21428b864494fc30bfe5ec9fba761015965e0a3d 100644 (file)
@@ -247,7 +247,8 @@ stages:
     fi
 
 .setup_softhsm: &setup_softhsm |
-    sh -x bin/tests/prepare-softhsm2.sh
+    export SLOT=$(sh -x bin/tests/prepare-softhsm2.sh)
+    test -n "${SLOT}" && test "${SLOT}" -gt 0
 
 .system_test: &system_test_job
   <<: *default_triggering_rules
index 24c7f17c1a9de61bcc3fe19656be2390edf1303c..f51224723ea0d16602a8a12391def759a4dfe1ab 100755 (executable)
@@ -5,6 +5,6 @@ if [ -n "${SOFTHSM2_CONF}" ] && command -v softhsm2-util >/dev/null; then
     echo "directories.tokendir = ${SOFTHSM2_DIR}/tokens" > "${SOFTHSM2_CONF}"
     echo "objectstore.backend = file" >> "${SOFTHSM2_CONF}"
     echo "log.level = DEBUG" >> "${SOFTHSM2_CONF}"
-    softhsm2-util --init-token --free --pin 0000 --so-pin 0000 --label "softhsm2";
+    softhsm2-util --init-token --free --pin 1234 --so-pin 1234 --label "softhsm2" | awk '/^The token has been initialized and is reassigned to slot/ { print $NF }'
 fi
 exit 0
index f5be432d98ed5d7bf1f215e0adb7d9387e001bd0..2cbfc0fa6eb2fb3cddabdfa1d02ecb117413da7e 100644 (file)
@@ -13,4 +13,5 @@ rm -f K* ns1/K* keyset-* dsset-* ns1/*.db ns1/*.signed ns1/*.jnl
 rm -f dig.out* pin upd.log*
 rm -f ns1/*.key ns1/named.memstats
 rm -f supported
+rm -f ns*/named.run
 rm -f ns*/named.lock
diff --git a/bin/tests/system/pkcs11/prereq.sh b/bin/tests/system/pkcs11/prereq.sh
deleted file mode 100644 (file)
index 0eb3b78..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-SYSTEMTESTTOP=..
-. $SYSTEMTESTTOP/conf.sh
-
-echo "I:(Native PKCS#11)" >&2
-rsafail=0 eccfail=0 ecxfail=0
-
-$SHELL ../testcrypto.sh -q rsa || rsafail=1
-$SHELL ../testcrypto.sh -q ecdsa || eccfail=1
-$SHELL ../testcrypto.sh -q eddsa || ecxfail=1
-
-if [ $rsafail = 1 -a $eccfail = 1 ]; then
-       echo "I:This test requires PKCS#11 support for either RSA or ECDSA cryptography." >&2
-       exit 255
-fi
-rm -f supported
-touch supported
-if [ $rsafail = 0 ]; then
-       echo rsa >> supported
-fi
-if [ $eccfail = 0 ]; then
-       echo ecc >> supported
-fi
-if [ $ecxfail = 0 ]; then
-       echo ecx >> supported
-fi
index 4fc5ec5b992e57fe1922f93eb6d57fb07e6bd362..98a69364be9b0dbfa5c52d4daf7b9cfcfdcd2d80 100644 (file)
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
 
+echo "I:(Native PKCS#11)" >&2
+ecxfail=0
+
+$SHELL ../testcrypto.sh -q eddsa || ecxfail=1
+
+rm -f supported
+touch supported
+echo rsa >> supported
+echo ecc >> supported
+if [ $ecxfail = 0 ]; then
+       echo ecx >> supported
+fi
+
 infile=ns1/example.db.in
 
 /bin/echo -n ${HSMPIN:-1234}> pin
index cf3b5492132929fd63bc03ccda0d61ef937ddc07..d1007a6bfa7aa538fb553f20971a65685766dc8a 100644 (file)
@@ -26,7 +26,7 @@ have_ecc=`grep ecc supported`
 if [ "x$have_ecc" != "x" ]; then
     algs=$algs"ecc "
 fi
-have_ecx=`grep ecc supported`
+have_ecx=`grep ecx supported`
 if [ "x$have_ecx" != "x" ]; then
     algs=$algs"ecx "
 fi
index 6fef21fe01776b61bd41706f46b1bb1772a9f5ac..35b7223b5d0a597ff5771478768ce3fd55cf0498 100644 (file)
 ./bin/tests/system/pkcs11/clean.sh             SH      2010,2012,2014,2016,2017,2018,2019,2020
 ./bin/tests/system/pkcs11/ns1/example.db.in    ZONE    2010,2016,2018,2019,2020
 ./bin/tests/system/pkcs11/ns1/named.conf       CONF-C  2018,2019,2020
-./bin/tests/system/pkcs11/prereq.sh            SH      2010,2012,2014,2016,2017,2018,2019,2020
 ./bin/tests/system/pkcs11/setup.sh             SH      2010,2012,2013,2014,2016,2017,2018,2019,2020
 ./bin/tests/system/pkcs11/tests.sh             SH      2010,2012,2014,2016,2017,2018,2019,2020
 ./bin/tests/system/pkcs11/usepkcs11            X       2010,2018,2019,2020