#
# $Id: 050_QS_ClientEventLimitCount.htt 2317 2017-11-08 16:36:23Z pbuchbinder $
#
# QS_ErrorResponseCode 503
#
# QS_ClientEventLimitCount 3 10
# QS_ClientIpFromHeader X-Frwd-Address
#
#
# QS_SetEnvIfResBody "Login Failed" QS_Limit
#
INCLUDE scripts/ports
EXEC ./ctl.sh restart -D real_ip -D fromHeader >/dev/null
CLIENT
_EXEC echo "[`date '+%a %b %d %H:%M:%S.000000 %Y'`] [test:notice] [pid $$:tid 0] htt: 052_QS_ClientEventLimitCount.htt" >> logs/error_log
_LOOP 3
_REQ localhost $QS_PORT_BASE
__GET /htt/limit/index.html HTTP/1.1
__Host: localhost
__Req: 01
__X-Frwd-Address: 192.12.32.34
__
_EXPECT . "
Login Failed"
_WAIT
_CLOSE
_END LOOP
_REQ localhost $QS_PORT_BASE
__GET /htt/limit/index.html HTTP/1.1
__Host: localhost
__Connection: keep-alive
__Req: 02
__X-Frwd-Address: 192.12.32.34
__
_EXPECT . "code=067"
_EXPECT . "custom error page"
_EXPECT . "503 Service Unavailable"
_WAIT
_CLOSE
_SLEEP 200
_EXPECT EXEC "mod_qos\(067\): access denied, QS_ClientEventLimitCount rule: event=QS_Limit, max=3, current=3, age=., c=192.12.32.34"
_EXEC tail -1 logs/error_log
_REQ localhost $QS_PORT_BASE
__GET /index.html HTTP/1.1
__Host: localhost
__Req: 21
__X-Frwd-Address: 192.12.32.34
__
_EXPECT . "!this is the root index.html"
_EXPECT . "code=067"
_EXPECT . "custom error page"
_EXPECT . "503 Service Unavailable"
_WAIT
_CLOSE
_REQ localhost $QS_PORT_BASE
__GET /console?action=search&address=192.12.32.34&event=QS_Limit HTTP/1.1
__Host: localhost
__Req: 04
__
_EXPECT . "192.12.32.34 vip=no lowprio=no block=0/0 limit=3/[1]?[09]"
_WAIT
_CLOSE
_REQ localhost $QS_PORT_BASE
__GET /index.html HTTP/1.1
__Host: localhost
__Req: 05
__X-Frwd-Address: 192.12.32.36
__
_EXPECT . "this is the root index.html"
_WAIT
_CLOSE
_REQ localhost $QS_PORT_BASE
__GET /console?action=search&address=192.12.32.36&event=QS_Limit HTTP/1.1
__Host: localhost
__Req: 06
__
_EXPECT . "192.12.32.36 vip=no lowprio=no block=0/0 limit=0/0"
_WAIT
_CLOSE
_REQ localhost $QS_PORT_BASE
__GET /htt/limit/index.html HTTP/1.1
__Host: localhost
__Req: 07
__X-Frwd-Address: fe80::0000:76e5:bff:fed6:df6a
__
_EXPECT . "Login Failed"
_WAIT
_CLOSE
_REQ localhost $QS_PORT_BASE
__GET /console?action=search&address=fe80::76e5:bff:fed6:df6a&event=QS_Limit HTTP/1.1
__Host: localhost
__Req: 08
__
_EXPECT . "fe80::76e5:bff:fed6:df6a vip=no lowprio=no block=0/0 limit=1/[1]?[09]"
_WAIT
_CLOSE
_SLEEP 12000
_REQ localhost $QS_PORT_BASE
__GET /htt/limit/index.html HTTP/1.1
__Host: localhost
__Req: 20
__X-Frwd-Address: 192.12.32.34
__
_EXPECT . "Login Failed"
_WAIT
_CLOSE
_REQ localhost $QS_PORT_BASE
__GET /index.html HTTP/1.1
__Host: localhost
__Req: 21
__X-Frwd-Address: 192.12.32.34
__
_EXPECT . "this is the root index.html"
_WAIT
_CLOSE
END
SERVER $QS_PORT_BASE6
_LOOP 5
_RES
_WAIT
__HTTP/1.1 200 OK
__Content-Type: text/html
__Content-Length: AUTO
__
__
__Login Failed
__
__
__
_CLOSE
_END LOOP
END
BLOCK FINALLY
_EXEC ./ctl.sh restart 2>/dev/null 1>/dev/null
END