|
|
|
|
@ -31,6 +31,22 @@ func TestAccAWSWafXssMatchSet_basic(t *testing.T) {
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "name", xssMatchSet),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.#", "2"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2018581549.field_to_match.#", "1"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2018581549.field_to_match.2316364334.data", ""),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2018581549.field_to_match.2316364334.type", "QUERY_STRING"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2018581549.text_transformation", "NONE"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2786024938.field_to_match.#", "1"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2786024938.field_to_match.3756326843.data", ""),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2786024938.field_to_match.3756326843.type", "URI"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2786024938.text_transformation", "NONE"),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
@ -92,6 +108,94 @@ func TestAccAWSWafXssMatchSet_disappears(t *testing.T) {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAccAWSWafXssMatchSet_changeTuples(t *testing.T) {
|
|
|
|
|
var before, after waf.XssMatchSet
|
|
|
|
|
setName := fmt.Sprintf("xssMatchSet-%s", acctest.RandString(5))
|
|
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
|
Providers: testAccProviders,
|
|
|
|
|
CheckDestroy: testAccCheckAWSWafXssMatchSetDestroy,
|
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
|
{
|
|
|
|
|
Config: testAccAWSWafXssMatchSetConfig(setName),
|
|
|
|
|
Check: resource.ComposeAggregateTestCheckFunc(
|
|
|
|
|
testAccCheckAWSWafXssMatchSetExists("aws_waf_xss_match_set.xss_match_set", &before),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "name", setName),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.#", "2"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2018581549.field_to_match.#", "1"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2018581549.field_to_match.2316364334.data", ""),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2018581549.field_to_match.2316364334.type", "QUERY_STRING"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2018581549.text_transformation", "NONE"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2786024938.field_to_match.#", "1"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2786024938.field_to_match.3756326843.data", ""),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2786024938.field_to_match.3756326843.type", "URI"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2786024938.text_transformation", "NONE"),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Config: testAccAWSWafXssMatchSetConfig_changeTuples(setName),
|
|
|
|
|
Check: resource.ComposeAggregateTestCheckFunc(
|
|
|
|
|
testAccCheckAWSWafXssMatchSetExists("aws_waf_xss_match_set.xss_match_set", &after),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "name", setName),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.#", "2"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2893682529.field_to_match.#", "1"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2893682529.field_to_match.4253810390.data", "GET"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2893682529.field_to_match.4253810390.type", "METHOD"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.2893682529.text_transformation", "HTML_ENTITY_DECODE"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.4270311415.field_to_match.#", "1"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.4270311415.field_to_match.281401076.data", ""),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.4270311415.field_to_match.281401076.type", "BODY"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.4270311415.text_transformation", "CMD_LINE"),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAccAWSWafXssMatchSet_noTuples(t *testing.T) {
|
|
|
|
|
var ipset waf.XssMatchSet
|
|
|
|
|
setName := fmt.Sprintf("xssMatchSet-%s", acctest.RandString(5))
|
|
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
|
Providers: testAccProviders,
|
|
|
|
|
CheckDestroy: testAccCheckAWSWafXssMatchSetDestroy,
|
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
|
{
|
|
|
|
|
Config: testAccAWSWafXssMatchSetConfig_noTuples(setName),
|
|
|
|
|
Check: resource.ComposeAggregateTestCheckFunc(
|
|
|
|
|
testAccCheckAWSWafXssMatchSetExists("aws_waf_xss_match_set.xss_match_set", &ipset),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "name", setName),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"aws_waf_xss_match_set.xss_match_set", "xss_match_tuples.#", "0"),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func testAccCheckAWSWafXssMatchSetDisappears(v *waf.XssMatchSet) resource.TestCheckFunc {
|
|
|
|
|
return func(s *terraform.State) error {
|
|
|
|
|
conn := testAccProvider.Meta().(*AWSClient).wafconn
|
|
|
|
|
@ -232,3 +336,31 @@ resource "aws_waf_xss_match_set" "xss_match_set" {
|
|
|
|
|
}
|
|
|
|
|
}`, name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func testAccAWSWafXssMatchSetConfig_changeTuples(name string) string {
|
|
|
|
|
return fmt.Sprintf(`
|
|
|
|
|
resource "aws_waf_xss_match_set" "xss_match_set" {
|
|
|
|
|
name = "%s"
|
|
|
|
|
xss_match_tuples {
|
|
|
|
|
text_transformation = "CMD_LINE"
|
|
|
|
|
field_to_match {
|
|
|
|
|
type = "BODY"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xss_match_tuples {
|
|
|
|
|
text_transformation = "HTML_ENTITY_DECODE"
|
|
|
|
|
field_to_match {
|
|
|
|
|
type = "METHOD"
|
|
|
|
|
data = "GET"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}`, name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func testAccAWSWafXssMatchSetConfig_noTuples(name string) string {
|
|
|
|
|
return fmt.Sprintf(`
|
|
|
|
|
resource "aws_waf_xss_match_set" "xss_match_set" {
|
|
|
|
|
name = "%s"
|
|
|
|
|
}`, name)
|
|
|
|
|
}
|
|
|
|
|
|