@@ -54,3 +54,95 @@ data "datadog_synthetics_global_variable" "my_variable" {
5454 name = "%s"
5555}` , testAccDatadogSyntheticsGlobalVariableConfig (uniq ), uniq )
5656}
57+
58+ func TestAccDatadogSyntheticsGlobalVariable_ParseTestOptions (t * testing.T ) {
59+ t .Parallel ()
60+ ctx , providers , accProviders := testAccFrameworkMuxProviders (ctx , t )
61+
62+ // Generate a unique name to avoid conflicts
63+ uniq := uniqueEntityName (ctx , t )
64+ accProvider := testAccProvider (t , providers )
65+
66+ resource .Test (t , resource.TestCase {
67+ ProtoV5ProviderFactories : accProviders ,
68+ PreCheck : func () { testAccPreCheck (t ) },
69+ Steps : []resource.TestStep {
70+ {
71+ Config : testAccCheckDatadogSyntheticsGlobalVariableParseTestOptions (uniq ),
72+ Check : resource .ComposeTestCheckFunc (
73+ testAccCheckDatadogSyntheticsGlobalVariableExists (accProvider , "datadog_synthetics_global_variable.foo" ),
74+ resource .TestCheckResourceAttr (
75+ "datadog_synthetics_global_variable.foo" , "name" , uniq ),
76+ resource .TestCheckResourceAttr (
77+ "datadog_synthetics_global_variable.foo" , "value" , "secret_value" ),
78+ resource .TestCheckResourceAttr (
79+ "datadog_synthetics_global_variable.foo" , "secure" , "true" ),
80+ resource .TestCheckResourceAttr (
81+ "datadog_synthetics_global_variable.foo" , "parse_test_id" , "public-abc123" ),
82+ resource .TestCheckResourceAttr (
83+ "datadog_synthetics_global_variable.foo" , "parse_test_options.#" , "1" ),
84+ resource .TestCheckResourceAttr (
85+ "datadog_synthetics_global_variable.foo" , "parse_test_options.0.field" , "auth_token" ),
86+ resource .TestCheckResourceAttr (
87+ "datadog_synthetics_global_variable.foo" , "parse_test_options.0.type" , "http_header" ),
88+ resource .TestCheckResourceAttr (
89+ "datadog_synthetics_global_variable.foo" , "parse_test_options.0.parser.#" , "1" ),
90+ resource .TestCheckResourceAttr (
91+ "datadog_synthetics_global_variable.foo" , "parse_test_options.0.parser.0.type" , "regex" ),
92+ resource .TestCheckResourceAttr (
93+ "datadog_synthetics_global_variable.foo" , "parse_test_options.0.parser.0.value" , "token=([a-f0-9]+)" ),
94+ ),
95+ },
96+ {
97+ Config : testAccCheckDatadogSyntheticsGlobalVariableParseTestOptionsUpdated (uniq ),
98+ Check : resource .ComposeTestCheckFunc (
99+ testAccCheckDatadogSyntheticsGlobalVariableExists (accProvider , "datadog_synthetics_global_variable.foo" ),
100+ resource .TestCheckResourceAttr (
101+ "datadog_synthetics_global_variable.foo" , "parse_test_options.0.field" , "new_auth_token" ),
102+ resource .TestCheckResourceAttr (
103+ "datadog_synthetics_global_variable.foo" , "parse_test_options.0.parser.0.value" , "new_token=([a-f0-9]+)" ),
104+ ),
105+ },
106+ },
107+ })
108+ }
109+
110+ func testAccCheckDatadogSyntheticsGlobalVariableParseTestOptions (name string ) string {
111+ return fmt .Sprintf (`
112+ resource "datadog_synthetics_global_variable" "foo" {
113+ name = "%s"
114+ value = "secret_value"
115+ secure = true
116+ parse_test_id = "public-abc123"
117+
118+ parse_test_options {
119+ field = "auth_token"
120+ type = "http_header"
121+ parser {
122+ type = "regex"
123+ value = "token=([a-f0-9]+)"
124+ }
125+ }
126+ }
127+ ` , name )
128+ }
129+
130+ func testAccCheckDatadogSyntheticsGlobalVariableParseTestOptionsUpdated (name string ) string {
131+ return fmt .Sprintf (`
132+ resource "datadog_synthetics_global_variable" "foo" {
133+ name = "%s"
134+ value = "secret_value"
135+ secure = true
136+ parse_test_id = "public-abc123"
137+
138+ parse_test_options {
139+ field = "new_auth_token"
140+ type = "http_header"
141+ parser {
142+ type = "regex"
143+ value = "new_token=([a-f0-9]+)"
144+ }
145+ }
146+ }
147+ ` , name )
148+ }
0 commit comments