TESTS: add regression tests for ACL and sample expression parsers

These ones trigger each of the error messages in the code about
argument and converters syntax.
This commit is contained in:
Willy Tarreau 2013-12-13 01:32:09 +01:00
parent adaddc21ee
commit 1d7ca2ec1f
3 changed files with 114 additions and 0 deletions

36
tests/test-acl-args.cfg Normal file
View File

@ -0,0 +1,36 @@
# This config file aims to trigger all error detection cases in the ACL
# expression parser related to the fetch arguments.
# silence some warnings
defaults
mode http
timeout client 1s
timeout server 1s
timeout connect 1s
frontend 1
bind :10000
# missing fetch method in ACL expression '(arg)'.
block if { (arg) }
# unknown fetch method 'blah' in ACL expression 'blah(arg)'.
block if { blah(arg) }
# missing closing ')' after arguments to fetch keyword 'req.hdr' in ACL expression 'req.hdr('.
block if { req.hdr( }
# cannot be triggerred : "returns type of fetch method '%s' is unknown"
# fetch method 'always_true' : no argument supported, but got 'arg' in ACL expression 'always_true(arg)'.
block if { always_true(arg) }
# fetch method 'req.hdr' : failed to parse 'a' as type 'signed integer' at position 2 in ACL expression 'req.hdr(a,a)'.
block if { req.hdr(a,a) }
# in argument to 'payload_lv', payload length must be > 0.
block if { payload_lv(0,0) }
# ACL keyword 'payload_lv' : expected type 'unsigned integer' at position 1, but got nothing.
block if { payload_lv }

View File

@ -0,0 +1,36 @@
# This config file aims to trigger all error detection cases in the sample
# fetch expression parser related to the fetch arguments.
# silence some warnings
defaults
mode http
timeout client 1s
timeout server 1s
timeout connect 1s
frontend 1
bind :10000
# missing fetch method
http-request add-header name %[(arg)]
# unknown fetch method 'blah'
http-request add-header name %[blah(arg)]
# missing closing ')' after arguments to fetch keyword 'req.hdr'
http-request add-header name %[req.hdr(]
# cannot be triggerred : "returns type of fetch method '%s' is unknown"
# fetch method 'always_true' : no argument supported, but got 'arg'
http-request add-header name %[always_true(arg)]
# fetch method 'req.hdr' : failed to parse 'a' as 'signed integer' at position 2
http-request add-header name %[req.hdr(a,a)]
# invalid args in fetch method 'payload_lv' : payload length must be > 0
http-request add-header name %[payload_lv(0,0)]
# fetch method 'payload_lv' : expected type 'unsigned integer' at position 1, but got nothing
http-request add-header name %[payload_lv]

View File

@ -0,0 +1,42 @@
# This config file aims to trigger all error detection cases in the sample
# fetch expression parser related to the sample converters.
# silence some warnings
defaults
mode http
timeout client 1s
timeout server 1s
timeout connect 1s
frontend 1
bind :10000
# report "missing comma after fetch keyword %s"
http-request add-header name %[hdr(arg))]
# report "missing comma after conv keyword %s"
http-request add-header name %[hdr(arg),ipmask(2))]
# report "unknown conv method '%s'"
http-request add-header name %[hdr(arg),blah]
# report "syntax error: missing ')' after conv keyword '%s'"
http-request add-header name %[hdr(arg),ipmask(2]
# no way to report "returns type of conv method '%s' is unknown"
# "conv method '%s' cannot be applied"
http-request add-header name %[wait_end,ipmask(2)]
# "conv method '%s' does not support any args"
http-request add-header name %[hdr(arg),upper()]
# "invalid arg %d in conv method '%s' : %s"
http-request add-header name %[hdr(arg),ipmask(a)]
# "invalid args in conv method '%s' : %s"
http-request add-header name %[hdr(arg),map()]
# "missing args for conv method '%s'"
http-request add-header name %[hdr(arg),ipmask]