Commit 87cae25c authored by Vincent Pelletier's avatar Vincent Pelletier

shell/caucase.sh: Factorise self-test failure codepath.

parent e5e13cd0
...@@ -1190,6 +1190,12 @@ EOF ...@@ -1190,6 +1190,12 @@ EOF
caucased_dir \ caucased_dir \
caucased_type \ caucased_type \
caucased_pid caucased_pid
_fail () {
# shellcheck disable=SC2059
printf "$@"
find . -ls
exit 1
}
echo 'Automated testing...' echo 'Automated testing...'
if command -v caucased > /dev/null; then if command -v caucased > /dev/null; then
caucased_type="path" caucased_type="path"
...@@ -1288,29 +1294,21 @@ EOF ...@@ -1288,29 +1294,21 @@ EOF
| sed 's/\s.*//' \ | sed 's/\s.*//' \
)" )"
if [ ! -d cas_crt ]; then if [ ! -d cas_crt ]; then
echo 'cas_crt not created' _fail 'cas_crt not created\n'
find . -ls
return 1
fi fi
for cas_file in cas_crt/*; do for cas_file in cas_crt/*; do
if [ -r "$cas_file" ] && [ ! -h "$cas_file" ]; then if [ -r "$cas_file" ] && [ ! -h "$cas_file" ]; then
if [ "$cas_found" -eq 1 ]; then if [ "$cas_found" -eq 1 ]; then
echo 'Multiple CAS CA certificates found' _fail 'Multiple CAS CA certificates found\n'
find . -ls
return 1
fi fi
cas_found=1 cas_found=1
fi fi
done done
if [ "$cas_found" -eq 0 ]; then if [ "$cas_found" -eq 0 ]; then
echo 'No CAS CA certificates found, but directory exists' _fail 'No CAS CA certificates found, but directory exists\n'
find . -ls
return 1
fi fi
if [ ! -f cau.crt.pem ]; then if [ ! -f cau.crt.pem ]; then
echo 'cau.crt.pem not created' _fail 'cau.crt.pem not created\n'
find . -ls
return 1
fi fi
echo 'Retrieving auto-issued user certificate...' echo 'Retrieving auto-issued user certificate...'
if _main \ if _main \
...@@ -1321,9 +1319,7 @@ EOF ...@@ -1321,9 +1319,7 @@ EOF
then then
: :
else else
echo 'Failed to receive signed user certificate.' _fail 'Failed to receive signed user certificate.\n'
find . -ls
return 1
fi fi
echo 'Using the user certificate...' echo 'Using the user certificate...'
if _main \ if _main \
...@@ -1334,9 +1330,7 @@ EOF ...@@ -1334,9 +1330,7 @@ EOF
> /dev/null; then > /dev/null; then
: :
else else
echo 'Failed to list pending CSR, authentication failed ?' _fail 'Failed to list pending CSR, authentication failed ?\n'
find . -ls
return 1
fi fi
echo 'Success' echo 'Success'
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment