From 175231e163d3770fdefdaaa355d96996b11ada8f Mon Sep 17 00:00:00 2001 From: Manuel Sabban Date: Wed, 6 Nov 2024 13:24:26 +0100 Subject: [PATCH] live tests cleanup (#86) * tests cleanup * add configuration for first test --- t/01lua_config.t | 9 ++++-- t/02live.t | 5 ---- t/conf_t/01_conf_crowdsec_nginx_bouncer.conf | 29 ++++++++++++++++++++ 3 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 t/conf_t/01_conf_crowdsec_nginx_bouncer.conf diff --git a/t/01lua_config.t b/t/01lua_config.t index 9c93f18..d17858d 100644 --- a/t/01lua_config.t +++ b/t/01lua_config.t @@ -10,10 +10,15 @@ __DATA__ load_module /usr/share/nginx/modules/ndk_http_module.so; load_module /usr/share/nginx/modules/ngx_http_lua_module.so; ---- http +--- http_config +lua_package_path "./lib/?.lua;;"; +lua_shared_dict crowdsec_cache 50m; + +# luacov -r lcov +# genhtml luacov.report.out -o destination_directory/ init_by_lua_block { cs = require "crowdsec" - local ok, err = cs.init("/etc/crowdsec/bouncers/crowdsec-nginx-bouncer.conf", "crowdsec-nginx-bouncer/v1.0.8") + local ok, err = cs.init("t/conf_t/01_conf_crowdsec_nginx_bouncer.conf", "crowdsec-nginx-bouncer/v1.0.8") if ok == nil then ngx.log(ngx.ERR, "[Crowdsec] " .. err) error() diff --git a/t/02live.t b/t/02live.t index d41726a..b062e42 100644 --- a/t/02live.t +++ b/t/02live.t @@ -31,11 +31,6 @@ init_by_lua_block access_by_lua_block { local cs = require "crowdsec" cs.Allow(ngx.var.remote_addr) - if ngx.var.unix == "1" then - ngx.log(ngx.DEBUG, "[Crowdsec] Unix socket request ignoring...") - else - cs.Allow(ngx.var.remote_addr) - end } server { diff --git a/t/conf_t/01_conf_crowdsec_nginx_bouncer.conf b/t/conf_t/01_conf_crowdsec_nginx_bouncer.conf new file mode 100644 index 0000000..84478dd --- /dev/null +++ b/t/conf_t/01_conf_crowdsec_nginx_bouncer.conf @@ -0,0 +1,29 @@ +APPSEC_URL=http://127.0.0.1:7422 +ENABLED=true +API_URL=http://127.0.0.1:8081 +API_KEY=LFrdL+aiecMTSxpGE9vLkx5sGMwdIpgVovpVMfXp3J0 +CACHE_EXPIRATION=1 +# bounce for all type of remediation that the bouncer can receive from the local API +BOUNCING_ON_TYPE=all +FALLBACK_REMEDIATION=ban +REQUEST_TIMEOUT=3000 +UPDATE_FREQUENCY=10 +# live or stream +MODE=live +# exclude the bouncing on those location +EXCLUDE_LOCATION=/v1/decisions +#those apply for "ban" action +# /!\ REDIRECT_LOCATION and RET_CODE can't be used together. REDIRECT_LOCATION take priority over RET_CODE +BAN_TEMPLATE_PATH=./ban +REDIRECT_LOCATION= +RET_CODE= +#those apply for "captcha" action +#valid providers are recaptcha, hcaptcha, turnstile +CAPTCHA_PROVIDER= +# Captcha Secret Key +SECRET_KEY= +# Captcha Site key +SITE_KEY= +CAPTCHA_TEMPLATE_PATH=/var/lib/crowdsec/lua/templates/captcha.html +CAPTCHA_EXPIRATION=3600 +#METRICS_PERIOD=60