Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue 955,960 #985

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bigip/resource_bigip_ltm_profile_request_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func resourceBigipLtmProfileRequestLogRead(ctx context.Context, d *schema.Resour
_ = d.Set("requestlog_error_pool", pp.RequestLogErrorPool)
}
if _, ok := d.GetOk("requestlog_template"); ok {
_ = d.Set("requestlog_template", pp.RequestLogTemplate)
_ = d.Set("requestlog_template", strings.ReplaceAll(pp.RequestLogTemplate, `\"`, `"`))
}
if _, ok := d.GetOk("requestlog_protocol"); ok {
_ = d.Set("requestlog_protocol", pp.RequestLogProtocol)
Expand Down Expand Up @@ -262,7 +262,7 @@ func resourceBigipLtmProfileRequestLogRead(ctx context.Context, d *schema.Resour
_ = d.Set("response_logging", pp.RequestLogging)
}
if _, ok := d.GetOk("responselog_template"); ok {
_ = d.Set("responselog_template", pp.RequestLogTemplate)
_ = d.Set("responselog_template", strings.ReplaceAll(pp.ResponseLogTemplate, `\"`, `"`))
}
if _, ok := d.GetOk("requestlog_error_template"); ok {
_ = d.Set("requestlog_error_template", pp.RequestLogTemplate)
Expand Down Expand Up @@ -341,9 +341,9 @@ func getRequestLogProfileConfig(d *schema.ResourceData, config *bigip.RequestLog
config.ResponseLogErrorProtocol = d.Get("responselog_error_protocol").(string)
config.RequestLogging = d.Get("request_logging").(string)
config.ResponseLogging = d.Get("response_logging").(string)
config.RequestLogTemplate = d.Get("requestlog_template").(string)
config.RequestLogTemplate = strings.ReplaceAll(d.Get("requestlog_template").(string), `"`, `\"`)
config.RequestLogErrorTemplate = d.Get("requestlog_error_template").(string)
config.ResponseLogTemplate = d.Get("responselog_template").(string)
config.ResponseLogTemplate = strings.ReplaceAll(d.Get("responselog_template").(string), `"`, `\"`)
config.ResponseLogErrorTemplate = d.Get("responselog_error_template").(string)
config.ProxyResponse = d.Get("proxy_response").(string)
config.ProxyCloseOnError = d.Get("proxyclose_on_error").(string)
Expand Down
37 changes: 37 additions & 0 deletions bigip/resource_bigip_ltm_profile_request_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,32 @@ func TestAccBigipLtmProfileRequestLogTC2(t *testing.T) {
})
}

func TestAccBigipLtmProfileRequestLogTC3(t *testing.T) {
t.Parallel()
var instName = "request-log-profile-tc3"
var testPartition = "Common"
var testRequestLogProfileName = fmt.Sprintf("/%s/%s", testPartition, instName)
resFullName := fmt.Sprintf("%s.%s", resRequestLogName, instName)
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAcctPreCheck(t)
},
Providers: testAccProviders,
CheckDestroy: testCheckProfileRequestLogDestroyed,
Steps: []resource.TestStep{
{
Config: testAccBigipLtmProfileRequestLogTC3Config(testPartition, testRequestLogProfileName, instName),
Check: resource.ComposeTestCheckFunc(
testCheckRequestLogExists(testRequestLogProfileName),
resource.TestCheckResourceAttr(resFullName, "name", testRequestLogProfileName),
resource.TestCheckResourceAttr(resFullName, "requestlog_template", "<134> ${TIME_MSECS} ${TIME_OFFSET} bigip_host=${BIGIP_HOSTNAME} type=request x-client-cert-subject=\"$X-Client-Cert-Subject\""),
resource.TestCheckResourceAttr(resFullName, "responselog_template", "<134> ${TIME_MSECS} ${TIME_OFFSET} bigip_host=${BIGIP_HOSTNAME} type=response x-client-cert-subject=\"$X-Client-Cert-Subject\""),
),
},
},
})
}

func testCheckRequestLogExists(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
client := testAccProvider.Meta().(*bigip.BigIP)
Expand Down Expand Up @@ -147,6 +173,17 @@ func testAccBigipLtmProfileRequestLogTC2Config(partition, profileName, resourceN
}`, partition, profileName, resourceName, resRequestLogName)
}

func testAccBigipLtmProfileRequestLogTC3Config(partition, profileName, resourceName string) string {
return fmt.Sprintf(`resource "%[4]s" "%[3]s" {
name = "%[2]s"
defaults_from = "/%[1]s/request-log"
request_logging = "enabled"
requestlog_template = "<134> $${TIME_MSECS} $${TIME_OFFSET} bigip_host=$${BIGIP_HOSTNAME} type=request x-client-cert-subject=\"$X-Client-Cert-Subject\""
response_logging = "enabled"
responselog_template = "<134> $${TIME_MSECS} $${TIME_OFFSET} bigip_host=$${BIGIP_HOSTNAME} type=response x-client-cert-subject=\"$X-Client-Cert-Subject\""
}`, partition, profileName, resourceName, resRequestLogName)
}

func testAccBigipLtmProfileRequestLogTC2UpdateConfig(partition, profileName, resourceName string) string {
return fmt.Sprintf(`resource "%[4]s" "%[3]s" {
name = "%[2]s"
Expand Down
Loading