Skip to content

Commit

Permalink
fix test for rule.rate_limit_options.enforce_on_key
Browse files Browse the repository at this point in the history
  • Loading branch information
imrannayer committed Oct 17, 2023
1 parent 5b0aa2b commit 8ecf52b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions docs/upgrading_to_v2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
The v2.0 release contains backwards-incompatible changes.

This update requires upgrading the minimum provider version to `4.79`.

### TPG max version is bumped to 5.x.
In `4.X`, the default value for `rule.rate_limit_options.enforce_on_key` is `ALL`. In `5.X` this field no longer has a default value. If you need `All` you will need to set it explicitly. See [Rule 2](https://github.com/GoogleCloudPlatform/terraform-google-cloud-armor/blob/main/examples/security-policy-all/main.tf) in `examples/security-policy-all` folder for reference.
1 change: 1 addition & 0 deletions examples/security-policy-all/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module "cloud_armor" {
exceed_action = "deny(502)"
rate_limit_http_request_count = 10
rate_limit_http_request_interval_sec = 60
enforce_on_key = "ALL"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestSecurityPolicyAll(t *testing.T) {
assert.Equal("rate_based_ban", sp.Get("action").String(), "priority 3 rule has expected action")
assert.Equal("PHP Sensitivity Level 1 with included rules", sp.Get("description").String(), "priority 3 rule has expected description")
assert.Equal("allow", sp.Get("rateLimitOptions.conformAction").String(), "priority 3 rule has expected Rate limit confirm action")
assert.Equal("ALL", sp.Get("rateLimitOptions.enforceOnKey").String(), "priority 3 rule has expected Rate limit enforce on key")
assert.Equal("", sp.Get("rateLimitOptions.enforceOnKey").String(), "priority 3 rule has expected Rate limit enforce on key")
assert.Equal("deny(502)", sp.Get("rateLimitOptions.exceedAction").String(), "priority 3 rule has expected Rate limit exceed action")
assert.Equal("10", sp.Get("rateLimitOptions.rateLimitThreshold.count").String(), "priority 3 rule has expected Rate limit threshold count")
assert.Equal("60", sp.Get("rateLimitOptions.rateLimitThreshold.intervalSec").String(), "priority 3 rule has expected Rate limit threshold interval")
Expand Down
4 changes: 2 additions & 2 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 4.79.0, < 6.0"
version = ">= 4.79.0, < 6"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.79.0, < 6.0"
version = ">= 4.79.0, < 6"
}
}
provider_meta "google" {
Expand Down

0 comments on commit 8ecf52b

Please sign in to comment.