Skip to content

Commit

Permalink
Add secure field to synthetics config variables (#1811)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Jan 3, 2023
1 parent b5df4d4 commit 206cab2
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 19 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.4",
"regenerated": "2022-12-29 18:12:42.542728",
"spec_repo_commit": "5ba7a1cc"
"regenerated": "2023-01-03 13:40:24.146387",
"spec_repo_commit": "89fd9735"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2022-12-29 18:12:42.556920",
"spec_repo_commit": "5ba7a1cc"
"regenerated": "2023-01-03 13:40:24.161938",
"spec_repo_commit": "89fd9735"
}
}
}
5 changes: 5 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12530,6 +12530,11 @@ components:
pattern:
description: Pattern of the variable.
type: string
secure:
description: Whether the value of this variable will be obfuscated in test
results.
example: false
type: boolean
type:
$ref: '#/components/schemas/SyntheticsConfigVariableType'
required:
Expand Down
35 changes: 35 additions & 0 deletions api/datadogV1/model_synthetics_config_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type SyntheticsConfigVariable struct {
Name string `json:"name"`
// Pattern of the variable.
Pattern *string `json:"pattern,omitempty"`
// Whether the value of this variable will be obfuscated in test results.
Secure *bool `json:"secure,omitempty"`
// Type of the configuration variable.
Type SyntheticsConfigVariableType `json:"type"`
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
Expand Down Expand Up @@ -152,6 +154,34 @@ func (o *SyntheticsConfigVariable) SetPattern(v string) {
o.Pattern = &v
}

// GetSecure returns the Secure field value if set, zero value otherwise.
func (o *SyntheticsConfigVariable) GetSecure() bool {
if o == nil || o.Secure == nil {
var ret bool
return ret
}
return *o.Secure
}

// GetSecureOk returns a tuple with the Secure field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *SyntheticsConfigVariable) GetSecureOk() (*bool, bool) {
if o == nil || o.Secure == nil {
return nil, false
}
return o.Secure, true
}

// HasSecure returns a boolean if a field has been set.
func (o *SyntheticsConfigVariable) HasSecure() bool {
return o != nil && o.Secure != nil
}

// SetSecure gets a reference to the given bool and assigns it to the Secure field.
func (o *SyntheticsConfigVariable) SetSecure(v bool) {
o.Secure = &v
}

