Skip to content

Commit

Permalink
Merge pull request #930 from F5Networks/devel_vendor_12022024
Browse files Browse the repository at this point in the history
vendor sync changes
  • Loading branch information
RavinderReddyF5 authored Feb 12, 2024
2 parents 29a7722 + 612a0b9 commit 2b1f70f
Show file tree
Hide file tree
Showing 14 changed files with 183 additions and 171 deletions.
8 changes: 4 additions & 4 deletions bigip/resource_bigip_ltm_profile_bot_defense.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ func resourceBigipLtmProfileBotDefense() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
"relaxed",
"enabled"}, false),
Description: "Enables or disables Bot Defense. The default is `disabled`",
"relaxed", "balanced", "strict"}, false),
Description: "Profile templates specify Mitigation and Verification Settings default values. possible ptions `balanced`,`relaxed` and `strict`",
},
"enforcement_mode": {
Type: schema.TypeString,
Expand All @@ -61,7 +61,7 @@ func resourceBigipLtmProfileBotDefense() *schema.Resource {
ValidateFunc: validation.StringInSlice([]string{
"transparent",
"blocking"}, false),
Description: "Specifies the protocol to be used for high-speed logging of requests. The default is `mds-udp`",
Description: "Select the enforcement mode, possible values are `transparent` and `blocking`.",
},
},
}
Expand Down
6 changes: 2 additions & 4 deletions bigip/resource_bigip_ltm_profile_bot_defense_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,10 @@ func testCheckBotDefensesDestroyed(s *terraform.State) error {
}

func testaccbigipltmprofileBotDefenseDefaultConfig(partition, profileName, resourceName string) string {
return fmt.Sprintf(`
resource "bigip_ltm_profile_bot_defence" "%[3]s" {
return fmt.Sprintf(`resource "bigip_ltm_profile_bot_defence" "%[3]s" {
name = "%[2]s"
defaults_from = "/%[1]s/bot-defense"
description = "test-bot"
template = "relaxed"
}
`, partition, profileName, resourceName)
}`, partition, profileName, resourceName)
}
12 changes: 4 additions & 8 deletions bigip/resource_bigip_ltm_profile_request_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,29 +136,25 @@ resource "%[4]s" "%[3]s" {
}

func testAccBigipLtmProfileRequestLogTC2Config(partition, profileName, resourceName string) string {
return fmt.Sprintf(`
resource "%[4]s" "%[3]s" {
return fmt.Sprintf(`resource "%[4]s" "%[3]s" {
name = "%[2]s"
defaults_from = "/%[1]s/request-log"
request_logging = "disabled"
requestlog_protocol = "mds-tcp"
requestlog_error_protocol = "mds-tcp"
responselog_protocol = "mds-tcp"
responselog_error_protocol = "mds-tcp"
}
`, partition, profileName, resourceName, resRequestLogName)
}`, partition, profileName, resourceName, resRequestLogName)
}

func testAccBigipLtmProfileRequestLogTC2UpdateConfig(partition, profileName, resourceName string) string {
return fmt.Sprintf(`
resource "%[4]s" "%[3]s" {
return fmt.Sprintf(`resource "%[4]s" "%[3]s" {
name = "%[2]s"
defaults_from = "/%[1]s/request-log"
request_logging = "enabled"
requestlog_protocol = "mds-udp"
requestlog_error_protocol = "mds-udp"
responselog_protocol = "mds-udp"
responselog_error_protocol = "mds-udp"
}
`, partition, profileName, resourceName, resRequestLogName)
}`, partition, profileName, resourceName, resRequestLogName)
}
89 changes: 39 additions & 50 deletions bigip/resource_bigip_ltm_profile_rewrite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TestAccLtmRewriteProfileCreateOnBigipTC1(t *testing.T) {
Config: getLtmRewritePortalProfileConfig(),
Check: resource.ComposeTestCheckFunc(
testLtmRewriteProfileExists("/Common/tf_profile-tc1", true),
testLtmRewriteProfileExists("/Common/tf_profile-tc11", false),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "rewrite_mode", "portal"),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "cache_type", "cache-img-css-js"),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "ca_file", "/Common/ca-bundle.crt"),
Expand All @@ -37,21 +38,6 @@ func TestAccLtmRewriteProfileCreateOnBigipTC1(t *testing.T) {
},
})
}

