summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2018-11-21 18:35:07 +0300
committerDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2018-11-26 16:56:33 +0300
commitfc81bfef9a816db9afbb21f4fc7c1b4371f6e069 (patch)
tree43118014da8c5c307360709f4266c02c213bdd22
parenta0754ce52e28851fe6cef367ef0fbf45914ada49 (diff)
downloadgnutls-fc81bfef9a816db9afbb21f4fc7c1b4371f6e069.tar.gz
cert-tests: verify --no-text switch for cert/crq/pub/privkeys
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
-rwxr-xr-xtests/cert-tests/crl15
-rwxr-xr-xtests/cert-tests/crq13
-rwxr-xr-xtests/cert-tests/pem-decoding42
-rwxr-xr-xtests/cert-tests/privkey-import16
4 files changed, 86 insertions, 0 deletions
diff --git a/tests/cert-tests/crl b/tests/cert-tests/crl
index f1d1c9683c..15fa44b844 100755
--- a/tests/cert-tests/crl
+++ b/tests/cert-tests/crl
@@ -39,6 +39,7 @@ OUTFILE=out-crl.$$.tmp
INFOFILE=out-crl-info.$$.tmp
OUTFILE2=out2-crl.$$.tmp
TMPFILE=crl.$$.tmpl
+TMP2FILE=crl.$$.tmp2
echo "crl_next_update = 43" >$TMPFILE
echo "crl_number = 7" >>$TMPFILE
@@ -54,6 +55,19 @@ if test "${rc}" != "0"; then
exit ${rc}
fi
+${VALGRIND} "${CERTTOOL}" --crl-info --infile ${OUTFILE} --no-text >${TMP2FILE}
+rc=$?
+
+if test "${rc}" != "0"; then
+ echo "--no-text crl info failed 1"
+ exit ${rc}
+fi
+
+if grep -v '^-----BEGIN [A-Z0-9 ]\+-----$\|^[A-Za-z0-9/+=]\+$\|^-----END [A-Z0-9 ]\+-----$' ${TMP2FILE} ; then
+ echo "--no-text crl info failed 2"
+ exit 1
+fi
+
grep "Revoked certificates (152)" "${INFOFILE}" >/dev/null 2>&1
if test "$?" != "0"; then
echo "CRL generation didn't succeed as expected"
@@ -289,5 +303,6 @@ rm -f "${OUTFILE}"
rm -f "${INFOFILE}"
rm -f "${OUTFILE2}"
rm -f "${TMPFILE}"
+rm -f "${TMP2FILE}"
exit 0
diff --git a/tests/cert-tests/crq b/tests/cert-tests/crq
index 3edc004d6b..2c59930fef 100755
--- a/tests/cert-tests/crq
+++ b/tests/cert-tests/crq
@@ -66,6 +66,19 @@ datefudge -s "2007-04-22" \
--template "${srcdir}/templates/template-tlsfeature.tmpl" \
--outfile $OUTFILE 2>/dev/null
+${CERTTOOL} --crq-info --no-text --infile ${OUTFILE} > ${TMPFILE}
+rc=$?
+
+if test "${rc}" != "0"; then
+ echo "--no-text crq info failed 1"
+ exit ${rc}
+fi
+
+if grep -v '^-----BEGIN [A-Z0-9 ]\+-----$\|^[A-Za-z0-9/+=]\+$\|^-----END [A-Z0-9 ]\+-----$' ${TMPFILE} ; then
+ echo "--no-text crq info failed 2"
+ exit 1
+fi
+
datefudge -s "2007-04-22" \
"${CERTTOOL}" --generate-certificate \
--load-ca-privkey "${srcdir}/data/template-test.key" \
diff --git a/tests/cert-tests/pem-decoding b/tests/cert-tests/pem-decoding
index 0222ae72af..7419656d02 100755
--- a/tests/cert-tests/pem-decoding
+++ b/tests/cert-tests/pem-decoding
@@ -179,6 +179,48 @@ if test "${rc}" != "0"; then
exit ${rc}
fi
+#check if --no-text works as expected
+${VALGRIND} "${CERTTOOL}" --certificate-info --infile "${srcdir}/data/cert-ecc256.pem" --no-text >${TMPFILE}
+rc=$?
+
+if test "${rc}" != "0"; then
+ echo "--no-text -k --certificate-info failed 1"
+ exit ${rc}
+fi
+
+if grep -v '^-----BEGIN [A-Z0-9 ]\+-----$\|^[A-Za-z0-9/+=]\+$\|^-----END [A-Z0-9 ]\+-----$' ${TMPFILE} ; then
+ echo "--no-text -k --certificate-info failed 2"
+ exit 1
+fi
+
+#check if --no-text works as expected
+${VALGRIND} "${CERTTOOL}" --certificate-pubkey --infile "${srcdir}/data/cert-ecc256.pem" --no-text >${TMPFILE}
+rc=$?
+
+if test "${rc}" != "0"; then
+ echo "--no-text cert pubkey failed 1"
+ exit ${rc}
+fi
+
+if grep -v '^-----BEGIN [A-Z0-9 ]\+-----$\|^[A-Za-z0-9/+=]\+$\|^-----END [A-Z0-9 ]\+-----$' ${TMPFILE} ; then
+ echo "--no-text cert pubkey failed 2"
+ exit 1
+fi
+
+#check if --no-text works as expected
+${VALGRIND} "${CERTTOOL}" --pubkey-info --infile "${srcdir}/data/cert-ecc256.pem" --no-text >${TMPFILE}
+rc=$?
+
+if test "${rc}" != "0"; then
+ echo "--no-text pubkey info failed 1"
+ exit ${rc}
+fi
+
+if grep -v '^-----BEGIN [A-Z0-9 ]\+-----$\|^[A-Za-z0-9/+=]\+$\|^-----END [A-Z0-9 ]\+-----$' ${TMPFILE} ; then
+ echo "--no-text pubkey info failed 2"
+ exit 1
+fi
+
rm -f ${TMPFILE} ${TMPFILE1} ${TMPFILE2}
exit 0
diff --git a/tests/cert-tests/privkey-import b/tests/cert-tests/privkey-import
index 6eaa237836..afac285463 100755
--- a/tests/cert-tests/privkey-import
+++ b/tests/cert-tests/privkey-import
@@ -23,6 +23,7 @@
srcdir="${srcdir:-.}"
CERTTOOL="${CERTTOOL:-../../src/certtool${EXEEXT}}"
DIFF="${DIFF:-diff}"
+TMPFILE=tmp-$$.privkey.tmp
if ! test -x "${CERTTOOL}"; then
exit 77
@@ -43,4 +44,19 @@ if test "${rc}" != "0";then
fi
done
+${VALGRIND} "${CERTTOOL}" -k --infile "${srcdir}/data/privkey1.pem" --no-text >${TMPFILE}
+rc=$?
+
+if test "${rc}" != "0"; then
+ echo "--no-text privkey info failed 1"
+ exit ${rc}
+fi
+
+if grep -v '^-----BEGIN [A-Z0-9 ]\+-----$\|^[A-Za-z0-9/+=]\+$\|^-----END [A-Z0-9 ]\+-----$' ${TMPFILE} ; then
+ echo "--no-text privkey info failed 2"
+ exit 1
+fi
+
+rm -f ${TMPFILE}
+
exit 0