summaryrefslogtreecommitdiffstats
path: root/debian/tests/rlm_python3-test
blob: ddf0982697864c69583e5ac9056020954ba026ab (plain)
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
#!/bin/sh

set -e

cp debian/tests/rlm_python3-data/python3.mods-available \
    /etc/freeradius/3.0/mods-available/python3
cp debian/tests/rlm_python3-data/python3.sites-available \
    /etc/freeradius/3.0/sites-available/python3-test
cp debian/tests/rlm_python3-data/ubuntu_example.py.mods-config \
    /etc/freeradius/3.0/mods-config/python3/ubuntu_example.py

# enable our python3 test site
ln -sf /etc/freeradius/3.0/sites-available/python3-test \
    /etc/freeradius/3.0/sites-enabled

# enable the python3 module
ln -sf /etc/freeradius/3.0/mods-available/python3 \
    /etc/freeradius/3.0/mods-enabled

# restart
systemctl restart freeradius.service

echo "Test that \"ubuntu\" can login with any password"
result=0
output=$(radtest ubuntu anypass$$ 127.0.0.1:1234 0 testing123) || result=$?
if [ ${result} -ne 0 ]; then
    echo "Failed. Output:"
    echo "${output}"
    exit 1
else
    echo "${output}" | grep "Reply-Message"
fi

echo "Test that any other user won't work"
result=0
output=$(radtest otheruser$$ secret$$ 127.0.0.1:1234 0 testing123 2>&1) || result=$?
echo "${output}" | grep "Reply-Message"
if [ ${result} -eq 0 ]; then
    echo "This shouldn't have worked..."
    echo "Output:"
    echo "${output}"
    exit 1
fi