From cb3611d0ee00432d589eda519474516e1f982ab0 Mon Sep 17 00:00:00 2001 From: Integralist Date: Fri, 15 Sep 2023 17:24:32 +0100 Subject: [PATCH] test: add waf --- tests/interface/main.tf | 43 ++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/tests/interface/main.tf b/tests/interface/main.tf index 9f6cea054..e75554ef7 100644 --- a/tests/interface/main.tf +++ b/tests/interface/main.tf @@ -44,6 +44,13 @@ resource "fastly_service_vcl" "interface-test-project" { type = "CACHE" } + condition { + name = "test_prefetch_condition" + priority = 15 + statement = "req.url~+\"index.html\"" + type = "PREFETCH" + } + condition { name = "test_req_condition" priority = 5 @@ -51,6 +58,14 @@ resource "fastly_service_vcl" "interface-test-project" { type = "REQUEST" } + # Required for `waf` to work with no diff (see waf test file for details). + condition { + name = "test_req_condition_ALWAYS_FALSE" + priority = 10 + statement = "!req.url" + type = "REQUEST" + } + condition { name = "test_res_condition" priority = 10 @@ -151,13 +166,13 @@ resource "fastly_service_vcl" "interface-test-project" { # } request_setting { - action = "pass" - bypass_busy_wait = true - default_host = "interface-test-project.fastly-terraform.com" - force_miss = true - force_ssl = false - geo_headers = false # DEPRECATED - # hash_keys = "test_request_setting" # Omitted because of error... Syntax error: Expected string variable or constant + action = "pass" + bypass_busy_wait = true + default_host = "interface-test-project.fastly-terraform.com" + force_miss = true + force_ssl = false + geo_headers = false # DEPRECATED + hash_keys = "req.url.path, req.http.host" # Omitted because of error... Syntax error: Expected string variable or constant max_stale_age = "300" name = "test_request_setting" request_condition = "test_req_condition" @@ -175,6 +190,14 @@ resource "fastly_service_vcl" "interface-test-project" { status = 200 } + response_object { + content = "content" + name = "test_response_object_waf" + request_condition = "test_req_condition_ALWAYS_FALSE" + response = "Forbidden" + status = "403" + } + snippet { content = "if ( req.url ) { set req.http.different-header = \"true\"; }" name = "recv_test" @@ -187,4 +210,10 @@ resource "fastly_service_vcl" "interface-test-project" { main = true name = "test_vcl" } + + # waf { + # disabled = false + # prefetch_condition = "test_prefetch_condition" + # response_object = "test_response_object_waf" + # } }