Blame tests/system-override-default-priority-string.sh

Packit Service 991b93
#!/bin/sh
Packit Service 991b93
# Copyright (C) 2019 Canonical, Ltd.
Packit Service 991b93
#
Packit Service 991b93
# Author: Dimitri John Ledkov
Packit Service 991b93
#
Packit Service 991b93
# This file is part of GnuTLS.
Packit Service 991b93
#
Packit Service 991b93
# GnuTLS is free software; you can redistribute it and/or modify it
Packit Service 991b93
# under the terms of the GNU General Public License as published by the
Packit Service 991b93
# Free Software Foundation; either version 3 of the License, or (at
Packit Service 991b93
# your option) any later version.
Packit Service 991b93
#
Packit Service 991b93
# GnuTLS is distributed in the hope that it will be useful, but
Packit Service 991b93
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 991b93
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 991b93
# General Public License for more details.
Packit Service 991b93
#
Packit Service 991b93
# You should have received a copy of the GNU General Public License
Packit Service 991b93
# along with GnuTLS; if not, write to the Free Software Foundation,
Packit Service 991b93
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit Service 991b93
Packit Service 991b93
srcdir="${srcdir:-.}"
Packit Service 991b93
SERV="${SERV:-../src/gnutls-serv${EXEEXT}}"
Packit Service 991b93
CLI="${CLI:-../src/gnutls-cli${EXEEXT}}"
Packit Service 991b93
TMPFILE=config.$$.tmp
Packit Service 991b93
TMPFILE2=log.$$.tmp
Packit Service 991b93
STOCK_PRIORITY="${GNUTLS_SYSTEM_PRIORITY_FILE:-./system.prio}"
Packit Service 991b93
export GNUTLS_SYSTEM_PRIORITY_FAIL_ON_INVALID=1
Packit Service 991b93
Packit Service 991b93
if ! test -x "${SERV}"; then
Packit Service 991b93
	exit 77
Packit Service 991b93
fi
Packit Service 991b93
Packit Service 991b93
if ! test -x "${CLI}"; then
Packit Service 991b93
	exit 77
Packit Service 991b93
fi
Packit Service 991b93
Packit Service 991b93
if test "${WINDIR}" != ""; then
Packit Service 991b93
	exit 77
Packit Service 991b93
fi
Packit Service 991b93
Packit Service 991b93
. "${srcdir}/scripts/common.sh"
Packit Service 991b93
Packit Service 991b93
export GNUTLS_DEBUG_LEVEL=3
Packit Service 991b93
KEY1=${srcdir}/../doc/credentials/x509/key-rsa.pem
Packit Service 991b93
CERT1=${srcdir}/../doc/credentials/x509/cert-rsa.pem
Packit Service 991b93
Packit Service 991b93
# Try whether a client connection with priority string None succeeds
Packit Service 991b93
export GNUTLS_SYSTEM_PRIORITY_FILE="${srcdir}/system-override-default-priority-string.none.config"
Packit Service 991b93
eval "${GETPORT}"
Packit Service 991b93
launch_server $$ --echo --x509keyfile ${KEY1} --x509certfile ${CERT1}
Packit Service 991b93
PID=$!
Packit Service 991b93
wait_server ${PID}
Packit Service 991b93
Packit Service 991b93
export GNUTLS_SYSTEM_PRIORITY_FILE="${STOCK_PRIORITY}"
Packit Service 991b93
"${CLI}" -p "${PORT}" 127.0.0.1 --insecure --logfile ${TMPFILE2} </dev/null >/dev/null &&
Packit Service 991b93
	fail "expected connection to fail (1)"
Packit Service 991b93
kill ${PID}
Packit Service 991b93
wait
Packit Service 991b93
Packit Service 991b93
# Try whether a client connection to an tls1.3 only server succeeds
Packit Service 991b93
export GNUTLS_SYSTEM_PRIORITY_FILE="${srcdir}/system-override-default-priority-string.only-tls13.config"
Packit Service 991b93
eval "${GETPORT}"
Packit Service 991b93
launch_server $$ --echo --x509keyfile ${KEY1} --x509certfile ${CERT1}
Packit Service 991b93
PID=$!
Packit Service 991b93
wait_server ${PID}
Packit Service 991b93
Packit Service 991b93
export GNUTLS_SYSTEM_PRIORITY_FILE="${STOCK_PRIORITY}"
Packit Service 991b93
"${CLI}" -p "${PORT}" 127.0.0.1 --priority "NORMAL:-VERS-TLS1.3" --insecure --logfile ${TMPFILE2} </dev/null >/dev/null &&
Packit Service 991b93
	fail "expected connection to fail (2)"
Packit Service 991b93
Packit Service 991b93
export GNUTLS_SYSTEM_PRIORITY_FILE="${STOCK_PRIORITY}"
Packit Service 991b93
"${CLI}" -p "${PORT}" 127.0.0.1 --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.3" --insecure --logfile ${TMPFILE2} </dev/null >/dev/null ||
Packit Service 991b93
	fail "expected connection to succeed (1)"
Packit Service 991b93
Packit Service 991b93
kill ${PID}
Packit Service 991b93
wait
Packit Service 991b93
Packit Service 991b93
# Check that a bad (empty) default-priority-string results in an built-one being used, when non-strict
Packit Service 991b93
export GNUTLS_SYSTEM_PRIORITY_FILE="${srcdir}/system-override-default-priority-string.bad.config"
Packit Service 991b93
unset GNUTLS_SYSTEM_PRIORITY_FAIL_ON_INVALID
Packit Service 991b93
eval "${GETPORT}"
Packit Service 991b93
launch_server $$ --echo --x509keyfile ${KEY1} --x509certfile ${CERT1}
Packit Service 991b93
PID=$!
Packit Service 991b93
wait_server ${PID}
Packit Service 991b93
Packit Service 991b93
"${CLI}" -p "${PORT}" 127.0.0.1 --insecure --logfile ${TMPFILE2} </dev/null >/dev/null ||
Packit Service 991b93
	fail "expected connection to succeed (2)"
Packit Service 991b93
Packit Service 991b93
kill ${PID}
Packit Service 991b93
wait
Packit Service 991b93
Packit Service 991b93
exit 0