MXS-3010: Fix maxkeys and the test
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.
This commit is contained in:
parent
6cc16ac16b
commit
e2642d64b9
@ -62,9 +62,9 @@ int main(int argc, char** argv)
|
||||
|
||||
int c;
|
||||
#ifdef HAVE_GLIBC
|
||||
while ((c = getopt_long(argc, argv, "h", options, NULL)) != -1)
|
||||
while ((c = getopt_long(argc, argv, "hu:", options, NULL)) != -1)
|
||||
#else
|
||||
while ((c = getopt(argc, argv, "h")) != -1)
|
||||
while ((c = getopt(argc, argv, "hu:")) != -1)
|
||||
#endif
|
||||
{
|
||||
switch (c)
|
||||
|
@ -4,22 +4,32 @@
|
||||
SECRETS_DIR=`mktemp -d`
|
||||
|
||||
# Generate a .secrets file.
|
||||
../maxkeys ${SECRETS_DIR} || exit 1
|
||||
../maxkeys -u $(whoami) ${SECRETS_DIR} || exit 1
|
||||
|
||||
# Generate a key.
|
||||
KEY=`../maxpasswd ${SECRETS_DIR} dummy`
|
||||
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=${#KEY}
|
||||
LENGTH=${#KEY1}
|
||||
|
||||
if [ ${LENGTH} -eq 32 ]
|
||||
then
|
||||
# Exactly 32 characters => Ok!
|
||||
exit 0
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user