-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest.sh
executable file
·51 lines (43 loc) · 1.38 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "================================================================================"
if [[ -f "${DIR}/test.env" ]]; then
echo "Loading test environment data from: ${DIR}/test.env"
. "${DIR}/test.env"
fi
echo "Checking test environment data..."
if [[ -z "$ITERATIONS" || -z "$IDP_METADATA" || -z "$TRUSTED_SP" ||
-z "$PAM_AUTHTOK" || -z "$PAM_RHOST" || -z "$PAM_TYPE" ||
-z "$PAM_USER" ]]; then
echo "Failed!"
exit 2
fi
echo "Succeeded."
IDP_METADATA_FILE=$(mktemp)
echo "$IDP_METADATA" | tr -d '\r' > "${IDP_METADATA_FILE}"
echo "--------------------------------------------------------------------------------"
php -v
echo "--------------------------------------------------------------------------------"
RC=0
START=$(date +%s)
for ((i=1; i<=ITERATIONS; i++)); do
php -c "${DIR}/php.ini" \
-f "${DIR}/pam-script-saml.php" \
userid=mail \
idp="${IDP_METADATA_FILE}" \
trusted_sp="${TRUSTED_SP}" \
grace=2147483647 \
only_from=127.0.0.1,::1
RC=$?
if [[ $RC -ne 0 ]]; then
echo "An error occured in the test, aborting."
break
fi
done
END=$(date +%s)
if [[ $RC -eq 0 ]]; then
echo "Duration for $ITERATIONS iterations: $(( END-START ))s"
fi
echo "================================================================================"
rm -f "${IDP_METADATA_FILE}"
exit $RC