diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2016-01-08 12:16:29 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2016-01-08 14:20:47 +0100 |
commit | e2d69151e334946b0f67531a46c2cd89a58f9610 (patch) | |
tree | 129f99da7f7b72873bb912269f1fe58d3f55aea5 /tests/cert-tests/othername-test | |
parent | 4a65b1a0ce58064b55c94c92dcc4445552827d37 (diff) | |
download | gnutls-e2d69151e334946b0f67531a46c2cd89a58f9610.tar.gz |
tests: added check for certtool's othername writing functionality
Diffstat (limited to 'tests/cert-tests/othername-test')
-rwxr-xr-x | tests/cert-tests/othername-test | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/cert-tests/othername-test b/tests/cert-tests/othername-test new file mode 100755 index 0000000000..413e873dd2 --- /dev/null +++ b/tests/cert-tests/othername-test @@ -0,0 +1,66 @@ +#!/bin/sh + +# Copyright (C) 2015 Red Hat, Inc. +# +# This file is part of GnuTLS. +# +# GnuTLS is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# GnuTLS is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GnuTLS; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +#set -e + +srcdir="${srcdir:-.}" +CERTTOOL="${CERTTOOL:-../../src/certtool${EXEEXT}}" +DIFF="${DIFF:-diff}" +OUTFILE=tmp-othername.pem + +export TZ="UTC" + +# Check for datefudge +TSTAMP=`datefudge "2006-09-23" date -u +%s || true` +if test "$TSTAMP" != "1158969600"; then + echo $TSTAMP + echo "You need datefudge to run this test" + exit 77 +fi + +# Note that in rare cases this test may fail because the +# time set using datefudge could have changed since the generation +# (if example the system was busy) + +rc=1 +counter=1 + +while [ "${rc}" != "0" -a $counter -le 3 ]; do + datefudge "2007-04-22" \ + "${CERTTOOL}" --generate-self-signed \ + --load-privkey "${srcdir}/template-test.key" \ + --template "${srcdir}/template-othername.tmpl" \ + --outfile ${OUTFILE} 2>/dev/null + + ${DIFF} "${srcdir}/template-othername.pem" ${OUTFILE} >/dev/null 2>&1 + rc=$? + test ${rc} != 0 && sleep 3 + counter=`expr $counter + 1` +done + +# We're done. +if test "${rc}" != "0"; then + echo "Test 1 failed" + exit ${rc} +fi + +rm -f ${OUTFILE} + +exit 0 |