
The test doesn't work properly if the maxscale user doesn't exist and the key file permissions cannot be given to it. The test should use the current user as the owner of the file but it turned out that the -u option is broken. Extended the test case to make sure the same password with the same encryption key results in the same hash.
36 lines
832 B
Bash
Executable File
36 lines
832 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Create a temporary directory: /tmp/tmp.<random>
|
|
SECRETS_DIR=`mktemp -d`
|
|
|
|
# Generate a .secrets file.
|
|
../maxkeys -u $(whoami) ${SECRETS_DIR} || exit 1
|
|
|
|
# Generate a key.
|
|
KEY1=$(../maxpasswd ${SECRETS_DIR} dummy)
|
|
KEY2=$(../maxpasswd ${SECRETS_DIR} dummy)
|
|
|
|
# Remove the temporary directory.
|
|
rm -rf ${SECRETS_DIR}
|
|
|
|
# Get the length of the generated KEY.
|
|
LENGTH=${#KEY1}
|
|
|
|
if [ ${LENGTH} -eq 32 ]
|
|
then
|
|
# Exactly 32 characters => Ok!
|
|
|
|
if [ "$KEY1" == "$KEY2" ]
|
|
then
|
|
# Password encryption returns the same results when invoked multiple times
|
|
exit 0
|
|
else
|
|
echo "First generated key ($KEY1) and second generated key ($KEY2) do not match."
|
|
exit 1
|
|
fi
|
|
else
|
|
# Something else; chances are maxpasswd outputs garbage.
|
|
echo "Expected 32 characters, got $LENGTH"
|
|
exit 1
|
|
fi
|