// GetType returns the Type field value.
func (o *SyntheticsConfigVariable) GetType() SyntheticsConfigVariableType {
if o == nil {
Expand Down Expand Up @@ -191,6 +221,9 @@ func (o SyntheticsConfigVariable) MarshalJSON() ([]byte, error) {
if o.Pattern != nil {
toSerialize["pattern"] = o.Pattern
}
if o.Secure != nil {
toSerialize["secure"] = o.Secure
}
toSerialize["type"] = o.Type

for key, value := range o.AdditionalProperties {
Expand All @@ -211,6 +244,7 @@ func (o *SyntheticsConfigVariable) UnmarshalJSON(bytes []byte) (err error) {
Id *string `json:"id,omitempty"`
Name string `json:"name"`
Pattern *string `json:"pattern,omitempty"`
Secure *bool `json:"secure,omitempty"`
Type SyntheticsConfigVariableType `json:"type"`
}{}
err = json.Unmarshal(bytes, &required)
Expand Down Expand Up @@ -244,6 +278,7 @@ func (o *SyntheticsConfigVariable) UnmarshalJSON(bytes []byte) (err error) {
o.Id = all.Id
o.Name = all.Name
o.Pattern = all.Pattern
o.Secure = all.Secure
o.Type = all.Type
return nil
}
1 change: 1 addition & 0 deletions examples/v1/synthetics/CreateSyntheticsBrowserTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func main() {
Name: "PROPERTY",
Pattern: datadog.PtrString("content-type"),
Type: datadogV1.SYNTHETICSCONFIGVARIABLETYPE_TEXT,
Secure: datadog.PtrBool(true),
},
},
Request: datadogV1.SyntheticsTestRequest{
Expand Down
5 changes: 3 additions & 2 deletions examples/v1/synthetics/UpdateBrowserTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ func main() {
Assertions: []datadogV1.SyntheticsAssertion{},
ConfigVariables: []datadogV1.SyntheticsConfigVariable{
{
Name: "VARIABLE_NAME",
Type: datadogV1.SYNTHETICSCONFIGVARIABLETYPE_TEXT,
Name: "VARIABLE_NAME",
Secure: datadog.PtrBool(false),
Type: datadogV1.SYNTHETICSCONFIGVARIABLETYPE_TEXT,
},
},
Request: datadogV1.SyntheticsTestRequest{
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2022-08-30T12:58:42.391Z
2022-12-28T20:20:26.146Z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interactions:
- request:
body: |
{"config":{"assertions":[],"configVariables":[{"example":"content-type","name":"PROPERTY","pattern":"content-type","type":"text"}],"request":{"method":"GET","url":"https://datadoghq.com"},"setCookie":"name:test"},"locations":["aws:us-east-2"],"message":"Test message","name":"Test-Create_a_browser_test_returns_OK_Returns_the_created_test_details_response-1661864322","options":{"accept_self_signed":false,"allow_insecure":true,"device_ids":["tablet"],"disableCors":true,"follow_redirects":true,"min_failure_duration":10,"min_location_failed":1,"noScreenshot":true,"retry":{"count":3,"interval":10},"tick_every":300},"steps":[{"allowFailure":false,"isCritical":true,"name":"Refresh page","params":{},"type":"refresh"}],"tags":["testing:browser"],"type":"browser"}
{"config":{"assertions":[],"configVariables":[{"example":"content-type","name":"PROPERTY","pattern":"content-type","secure":true,"type":"text"}],"request":{"method":"GET","url":"https://datadoghq.com"},"setCookie":"name:test"},"locations":["aws:us-east-2"],"message":"Test message","name":"Test-Create_a_browser_test_returns_OK_Returns_the_created_test_details_response-1672258826","options":{"accept_self_signed":false,"allow_insecure":true,"device_ids":["tablet"],"disableCors":true,"follow_redirects":true,"min_failure_duration":10,"min_location_failed":1,"noScreenshot":true,"retry":{"count":3,"interval":10},"tick_every":300},"steps":[{"allowFailure":false,"isCritical":true,"name":"Refresh page","params":{},"type":"refresh"}],"tags":["testing:browser"],"type":"browser"}
form: {}
headers:
Accept:
Expand All @@ -11,9 +11,9 @@ interactions:
method: POST
url: https://api.datadoghq.com/api/v1/synthetics/tests/browser
response:
body: '{"status":"paused","public_id":"3x7-bch-33k","tags":["testing:browser"],"org_id":321813,"locations":["aws:us-east-2"],"message":"Test
message","deleted_at":null,"name":"Test-Create_a_browser_test_returns_OK_Returns_the_created_test_details_response-1661864322","monitor_id":81568570,"type":"browser","created_at":"2022-08-30T12:58:43.101655+00:00","modified_at":"2022-08-30T12:58:43.101655+00:00","steps":[{"name":"Refresh
page","allowFailure":false,"params":{},"isCritical":true,"type":"refresh"}],"config":{"setCookie":"name:test","request":{"url":"https://datadoghq.com","method":"GET"},"assertions":[],"configVariables":[{"pattern":"content-type","type":"text","example":"content-type","name":"PROPERTY"}]},"options":{"accept_self_signed":false,"retry":{"count":3,"interval":10},"min_location_failed":1,"allow_insecure":true,"follow_redirects":true,"min_failure_duration":10,"noScreenshot":true,"disableCors":true,"device_ids":["tablet"],"tick_every":300}}'
body: '{"status":"paused","public_id":"t2j-ah7-xvk","tags":["testing:browser"],"org_id":321813,"locations":["aws:us-east-2"],"message":"Test
message","deleted_at":null,"name":"Test-Create_a_browser_test_returns_OK_Returns_the_created_test_details_response-1672258826","monitor_id":106541668,"type":"browser","created_at":"2022-12-28T20:20:26.418704+00:00","modified_at":"2022-12-28T20:20:26.418704+00:00","steps":[{"name":"Refresh
page","allowFailure":false,"params":{},"isCritical":true,"type":"refresh"}],"config":{"setCookie":"name:test","request":{"url":"https://datadoghq.com","method":"GET"},"assertions":[],"configVariables":[{"type":"text","secure":true,"name":"PROPERTY"}]},"options":{"accept_self_signed":false,"retry":{"count":3,"interval":10},"min_location_failed":1,"allow_insecure":true,"follow_redirects":true,"min_failure_duration":10,"noScreenshot":true,"disableCors":true,"device_ids":["tablet"],"tick_every":300}}'
code: 200
duration: ''
headers:
Expand All @@ -22,7 +22,7 @@ interactions:
status: 200 OK
- request:
body: |
{"public_ids":["3x7-bch-33k"]}
{"public_ids":["t2j-ah7-xvk"]}
form: {}
headers:
Accept:
Expand All @@ -32,7 +32,9 @@ interactions:
method: POST
url: https://api.datadoghq.com/api/v1/synthetics/tests/delete
response:
body: '{"deleted_tests":[{"deleted_at":"2022-08-30T12:58:48.505733+00:00","public_id":"3x7-bch-33k"}]}'
body: '{"deleted_tests":[{"deleted_at":"2022-12-28T20:20:26.638790+00:00","public_id":"t2j-ah7-xvk"}]}
'
code: 200
duration: ''
headers:
Expand Down
11 changes: 6 additions & 5 deletions tests/scenarios/features/v1/synthetics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Feature: Synthetics
@generated @skip @team:DataDog/synthetics-app
Scenario: Create a browser test returns "- JSON format is wrong" response
Given new "CreateSyntheticsBrowserTest" request
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "proxy": {"url": "https://example.com"}, "service": "Greeter", "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "proxy": {"url": "https://example.com"}, "service": "Greeter", "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
When the request is sent
Then the response status is 400 - JSON format is wrong

Expand All @@ -55,11 +55,12 @@ Feature: Synthetics
When the request is sent
Then the response status is 200 OK - Returns the created test details.
And the response "name" is equal to "{{ unique }}"
And the response "config.configVariables[0].secure" is equal to true

@generated @skip @team:DataDog/synthetics-app
Scenario: Create a browser test returns "Test quota is reached" response
Given new "CreateSyntheticsBrowserTest" request
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "proxy": {"url": "https://example.com"}, "service": "Greeter", "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "proxy": {"url": "https://example.com"}, "service": "Greeter", "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
When the request is sent
Then the response status is 402 Test quota is reached

Expand Down Expand Up @@ -249,23 +250,23 @@ Feature: Synthetics
Scenario: Edit a browser test returns "- JSON format is wrong" response
Given new "UpdateBrowserTest" request
And request contains "public_id" parameter from "REPLACE.ME"
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "proxy": {"url": "https://example.com"}, "service": "Greeter", "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "proxy": {"url": "https://example.com"}, "service": "Greeter", "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
When the request is sent
Then the response status is 400 - JSON format is wrong

@generated @skip @team:DataDog/synthetics-app
Scenario: Edit a browser test returns "- Synthetic Monitoring is not activated for the user" response
Given new "UpdateBrowserTest" request
And request contains "public_id" parameter from "REPLACE.ME"
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "proxy": {"url": "https://example.com"}, "service": "Greeter", "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "proxy": {"url": "https://example.com"}, "service": "Greeter", "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
When the request is sent
Then the response status is 404 - Synthetic Monitoring is not activated for the user

@generated @skip @team:DataDog/synthetics-app
Scenario: Edit a browser test returns "OK" response
Given new "UpdateBrowserTest" request
And request contains "public_id" parameter from "REPLACE.ME"
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "proxy": {"url": "https://example.com"}, "service": "Greeter", "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
And body with value {"config": {"assertions": [], "configVariables": [{"name": "VARIABLE_NAME", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "proxy": {"url": "https://example.com"}, "service": "Greeter", "url": "https://example.com"}, "variables": [{"name": "VARIABLE_NAME", "type": "text"}]}, "locations": ["aws:eu-west-3"], "message": "", "name": "Example test name", "options": {"ci": {"executionRule": "blocking"}, "device_ids": ["laptop_large"], "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"}
When the request is sent
Then the response status is 200 OK

Expand Down
Loading

0 comments on commit 206cab2

Please sign in to comment.