Skip to content

Commit

Permalink
test: add waf
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Sep 15, 2023
1 parent 2fd04c3 commit cb3611d
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions tests/interface/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,28 @@ 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
statement = "req.url ~ \"^/foo/bar$\""
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
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
# }
}

0 comments on commit cb3611d

Please sign in to comment.