func getLtmRewritePortalProfileConfig() string {
return fmt.Sprintf(`
resource "bigip_ltm_profile_rewrite" "test-profile" {
name = "%v"
defaults_from = "/Common/rewrite"
rewrite_mode = "portal"
cache_type = "cache-img-css-js"
ca_file = "/Common/ca-bundle.crt"
signing_cert = "/Common/default.crt"
signing_key = "/Common/default.key"
split_tunneling = "false"
}`, "/Common/tf_profile-tc1")
}

func TestAccLtmRewriteProfileCreateOnBigipTC2(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
Expand Down Expand Up @@ -130,41 +116,46 @@ func TestAccLtmRewriteProfileCreateOnBigipTC3(t *testing.T) {
})
}

func getLtmRewritePortalProfileConfig() string {
return fmt.Sprintf(`resource "bigip_ltm_profile_rewrite" "test-profile" {
name = "/Common/%v"
defaults_from = "/Common/rewrite"
rewrite_mode = "portal"
cache_type = "cache-img-css-js"
ca_file = "/Common/ca-bundle.crt"
signing_cert = "/Common/default.crt"
signing_key = "/Common/default.key"
split_tunneling = "false"}`, "tf_profile-tc1")
}
func getLtmRewriteUriRewriteProfileConfig() string {
return fmt.Sprintf(`
resource "bigip_ltm_profile_rewrite" "test-profile2" {
name = "%v"
defaults_from = "/Common/rewrite"
rewrite_mode = "uri-translation"
request {
insert_xfwd_for = "enabled"
insert_xfwd_host = "disabled"
insert_xfwd_protocol = "enabled"
}
cookie_rules {
rule_name = "cookie1"
client_domain = "wrong.com"
client_path = "/this/"
server_domain = "right.com"
server_path = "/that/"
}
cookie_rules {
rule_name = "cookie2"
client_domain = "incorrect.com"
client_path = "/this/"
server_domain = "absolute.com"
server_path = "/that/"
}
}
`, "/Common/tf_profile_translate")
return fmt.Sprintf(`resource "bigip_ltm_profile_rewrite" "test-profile2" {
name = "%v"
defaults_from = "/Common/rewrite"
rewrite_mode = "uri-translation"
request {
insert_xfwd_for = "enabled"
insert_xfwd_host = "disabled"
insert_xfwd_protocol = "enabled"
}
cookie_rules {
rule_name = "cookie1"
client_domain = "wrong.com"
client_path = "/this/"
server_domain = "right.com"
server_path = "/that/"
}
cookie_rules {
rule_name = "cookie2"
client_domain = "incorrect.com"
client_path = "/this/"
server_domain = "absolute.com"
server_path = "/that/"
}
}`, "/Common/tf_profile_translate")
}

