Skip to content

Commit

Permalink
testing starts
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtek0806 committed Feb 2, 2024
1 parent 4836ab9 commit 667723a
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 17 deletions.
5 changes: 3 additions & 2 deletions bigip/resource_bigip_ltm_profile_rewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ func resourceBigipLtmRewriteProfile() *schema.Resource {
},
"cache_type": {
Type: schema.TypeString,
Required: true,
Description: "Specifies the type of Client caching.",
Optional: true,
Default: "cache-img-css-js",
Description: "Specifies the type of client caching.",
ValidateFunc: validation.StringInSlice([]string{"cache-css-js", "cache-all", "no-cache", "cache-img-css-js"}, false),
},
"ca_file": {
Expand Down
75 changes: 62 additions & 13 deletions bigip/resource_bigip_ltm_profile_rewrite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

func TestAccLtmRewriteProfileCreateOnBigip(t *testing.T) {
func TestAccLtmRewriteProfileCreateOnBigipTC1(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAcctPreCheck(t)
Expand All @@ -24,7 +24,7 @@ func TestAccLtmRewriteProfileCreateOnBigip(t *testing.T) {
CheckDestroy: testCheckLtmRewriteProfileDestroyed,
Steps: []resource.TestStep{
{
Config: getLtmRewriteProfileConfig(),
Config: getLtmRewritePortalProfileConfig(),
Check: resource.ComposeTestCheckFunc(
testLtmRewriteProfileExists("/Common/tf_profile", true),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "rewrite_mode", "portal"),
Expand All @@ -37,34 +37,83 @@ func TestAccLtmRewriteProfileCreateOnBigip(t *testing.T) {
})
}

func getLtmRewriteProfileConfig() string {
func getLtmRewritePortalProfileConfig() string {
return fmt.Sprintf(`
resource "bigip_ltm_profile_rewrite" "test-profile" {
name = "%v"
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 = "false"
}
`, "/Common/tf_profile")
}

func TestAccLtmRewriteProfileCreateOnBigipTC2(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAcctPreCheck(t)
},
Providers: testAccProviders,
CheckDestroy: testCheckLtmRewriteProfileDestroyed,
Steps: []resource.TestStep{
{
Config: getLtmRewriteUriRewriteProfileConfig(),
Check: resource.ComposeTestCheckFunc(
testLtmRewriteProfileExists("/Common/tf_profile_translate", true),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "rewrite_mode", "uri-translation"),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "request.0.insert_xfwd_for", "enabled"),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "request.0.insert_xfwd_host", "disabled"),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "request.0.insert_xfwd_protocol", "enabled"),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "cookie_rules.0.rule_name", "cookie1"),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "cookie_rules.0.client_domain", "wrong.com"),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "cookie_rules.0.client_path", "/this/"),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "cookie_rules.0.server_domain", "right.com"),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "cookie_rules.0.server_path", "/that/"),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "cookie_rules.1.rule_name", "cookie2"),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "cookie_rules.1.client_domain", "incorrect.com"),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "cookie_rules.1.client_path", "/this/"),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "cookie_rules.1.server_domain", "absolute.com"),
resource.TestCheckResourceAttr("bigip_ltm_profile_rewrite.test-profile", "cookie_rules.1.server_path", "/that/"),
),
},
},
})
}

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"
rewrite_headers = "disabled"
}
response {
rewrite_content = "enabled"
rewrite_headers = "disabled"
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")
`, "/Common/tf_profile_translate")
}

func testLtmRewriteProfileExists(name string, exists bool) resource.TestCheckFunc {
Expand Down
11 changes: 9 additions & 2 deletions docs/resources/bigip_ltm_profile_rewrite.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ resource "bigip_ltm_profile_rewrite" "test-profile" {
crl_file = "none"
signing_cert = "/Common/default.crt"
signing_key = "/Common/default.key"
split_tunneling = "false"
split_tunneling = "true"
}
resource "bigip_ltm_profile_rewrite" "test-profile2" {
name = "/Common/tf_profile_translate"
defaults_from = "/Common/rewrite"
rewrite_mode = "uri-translation"
request {
insert_xfwd_for = "enabled"
Expand All @@ -40,6 +46,7 @@ resource "bigip_ltm_profile_rewrite" "test-profile" {
rewrite_content = "enabled"
rewrite_headers = "disabled"
}
cookie_rules {
rule_name = "cookie1"
client_domain = "wrong.com"
Expand All @@ -66,7 +73,7 @@ resource "bigip_ltm_profile_rewrite" "test-profile" {

* `bypass_list` - (Optional,type `list`) Specifies a list of URIs to bypass inside a web page when the page is accessed using Portal Access.

* `cache_type` - (Required,type `string`) Specifies the type of Client caching. Valid choices are: `cache-css-js, cache-all, no-cache, cache-img-css-js`
* `cache_type` - (Optional,type `string`) Specifies the type of Client caching. Valid choices are: `cache-css-js, cache-all, no-cache, cache-img-css-js`. Default value: `cache-img-css-js`

* `ca_file` - (Optional, type `string`) Specifies a CA against which to verify signed Java applets signatures. (name should be in full path which is combination of partition and CA file name )

Expand Down

0 comments on commit 667723a

Please sign in to comment.