Skip to content

Commit

Permalink
test-pkcs11-tool-test.sh - fixup add --module "${P11LIB}" to URI tests
Browse files Browse the repository at this point in the history
As suggested in OpenSC#3090 (comment)
to not use opensc-tool but add --module "${P11LIB}" to URI tests
  • Loading branch information
dengert committed Oct 28, 2024
1 parent 4f6b764 commit e9cfac1
Showing 1 changed file with 14 additions and 32 deletions.
46 changes: 14 additions & 32 deletions tests/test-pkcs11-tool-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,21 @@ echo "======================================================="
$PKCS11_TOOL --test -p "${PIN}" --module "${P11LIB}"
assert $? "Failed running tests"

# done with $P11LIB

# test if OpenSC can access a reader with a token using OpenSC module
# to test how OpenSC creates
# softhsm2 module does not count
#
OPENSC_TOOL="../src/tools/opensc-tool"
if [[ -f "$OPENSC_TOOL" ]] ; then
$OPENSC_TOOL -a
if [[ "$?" -eq "0" ]] ; then
echo "======================================================="
echo "Test objects URI"
echo "======================================================="
$PKCS11_TOOL -O 2>/dev/null | grep 'uri:' 2>/dev/null >/dev/null
assert $? "Failed running objects URI tests"
$PKCS11_TOOL -O 2>/dev/null | grep 'uri:' | awk -F 'uri:' '{print $2}' | tr -d ' ' | grep ^"pkcs11:" 2>/dev/null >/dev/null
assert $? "Failed running objects URI tests"
echo "======================================================="
echo "Test objects URI"
echo "======================================================="
$PKCS11_TOOL --module "${P11LIB}" -O 2>/dev/null | grep 'uri:' 2>/dev/null >/dev/null
assert $? "Failed running objects URI tests"
$PKCS11_TOOL --module "${P11LIB}" -O 2>/dev/null | grep 'uri:' | awk -F 'uri:' '{print $2}' | tr -d ' ' | grep ^"pkcs11:" 2>/dev/null >/dev/null
assert $? "Failed running objects URI tests"

echo "======================================================="
echo "Test slots URI"
echo "======================================================="
$PKCS11_TOOL -L 2>/dev/null | grep 'uri' 2>/dev/null >/dev/null
assert $? "Failed running slots URI tests"
$PKCS11_TOOL -O 2>/dev/null | grep 'uri' | awk -F 'uri*:' '{print $2}' | tr -d ' ' | grep ^"pkcs11:" 2>/dev/null >/dev/null
assert $? "Failed running slots URI tests"
else
echo "Skipping URI tests because no token found"
exit 77
fi
else
echo "Skipping URI tests because because opensc-tool not found"
exit 77
fi
echo "======================================================="
echo "Test slots URI"
echo "======================================================="
$PKCS11_TOOL --module "${P11LIB}" -L 2>/dev/null | grep 'uri' 2>/dev/null >/dev/null
assert $? "Failed running slots URI tests"
$PKCS11_TOOL --module "${P11LIB}" -O 2>/dev/null | grep 'uri' | awk -F 'uri*:' '{print $2}' | tr -d ' ' | grep ^"pkcs11:" 2>/dev/null >/dev/null
assert $? "Failed running slots URI tests"

echo "======================================================="
echo "Cleanup"
Expand Down

0 comments on commit e9cfac1

Please sign in to comment.