func getLtmRewriteUriRewriteProfileConfigChanged() string {
return fmt.Sprintf(`
resource "bigip_ltm_profile_rewrite" "test-profile2" {
return fmt.Sprintf(`resource "bigip_ltm_profile_rewrite" "test-profile2" {
name = "%v"
request {
Expand All @@ -180,10 +171,8 @@ func getLtmRewriteUriRewriteProfileConfigChanged() string {
server_domain = "totallyright.com"
server_path = "/those/"
}
}
`, "/Common/tf_profile_translate")
}`, "/Common/tf_profile_translate")
}

func testLtmRewriteProfileExists(name string, exists bool) resource.TestCheckFunc {
return func(s *terraform.State) error {
client := testAccProvider.Meta().(*bigip.BigIP)
Expand Down
8 changes: 3 additions & 5 deletions bigip/resource_bigip_ltm_profile_rewrite_uri_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ package bigip
import (
"context"
"fmt"
"log"

bigip "github.com/f5devcentral/go-bigip"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"log"
)

func resourceBigipLtmRewriteProfileUriRules() *schema.Resource {
Expand Down Expand Up @@ -184,8 +185,7 @@ func resourceBigipLtmProfileRewriteUriRuleDelete(ctx context.Context, d *schema.
d.SetId("")
return nil
}

func setUriRulesData(d *schema.ResourceData, data *bigip.RewriteProfileUriRule) diag.Diagnostics {
func setUriRulesData(d *schema.ResourceData, data *bigip.RewriteProfileUriRule) {
_ = d.Set("rule_name", data.Name)
_ = d.Set("rule_type", data.Type)

Expand All @@ -206,8 +206,6 @@ func setUriRulesData(d *schema.ResourceData, data *bigip.RewriteProfileUriRule)
srv["port"] = data.Server.Port
srvList = append(srvList, srv)
_ = d.Set("server", srvList)

return nil
}

func getUriRulesConfig(d *schema.ResourceData, config *bigip.RewriteProfileUriRule) *bigip.RewriteProfileUriRule {
Expand Down
7 changes: 3 additions & 4 deletions bigip/resource_bigip_ltm_profile_rewrite_uri_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ package bigip

import (
"fmt"
"github.com/f5devcentral/go-bigip"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"testing"

"github.com/f5devcentral/go-bigip"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

var rewPorfile = fmt.Sprintf("/%s/%s", TestPartition, "tf_profile")
var rule1 = fmt.Sprintf("tf_rule")

var rule1 = "tf_rule"
var TestProfileResource = `
resource "bigip_ltm_profile_rewrite" "tftest" {
name = "` + rewPorfile + `"
Expand Down
43 changes: 43 additions & 0 deletions docs/resources/bigip_ltm_profile_bot_defence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
layout: "bigip"
page_title: "BIG-IP: bigip_ltm_profile_bot_defense"
subcategory: "Local Traffic Manager(LTM)"
description: |-
Provides details about bigip_ltm_profile_bot_defense resource
---

# bigip\_ltm\_profile\_bot\_defense

`bigip_ltm_profile_bot_defense` Resource used for Configures a Bot Defense profile.

## Example Usage

```hcl
resource "bigip_ltm_profile_bot_defense" "test-bot-tc1" {
name = "/Common/test-bot-tc1"
defaults_from = "/Common/bot-defense"
description = "test-bot"
template = "relaxed"
}
```

## Argument Reference

* `name` (Required,type `string`) Name of the Bot Defense profile,name of Profile should be full path. Full path is the combination of the `partition + profile name`,For example `/Common/test-bot-tc1`.

* `defaults_from` - (optional,type `string`) Specifies the profile from which this profile inherits settings. The default is the system-supplied `bot-defense` profile.

* `description` - (optional,type `string`) Specifies user-defined description.

* `template` - (Optional,type `string`) Profile templates specify Mitigation and Verification Settings default values. possible ptions `balanced`,`relaxed` and `strict`.

* `enforcement_mode` - (Optional,type `string`) Select the enforcement mode, possible values are `transparent` and `blocking`.


## Import

BIG-IP LTM Bot Defense profile can be imported using the `name`, e.g.

```bash
terraform import bigip_ltm_profile_bot_defense.test-bot /Common/testbotprofile01
```
39 changes: 17 additions & 22 deletions docs/resources/bigip_ltm_profile_rewrite.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,43 @@ For resources should be named with their `full path`. The full path is the combi
## Example Usage

```hcl
resource "bigip_ltm_profile_rewrite" "test-profile" {
name = "/Common/tf_profile"
defaults_from = "/Common/rewrite"
bypass_list = ["http://notouch.com"]
rewrite_list = ["http://some.com"]
rewrite_mode = "portal"
cache_type = "cache-img-css-js"
ca_file = "/Common/ca-bundle.crt"
crl_file = "none"
signing_cert = "/Common/default.crt"
signing_key = "/Common/default.key"
name = "/Common/tf_profile"
defaults_from = "/Common/rewrite"
bypass_list = ["http://notouch.com"]
rewrite_list = ["http://some.com"]
rewrite_mode = "portal"
cache_type = "cache-img-css-js"
ca_file = "/Common/ca-bundle.crt"
crl_file = "none"
signing_cert = "/Common/default.crt"
signing_key = "/Common/default.key"
split_tunneling = "true"
}
resource "bigip_ltm_profile_rewrite" "test-profile2" {
name = "/Common/tf_profile_translate"
name = "/Common/tf_profile_translate"
defaults_from = "/Common/rewrite"
rewrite_mode = "uri-translation"
rewrite_mode = "uri-translation"
request {
insert_xfwd_for = "enabled"
insert_xfwd_host = "disabled"
insert_xfwd_for = "enabled"
insert_xfwd_host = "disabled"
insert_xfwd_protocol = "enabled"
rewrite_headers = "disabled"
rewrite_headers = "disabled"
}
response {
rewrite_content = "enabled"
rewrite_headers = "disabled"
}
cookie_rules {
rule_name = "cookie1"
rule_name = "cookie1"
client_domain = "wrong.com"
client_path = "/this/"
server_domain = "wrong.com"
server_path = "/this/"
}
cookie_rules {
rule_name = "cookie2"
rule_name = "cookie2"
client_domain = "incorrect.com"
client_path = "/this/"
server_domain = "absolute.com"
Expand Down
Loading

0 comments on commit 2b1f70f

Please sign in to comment.