File: functional-tests

package info (click to toggle)
flask-limiter 3.12-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,264 kB
  • sloc: python: 6,432; makefile: 165; sh: 67
file content (43 lines) | stat: -rwxr-xr-x 1,058 bytes parent folder | download | duplicates (3)
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/bash

set -e

function cleanup {
if [ -f ${AUTOPKGTEST_TMP}/memcached.pid ]; then
    echo "Shut down memcached..."
    kill $(cat ${AUTOPKGTEST_TMP}/memcached.pid)
    echo "Done."
fi
}

trap cleanup EXIT

echo "Starting memcached..."
memcached -v -u memcache -d -p 22122 -P ${AUTOPKGTEST_TMP}/memcached.pid || exit 1
echo

for py3vers in $(py3versions -s); do
    echo
    echo "***************************"
    echo "*** Testing with ${py3vers}"
    echo "***************************"
    echo

    ${py3vers} debian/tests/testapp.py &
    FLASK_PID=$!
    sleep 5

    # The /ping endpoint is not rate limited
    curl -v http://127.0.0.1:5000/ping 2>&1 | grep '200 OK'
    curl -v http://127.0.0.1:5000/ping 2>&1 | grep '200 OK'
    curl -v http://127.0.0.1:5000/ping 2>&1 | grep '200 OK'

    # The / endpoint is
    curl -v http://127.0.0.1:5000/ 2>&1 | grep '200 OK'
    curl -v http://127.0.0.1:5000/ 2>&1 | grep '429 TOO MANY REQUESTS'
    sleep 2
    curl -v http://127.0.0.1:5000/ 2>&1 | grep '200 OK'

    kill ${FLASK_PID}
    echo
done