From: francisco.garcia Date: Mon, 31 Jul 2023 11:11:21 +0000 (+0200) Subject: regress: Add check_string_in_log and generate self-signed certificate X-Git-Tag: Beta-15.0.0~149 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1f8c1215eabb861aa7958fa49424c55f57d5c6f;p=thirdparty%2Fbacula.git regress: Add check_string_in_log and generate self-signed certificate --- diff --git a/regress/scripts/regress-utils.sh b/regress/scripts/regress-utils.sh index bbd1da8dc..674e39a7d 100755 --- a/regress/scripts/regress-utils.sh +++ b/regress/scripts/regress-utils.sh @@ -36,6 +36,34 @@ fi export LPLUG } +# +# Create self-signed certificate. +# +# in: +# $1 (optional): Directory to save the csr, key and pem. +# $2 (optional): Name of csr, key and pem +# +setup_self_signed_cert() +{ + cert_dir="/tmp/" + cert_name="snakeoil" + if [ "x$1" != "x" ] + then + if [ "${1:(-1)}" != "/" ] + then + cert_dir=${1}/ + fi + fi + if [ "x${2}" != "x" ] + then + cert_name=${2} + fi + echo "[INIT] CREATE OPENSSL CERTS" + `openssl req -nodes -newkey rsa:2048 -keyout ${cert_dir}${cert_name}.key -out ${cert_dir}${cert_name}.csr -subj "/C=CH/ST=Vaud/L=Yverdon-les-Bains/O=Backup Security/OU=R&D Department/CN=baculasystems.com"` + `openssl x509 -req -sha256 -days 365 -in ${cert_dir}${cert_name}.csr -signkey ${cert_dir}${cert_name}.key -out ${cert_dir}${cert_name}.pem` + echo "[END] CREATE OPENSSL CERTS" +} + # # common check if test pass by checking input param # @@ -284,6 +312,31 @@ else fi } +# +# Check the expected string on any log file +# +# in: +# $1 - type of log. Values allowed: b,r,e,l +# $2 - the string to seach into logfile +# $3 - a test number to examine which means we will check log${ltest}.out logfile +check_regress_string_in_log() +{ + type_log=$1 + to_search=$2 + n_test=$3 + log_file=${tmp}/${type_log}log${n_test}.out + grep "${to_search}" ${log_file} + F=$? + if [ $F -ne 0 ] + then + error_stat="${type_log}stat" + declare -g "${error_stat}"=$((${!error_stat}+1)) + return 1 + else + return 0 + fi +} + # # This is a simple common function which start a fresh, new local slapd # available on ldap://localhost:3890