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

[datadog_synthetics_test] Add persistCookies option #2058

Merged
merged 6 commits into from
Aug 18, 2023
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
30 changes: 30 additions & 0 deletions datadog/resource_datadog_integration_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,29 @@ func resourceDatadogIntegrationAzure() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"app_service_plan_filters": {
Description: "String of app service plan tag(s) (in the form `key:value,key:value`) defines a filter that Datadog uses when collecting metrics from Azure. Limit the Azure instances that are pulled into Datadog by using tags. Only hosts that match one of the defined tags are imported into Datadog. For example, `env:production,deploymentgroup:red`.",
Type: schema.TypeString,
Optional: true,
},
"automute": {
Description: "Silence monitors for expected Azure VM shutdowns.",
Type: schema.TypeBool,
Default: false,
Optional: true,
},
"cspm_enabled": {
Description: "Enable Cloud Security Management Misconfigurations for your organization.",
Type: schema.TypeBool,
Default: false,
Optional: true,
},
"custom_metrics_enabled": {
Description: "Enable custom metrics for your organization.",
Type: schema.TypeBool,
Default: false,
Optional: true,
},
}
},
}
Expand Down Expand Up @@ -81,10 +98,17 @@ func resourceDatadogIntegrationAzureRead(ctx context.Context, d *schema.Resource
d.Set("tenant_name", integration.GetTenantName())
d.Set("client_id", integration.GetClientId())
d.Set("automute", integration.GetAutomute())
d.Set("cspm_enabled", integration.GetCspmEnabled())
d.Set("custom_metrics_enabled", integration.GetCustomMetricsEnabled())
hostFilters, exists := integration.GetHostFiltersOk()
if exists {
d.Set("host_filters", hostFilters)
}
appServicePlanFilters, exists := integration.GetAppServicePlanFiltersOk()
if exists {
d.Set("app_service_plan_filters", appServicePlanFilters)
}

return nil
}
}
Expand Down Expand Up @@ -166,8 +190,14 @@ func buildDatadogAzureIntegrationDefinition(terraformDefinition *schema.Resource
// Optional params
hostFilters := terraformDefinition.Get("host_filters")
datadogDefinition.SetHostFilters(hostFilters.(string))
appServicePlanFilters := terraformDefinition.Get("app_service_plan_filters")
datadogDefinition.SetAppServicePlanFilters(appServicePlanFilters.(string))
automute := terraformDefinition.Get("automute")
datadogDefinition.SetAutomute(automute.(bool))
cspmEnabled := terraformDefinition.Get("cspm_enabled")
datadogDefinition.SetCspmEnabled(cspmEnabled.(bool))
customMetricsEnabled := terraformDefinition.Get("custom_metrics_enabled")
datadogDefinition.SetCustomMetricsEnabled(customMetricsEnabled.(bool))

clientSecret, exists := terraformDefinition.GetOk("client_secret")
if exists {
Expand Down
12 changes: 12 additions & 0 deletions datadog/resource_datadog_synthetics_test_.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ func syntheticsTestRequest() *schema.Resource {
Type: schema.TypeString,
},
},
"persist_cookies": {
Description: "Persist cookies across redirects.",
Type: schema.TypeBool,
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -1446,6 +1451,9 @@ func buildSyntheticsAPITestStruct(d *schema.ResourceData) *datadogV1.SyntheticsA
request.SetService("")
}
}
if attr, ok := d.GetOk("request_definition.0.persist_cookies"); ok {
request.SetPersistCookies(attr.(bool))
}

request = *completeSyntheticsTestRequest(request, d.Get("request_headers").(map[string]interface{}), d.Get("request_query").(map[string]interface{}), d.Get("request_basicauth").([]interface{}), d.Get("request_client_certificate").([]interface{}), d.Get("request_proxy").([]interface{}))

Expand Down Expand Up @@ -1516,6 +1524,7 @@ func buildSyntheticsAPITestStruct(d *schema.ResourceData) *datadogV1.SyntheticsA
request.SetTimeout(float64(requestMap["timeout"].(int)))
request.SetAllowInsecure(requestMap["allow_insecure"].(bool))
request.SetFollowRedirects(requestMap["follow_redirects"].(bool))
request.SetPersistCookies(requestMap["persist_cookies"].(bool))
}

request = *completeSyntheticsTestRequest(request, stepMap["request_headers"].(map[string]interface{}), stepMap["request_query"].(map[string]interface{}), stepMap["request_basicauth"].([]interface{}), stepMap["request_client_certificate"].([]interface{}), stepMap["request_proxy"].([]interface{}))
Expand Down Expand Up @@ -2307,6 +2316,9 @@ func buildLocalRequest(request datadogV1.SyntheticsTestRequest) map[string]inter
if request.HasCertificateDomains() {
localRequest["certificate_domains"] = request.GetCertificateDomains()
}
if request.HasPersistCookies() {
localRequest["persist_cookies"] = request.GetPersistCookies()
}

