From 59762f627afa1c0fda3c9788199257fd26879e15 Mon Sep 17 00:00:00 2001 From: Jan Schumann Date: Fri, 21 Jun 2024 12:59:12 +0200 Subject: [PATCH] add tests Signed-off-by: Jan Schumann --- ...ixadc_appfwprofile_sqlinjection_binding.go | 8 ++- ..._appfwprofile_sqlinjection_binding_test.go | 56 +++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/citrixadc/resource_citrixadc_appfwprofile_sqlinjection_binding.go b/citrixadc/resource_citrixadc_appfwprofile_sqlinjection_binding.go index 86c9ae80a..497a30641 100644 --- a/citrixadc/resource_citrixadc_appfwprofile_sqlinjection_binding.go +++ b/citrixadc/resource_citrixadc_appfwprofile_sqlinjection_binding.go @@ -209,8 +209,12 @@ func deleteAppfwprofile_sqlinjection_bindingFunc(d *schema.ResourceData, meta in args["sqlinjection"] = sqlinjection args["formactionurl_sql"] = url.QueryEscape(d.Get("formactionurl_sql").(string)) args["as_scan_location_sql"] = d.Get("as_scan_location_sql").(string) - args["as_value_type_sql"] = d.Get("as_value_type_sql").(string) - args["as_value_expr_sql"] = d.Get("as_value_expr_sql").(string) + if val, ok := d.GetOk("as_value_type_sql"); ok { + args["as_value_type_sql"] = val.(string) + } + if val, ok := d.GetOk("as_value_expr_sql"); ok { + args["as_value_expr_sql"] = val.(string) + } err := client.DeleteResourceWithArgsMap(service.Appfwprofile_sqlinjection_binding.Type(), appFwName, args) if err != nil { diff --git a/citrixadc/resource_citrixadc_appfwprofile_sqlinjection_binding_test.go b/citrixadc/resource_citrixadc_appfwprofile_sqlinjection_binding_test.go index 719551587..1c74baf89 100644 --- a/citrixadc/resource_citrixadc_appfwprofile_sqlinjection_binding_test.go +++ b/citrixadc/resource_citrixadc_appfwprofile_sqlinjection_binding_test.go @@ -69,6 +69,51 @@ const testAccAppfwprofile_sqlinjection_binding_basic = ` } ` +const testAccAppfwprofile_sqlinjection_binding_as_value_type_sql = ` + resource citrixadc_appfwprofile_sqlinjection_binding demo_as_value_type_sql_binding { + name = citrixadc_appfwprofile.demo_appfw_as_value_type_sql.name + sqlinjection= "demo_binding" + as_scan_location_sql= "HEADER" + as_value_type_sql= "Keyword" + as_value_expr_sql= "example1" + formactionurl_sql= "www.example.com" + state= "ENABLED" + isregex_sql= "NOTREGEX" + } + + resource citrixadc_appfwprofile demo_appfw_as_value_type_sql { + name = "demo_appfw_as_value_type_sql" + bufferoverflowaction = ["none"] + contenttypeaction = ["none"] + cookieconsistencyaction = ["none"] + creditcard = ["none"] + creditcardaction = ["none"] + crosssitescriptingaction = ["none"] + csrftagaction = ["none"] + denyurlaction = ["none"] + dynamiclearning = ["none"] + fieldconsistencyaction = ["none"] + fieldformataction = ["none"] + fileuploadtypesaction = ["none"] + inspectcontenttypes = ["none"] + jsondosaction = ["none"] + jsonsqlinjectionaction = ["none"] + jsonxssaction = ["none"] + multipleheaderaction = ["none"] + sqlinjectionaction = ["none"] + starturlaction = ["none"] + type = ["HTML"] + xmlattachmentaction = ["none"] + xmldosaction = ["none"] + xmlformataction = ["none"] + xmlsoapfaultaction = ["none"] + xmlsqlinjectionaction = ["none"] + xmlvalidationaction = ["none"] + xmlwsiaction = ["none"] + xmlxssaction = ["none"] + } +` + func TestAccAppfwprofile_sqlinjection_binding_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -84,6 +129,17 @@ func TestAccAppfwprofile_sqlinjection_binding_basic(t *testing.T) { resource.TestCheckResourceAttr("citrixadc_appfwprofile_sqlinjection_binding.demo_binding", "formactionurl_sql", "www.example.com"), ), }, + { + Config: testAccAppfwprofile_sqlinjection_binding_as_value_type_sql, + Check: resource.ComposeTestCheckFunc( + testAccCheckAppfwprofile_sqlinjection_bindingExist("citrixadc_appfwprofile_sqlinjection_binding.demo_as_value_type_sql_binding", nil), + resource.TestCheckResourceAttr("citrixadc_appfwprofile_sqlinjection_binding.demo_as_value_type_sql_binding", "name", "demo_appfw_as_value_type_sql"), + resource.TestCheckResourceAttr("citrixadc_appfwprofile_sqlinjection_binding.demo_as_value_type_sql_binding", "as_scan_location_sql", "HEADER"), + resource.TestCheckResourceAttr("citrixadc_appfwprofile_sqlinjection_binding.demo_as_value_type_sql_binding", "formactionurl_sql", "www.example.com"), + resource.TestCheckResourceAttr("citrixadc_appfwprofile_sqlinjection_binding.demo_as_value_type_sql_binding", "as_value_type_sql", "Keyword"), + resource.TestCheckResourceAttr("citrixadc_appfwprofile_sqlinjection_binding.demo_as_value_type_sql_binding", "as_value_expr_sql", "example1"), + ), + }, }, }) }