Skip to content

Add secure field to synthetics config variables #1283

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

Merged
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
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:35.638162",
"spec_repo_commit": "5ba7a1cc"
"regenerated": "2023-01-03 13:40:08.022216",
"spec_repo_commit": "89fd9735"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2022-12-29 18:12:35.649477",
"spec_repo_commit": "5ba7a1cc"
"regenerated": "2023-01-03 13:40:08.179564",
"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
1 change: 1 addition & 0 deletions examples/v1/synthetics/CreateSyntheticsBrowserTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
name="PROPERTY",
pattern="content-type",
type=SyntheticsConfigVariableType.TEXT,
secure=True,
),
],
request=SyntheticsTestRequest(
Expand Down
1 change: 1 addition & 0 deletions examples/v1/synthetics/UpdateBrowserTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
config_variables=[
SyntheticsConfigVariable(
name="VARIABLE_NAME",
secure=False,
type=SyntheticsConfigVariableType.TEXT,
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def openapi_types(_):
"id": (str,),
"name": (str,),
"pattern": (str,),
"secure": (bool,),
"type": (SyntheticsConfigVariableType,),
}

Expand All @@ -35,6 +36,7 @@ def openapi_types(_):
"id": "id",
"name": "name",
"pattern": "pattern",
"secure": "secure",
"type": "type",
}

Expand All @@ -45,6 +47,7 @@ def __init__(
example: Union[str, UnsetType] = unset,
id: Union[str, UnsetType] = unset,
pattern: Union[str, UnsetType] = unset,
secure: Union[bool, UnsetType] = unset,
**kwargs,
):
"""
Expand All @@ -62,6 +65,9 @@ def __init__(
:param pattern: Pattern of the variable.
:type pattern: str, optional

:param secure: Whether the value of this variable will be obfuscated in test results.
:type secure: bool, optional

:param type: Type of the configuration variable.
:type type: SyntheticsConfigVariableType
"""
Expand All @@ -71,6 +77,8 @@ def __init__(
kwargs["id"] = id
if pattern is not unset:
kwargs["pattern"] = pattern
if secure is not unset:
kwargs["secure"] = secure
super().__init__(kwargs)

self_.name = name
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
body: '{"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"}'
headers:
accept:
Expand All @@ -12,17 +12,17 @@ interactions:
uri: https://api.datadoghq.com/api/v1/synthetics/tests/browser
response:
body:
string: '{"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}}'
string: '{"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}}'
headers:
content-type:
- application/json
status:
code: 200
message: OK
- request:
body: '{"public_ids":["3x7-bch-33k"]}'
body: '{"public_ids":["t2j-ah7-xvk"]}'
headers:
accept:
- application/json
Expand All @@ -32,7 +32,9 @@ interactions:
uri: https://api.datadoghq.com/api/v1/synthetics/tests/delete
response:
body:
string: '{"deleted_tests":[{"deleted_at":"2022-08-30T12:58:48.505733+00:00","public_id":"3x7-bch-33k"}]}'
string: '{"deleted_tests":[{"deleted_at":"2022-12-28T20:20:26.638790+00:00","public_id":"t2j-ah7-xvk"}]}

'
headers:
content-type:
- application/json
Expand Down
11 changes: 6 additions & 5 deletions tests/v1/features/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
3 changes: 2 additions & 1 deletion tests/v1/features/synthetics_browser_test_payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"example": "content-type",
"name": "PROPERTY",
"pattern": "content-type",
"type": "text"
"type": "text",
"secure": true
}
],
"request": { "method": "GET", "url": "https://datadoghq.com" },
Expand Down