return localRequest
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2021-11-09T17:40:54.549623+01:00
2023-08-16T17:18:45.791320091+02:00
58 changes: 37 additions & 21 deletions datadog/tests/cassettes/TestAccDatadogIntegrationAzure.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-07-19T15:48:49.692076-04:00
2023-08-16T17:18:45.791398158+02:00
33 changes: 17 additions & 16 deletions datadog/tests/cassettes/TestAccDatadogLogsArchiveAzure_basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 1
interactions:
- request:
body: |
{"automute":false,"client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"","tenant_name":"21a1b5da-d412-3ee3-02f8-36a639ec9d80"}
{"app_service_plan_filters":"","automute":false,"client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","cspm_enabled":false,"custom_metrics_enabled":false,"host_filters":"","tenant_name":"0241555f-ba72-8afa-b280-d73e229717b3"}
form: {}
headers:
Accept:
Expand Down Expand Up @@ -31,7 +31,7 @@ interactions:
method: GET
response:
body: |
[{"tenant_name":"21a1b5da-d412-3ee3-02f8-36a639ec9d80","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","host_filters":"","automute":false,"cspm_enabled":false,"custom_metrics_enabled":false,"errors":[],"warnings":[]}]
[{"tenant_name":"0241555f-ba72-8afa-b280-d73e229717b3","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","host_filters":"","app_service_plan_filters":"","automute":false,"cspm_enabled":false,"custom_metrics_enabled":false,"errors":[],"warnings":[]},{"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1692199125","client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear","app_service_plan_filters":"","automute":false,"cspm_enabled":false,"custom_metrics_enabled":false,"errors":[],"warnings":[]},{"tenant_name":"Test-Go-TestAzureCreate-1689984326","client_id":"testc7f6-1234-5678-9101-tt1689984326","host_filters":"","app_service_plan_filters":"","automute":true,"cspm_enabled":false,"custom_metrics_enabled":false,"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[]}]
headers:
Content-Type:
- application/json
Expand All @@ -40,7 +40,7 @@ interactions:
duration: ""
- request:
body: |
{"data":{"attributes":{"destination":{"container":"my-container","integration":{"client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","tenant_id":"21a1b5da-d412-3ee3-02f8-36a639ec9d80"},"path":"/path/blou","storage_account":"storageaccount","type":"azure"},"include_tags":false,"name":"my first azure archive","query":"service:toto","rehydration_max_scan_size_in_gb":null,"rehydration_tags":[]},"type":"archives"}}
{"data":{"attributes":{"destination":{"container":"my-container","integration":{"client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","tenant_id":"0241555f-ba72-8afa-b280-d73e229717b3"},"path":"/path/blou","storage_account":"storageaccount","type":"azure"},"include_tags":false,"name":"my first azure archive","query":"service:toto","rehydration_max_scan_size_in_gb":null,"rehydration_tags":[]},"type":"archives"}}
form: {}
headers:
Accept:
Expand All @@ -51,7 +51,7 @@ interactions:
method: POST
response:
body: |
{"data":{"type":"archives","id":"W3ivJX3uT7CT4lywe_T5zw","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"21a1b5da-d412-3ee3-02f8-36a639ec9d80","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e"}},"rehydration_tags":[],"include_tags":false,"rehydration_max_scan_size_in_gb":null}}}
{"data":{"type":"archives","id":"-GWdZ6m2RhKwHu40SqvtKg","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"0241555f-ba72-8afa-b280-d73e229717b3","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e"}},"rehydration_tags":[],"include_tags":false,"rehydration_max_scan_size_in_gb":null}}}
headers:
Content-Type:
- application/json
Expand All @@ -64,11 +64,11 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v2/logs/config/archives/W3ivJX3uT7CT4lywe_T5zw
url: https://api.datadoghq.com/api/v2/logs/config/archives/-GWdZ6m2RhKwHu40SqvtKg
method: GET
response:
body: |
{"data":{"type":"archives","id":"W3ivJX3uT7CT4lywe_T5zw","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"21a1b5da-d412-3ee3-02f8-36a639ec9d80","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e"}},"rehydration_tags":[],"include_tags":false,"rehydration_max_scan_size_in_gb":null}}}
{"data":{"type":"archives","id":"-GWdZ6m2RhKwHu40SqvtKg","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"0241555f-ba72-8afa-b280-d73e229717b3","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e"}},"rehydration_tags":[],"include_tags":false,"rehydration_max_scan_size_in_gb":null}}}
headers:
Content-Type:
- application/json
Expand All @@ -85,7 +85,7 @@ interactions:
method: GET
response:
body: |
[{"tenant_name":"21a1b5da-d412-3ee3-02f8-36a639ec9d80","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","host_filters":"","automute":false,"cspm_enabled":false,"custom_metrics_enabled":false,"errors":[],"warnings":[]}]
[{"tenant_name":"0241555f-ba72-8afa-b280-d73e229717b3","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","host_filters":"","app_service_plan_filters":"","automute":false,"cspm_enabled":false,"custom_metrics_enabled":false,"errors":[],"warnings":[]},{"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1692199125","client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear","app_service_plan_filters":"","automute":false,"cspm_enabled":false,"custom_metrics_enabled":false,"errors":[],"warnings":[]},{"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1692199125","client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear","app_service_plan_filters":"","automute":false,"cspm_enabled":false,"custom_metrics_enabled":false,"errors":[],"warnings":[]},{"tenant_name":"Test-Go-TestAzureCreate-1689984326","client_id":"testc7f6-1234-5678-9101-tt1689984326","host_filters":"","app_service_plan_filters":"","automute":true,"cspm_enabled":false,"custom_metrics_enabled":false,"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[]}]
headers:
Content-Type:
- application/json
Expand All @@ -98,11 +98,11 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v2/logs/config/archives/W3ivJX3uT7CT4lywe_T5zw
url: https://api.datadoghq.com/api/v2/logs/config/archives/-GWdZ6m2RhKwHu40SqvtKg
method: GET
response:
body: |
{"data":{"type":"archives","id":"W3ivJX3uT7CT4lywe_T5zw","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"21a1b5da-d412-3ee3-02f8-36a639ec9d80","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e"}},"rehydration_tags":[],"include_tags":false,"rehydration_max_scan_size_in_gb":null}}}
{"data":{"type":"archives","id":"-GWdZ6m2RhKwHu40SqvtKg","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"0241555f-ba72-8afa-b280-d73e229717b3","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e"}},"rehydration_tags":[],"include_tags":false,"rehydration_max_scan_size_in_gb":null}}}
headers:
Content-Type:
- application/json
Expand All @@ -115,7 +115,7 @@ interactions:
headers:
Accept:
- '*/*'
url: https://api.datadoghq.com/api/v2/logs/config/archives/W3ivJX3uT7CT4lywe_T5zw
url: https://api.datadoghq.com/api/v2/logs/config/archives/-GWdZ6m2RhKwHu40SqvtKg
method: DELETE
response:
body: ""
Expand All @@ -125,7 +125,7 @@ interactions:
duration: ""
- request:
body: |
{"automute":false,"client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"","tenant_name":"21a1b5da-d412-3ee3-02f8-36a639ec9d80"}
{"app_service_plan_filters":"","automute":false,"client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","cspm_enabled":false,"custom_metrics_enabled":false,"host_filters":"","tenant_name":"0241555f-ba72-8afa-b280-d73e229717b3"}
form: {}
headers:
Accept:
Expand All @@ -149,10 +149,10 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v2/logs/config/archives/W3ivJX3uT7CT4lywe_T5zw
url: https://api.datadoghq.com/api/v2/logs/config/archives/-GWdZ6m2RhKwHu40SqvtKg
method: GET
response:
body: '{"errors":["Archive W3ivJX3uT7CT4lywe_T5zw not found"]}'
body: '{"errors":["Archive -GWdZ6m2RhKwHu40SqvtKg not found"]}'
headers:
Content-Type:
- application/json
Expand All @@ -168,10 +168,11 @@ interactions:
url: https://api.datadoghq.com/api/v1/integration/azure
method: GET
response:
body: '{"errors":["Azure Integration not yet installed. Please install before performing this action."]}'
body: |
[{"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1692199125","client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear","app_service_plan_filters":"","automute":false,"cspm_enabled":false,"custom_metrics_enabled":false,"errors":[],"warnings":[]},{"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1692199125","client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear","app_service_plan_filters":"","automute":false,"cspm_enabled":false,"custom_metrics_enabled":false,"errors":[],"warnings":[]},{"tenant_name":"Test-Go-TestAzureCreate-1689984326","client_id":"testc7f6-1234-5678-9101-tt1689984326","host_filters":"","app_service_plan_filters":"","automute":true,"cspm_enabled":false,"custom_metrics_enabled":false,"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[]}]
headers:
Content-Type:
- application/json
status: 400 Bad Request
code: 400
status: 200 OK
code: 200
duration: ""
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-02-15T11:23:21.476572+01:00
2023-08-17T10:17:08.065609+02:00
Loading