Skip to content

Commit 266e7c9

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Fix missing field in Synthetics tests authentication configuration (#1263)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
1 parent 77e6830 commit 266e7c9

8 files changed

+309
-4
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.4",
7-
"regenerated": "2022-12-05 18:23:44.363298",
8-
"spec_repo_commit": "1cc231e1"
7+
"regenerated": "2022-12-08 13:18:32.017696",
8+
"spec_repo_commit": "65b2053a"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2022-12-05 18:23:44.375782",
13-
"spec_repo_commit": "1cc231e1"
12+
"regenerated": "2022-12-08 13:18:32.032677",
13+
"spec_repo_commit": "65b2053a"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11716,6 +11716,8 @@ components:
1171611716
description: Scope to use when performing the authentication.
1171711717
example: scope
1171811718
type: string
11719+
tokenApiAuthentication:
11720+
$ref: '#/components/schemas/SyntheticsBasicAuthOauthTokenApiAuthentication'
1171911721
type:
1172011722
$ref: '#/components/schemas/SyntheticsBasicAuthOauthROPType'
1172111723
username:
@@ -11725,6 +11727,7 @@ components:
1172511727
required:
1172611728
- accessTokenUrl
1172711729
- password
11730+
- tokenApiAuthentication
1172811731
- username
1172911732
type: object
1173011733
SyntheticsBasicAuthOauthROPType:
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
"""
2+
Create an API HTTP with oauth-rop test returns "OK - Returns the created test details." response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v1.api.synthetics_api import SyntheticsApi
7+
from datadog_api_client.v1.model.http_method import HTTPMethod
8+
from datadog_api_client.v1.model.synthetics_api_test import SyntheticsAPITest
9+
from datadog_api_client.v1.model.synthetics_api_test_config import SyntheticsAPITestConfig
10+
from datadog_api_client.v1.model.synthetics_api_test_type import SyntheticsAPITestType
11+
from datadog_api_client.v1.model.synthetics_assertion_json_path_operator import SyntheticsAssertionJSONPathOperator
12+
from datadog_api_client.v1.model.synthetics_assertion_json_path_target import SyntheticsAssertionJSONPathTarget
13+
from datadog_api_client.v1.model.synthetics_assertion_json_path_target_target import (
14+
SyntheticsAssertionJSONPathTargetTarget,
15+
)
16+
from datadog_api_client.v1.model.synthetics_assertion_operator import SyntheticsAssertionOperator
17+
from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget
18+
from datadog_api_client.v1.model.synthetics_assertion_type import SyntheticsAssertionType
19+
from datadog_api_client.v1.model.synthetics_assertion_x_path_operator import SyntheticsAssertionXPathOperator
20+
from datadog_api_client.v1.model.synthetics_assertion_x_path_target import SyntheticsAssertionXPathTarget
21+
from datadog_api_client.v1.model.synthetics_assertion_x_path_target_target import SyntheticsAssertionXPathTargetTarget
22+
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_rop import SyntheticsBasicAuthOauthROP
23+
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_rop_type import SyntheticsBasicAuthOauthROPType
24+
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_token_api_authentication import (
25+
SyntheticsBasicAuthOauthTokenApiAuthentication,
26+
)
27+
from datadog_api_client.v1.model.synthetics_config_variable import SyntheticsConfigVariable
28+
from datadog_api_client.v1.model.synthetics_config_variable_type import SyntheticsConfigVariableType
29+
from datadog_api_client.v1.model.synthetics_test_details_sub_type import SyntheticsTestDetailsSubType
30+
from datadog_api_client.v1.model.synthetics_test_headers import SyntheticsTestHeaders
31+
from datadog_api_client.v1.model.synthetics_test_options import SyntheticsTestOptions
32+
from datadog_api_client.v1.model.synthetics_test_options_retry import SyntheticsTestOptionsRetry
33+
from datadog_api_client.v1.model.synthetics_test_request import SyntheticsTestRequest
34+
from datadog_api_client.v1.model.synthetics_test_request_certificate import SyntheticsTestRequestCertificate
35+
from datadog_api_client.v1.model.synthetics_test_request_certificate_item import SyntheticsTestRequestCertificateItem
36+
from datadog_api_client.v1.model.synthetics_test_request_proxy import SyntheticsTestRequestProxy
37+
38+
body = SyntheticsAPITest(
39+
config=SyntheticsAPITestConfig(
40+
assertions=[
41+
SyntheticsAssertionTarget(
42+
operator=SyntheticsAssertionOperator.IS,
43+
_property="{{ PROPERTY }}",
44+
target="text/html",
45+
type=SyntheticsAssertionType.HEADER,
46+
),
47+
SyntheticsAssertionTarget(
48+
operator=SyntheticsAssertionOperator.LESS_THAN,
49+
target=2000,
50+
type=SyntheticsAssertionType.RESPONSE_TIME,
51+
),
52+
SyntheticsAssertionJSONPathTarget(
53+
operator=SyntheticsAssertionJSONPathOperator.VALIDATES_JSON_PATH,
54+
target=SyntheticsAssertionJSONPathTargetTarget(
55+
json_path="topKey",
56+
operator="isNot",
57+
target_value="0",
58+
),
59+
type=SyntheticsAssertionType.BODY,
60+
),
61+
SyntheticsAssertionXPathTarget(
62+
operator=SyntheticsAssertionXPathOperator.VALIDATES_X_PATH,
63+
target=SyntheticsAssertionXPathTargetTarget(
64+
x_path="target-xpath",
65+
target_value="0",
66+
operator="contains",
67+
),
68+
type=SyntheticsAssertionType.BODY,
69+
),
70+
],
71+
config_variables=[
72+
SyntheticsConfigVariable(
73+
example="content-type",
74+
name="PROPERTY",
75+
pattern="content-type",
76+
type=SyntheticsConfigVariableType.TEXT,
77+
),
78+
],
79+
request=SyntheticsTestRequest(
80+
certificate=SyntheticsTestRequestCertificate(
81+
cert=SyntheticsTestRequestCertificateItem(
82+
content="cert-content",
83+
filename="cert-filename",
84+
updated_at="2020-10-16T09:23:24.857Z",
85+
),
86+
key=SyntheticsTestRequestCertificateItem(
87+
content="key-content",
88+
filename="key-filename",
89+
updated_at="2020-10-16T09:23:24.857Z",
90+
),
91+
),
92+
headers=SyntheticsTestHeaders(
93+
unique="examplecreateanapihttpwithoauthroptestreturnsokreturnsthecreatedtestdetailsresponse",
94+
),
95+
method=HTTPMethod.GET,
96+
timeout=10.0,
97+
url="https://datadoghq.com",
98+
proxy=SyntheticsTestRequestProxy(
99+
url="https://datadoghq.com",
100+
headers=SyntheticsTestHeaders(),
101+
),
102+
basic_auth=SyntheticsBasicAuthOauthROP(
103+
access_token_url="https://datadog-token.com",
104+
audience="audience",
105+
client_id="client-id",
106+
client_secret="client-secret",
107+
resource="resource",
108+
scope="yoyo",
109+
token_api_authentication=SyntheticsBasicAuthOauthTokenApiAuthentication.BODY,
110+
type=SyntheticsBasicAuthOauthROPType.OAUTH_ROP,
111+
username="oauth-usermame",
112+
password="oauth-password",
113+
),
114+
),
115+
),
116+
locations=[
117+
"aws:us-east-2",
118+
],
119+
message="BDD test payload: synthetics_api_http_test_payload.json",
120+
name="Example-Create_an_API_HTTP_with_oauth_rop_test_returns_OK_Returns_the_created_test_details_response",
121+
options=SyntheticsTestOptions(
122+
accept_self_signed=False,
123+
allow_insecure=True,
124+
follow_redirects=True,
125+
min_failure_duration=10,
126+
min_location_failed=1,
127+
monitor_name="Example-Create_an_API_HTTP_with_oauth_rop_test_returns_OK_Returns_the_created_test_details_response",
128+
monitor_priority=5,
129+
retry=SyntheticsTestOptionsRetry(
130+
count=3,
131+
interval=10.0,
132+
),
133+
tick_every=60,
134+
),
135+
subtype=SyntheticsTestDetailsSubType.HTTP,
136+
tags=[
137+
"testing:api",
138+
],
139+
type=SyntheticsAPITestType.API,
140+
)
141+
142+
configuration = Configuration()
143+
with ApiClient(configuration) as api_client:
144+
api_instance = SyntheticsApi(api_client)
145+
response = api_instance.create_synthetics_api_test(body=body)
146+
147+
print(response)

src/datadog_api_client/v1/model/synthetics_basic_auth_oauth_rop.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@
1414

1515

1616
if TYPE_CHECKING:
17+
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_token_api_authentication import (
18+
SyntheticsBasicAuthOauthTokenApiAuthentication,
19+
)
1720
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_rop_type import SyntheticsBasicAuthOauthROPType
1821

1922

2023
class SyntheticsBasicAuthOauthROP(ModelNormal):
2124
@cached_property
2225
def openapi_types(_):
26+
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_token_api_authentication import (
27+
SyntheticsBasicAuthOauthTokenApiAuthentication,
28+
)
2329
from datadog_api_client.v1.model.synthetics_basic_auth_oauth_rop_type import SyntheticsBasicAuthOauthROPType
2430

2531
return {
@@ -30,6 +36,7 @@ def openapi_types(_):
3036
"password": (str,),
3137
"resource": (str,),
3238
"scope": (str,),
39+
"token_api_authentication": (SyntheticsBasicAuthOauthTokenApiAuthentication,),
3340
"type": (SyntheticsBasicAuthOauthROPType,),
3441
"username": (str,),
3542
}
@@ -42,6 +49,7 @@ def openapi_types(_):
4249
"password": "password",
4350
"resource": "resource",
4451
"scope": "scope",
52+
"token_api_authentication": "tokenApiAuthentication",
4553
"type": "type",
4654
"username": "username",
4755
}
@@ -50,6 +58,7 @@ def __init__(
5058
self_,
5159
access_token_url: str,
5260
password: str,
61+
token_api_authentication: SyntheticsBasicAuthOauthTokenApiAuthentication,
5362
username: str,
5463
audience: Union[str, UnsetType] = unset,
5564
client_id: Union[str, UnsetType] = unset,
@@ -83,6 +92,9 @@ def __init__(
8392
:param scope: Scope to use when performing the authentication.
8493
:type scope: str, optional
8594
95+
:param token_api_authentication: Type of token to use when performing the authentication.
96+
:type token_api_authentication: SyntheticsBasicAuthOauthTokenApiAuthentication
97+
8698
:param type: The type of basic authentication to use when performing the test.
8799
:type type: SyntheticsBasicAuthOauthROPType, optional
88100
@@ -105,4 +117,5 @@ def __init__(
105117

106118
self_.access_token_url = access_token_url
107119
self_.password = password
120+
self_.token_api_authentication = token_api_authentication
108121
self_.username = username
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2022-12-07T10:36:18.554Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
interactions:
2+
- request:
3+
body: '{"config":{"assertions":[{"operator":"is","property":"{{ PROPERTY }}","target":"text/html","type":"header"},{"operator":"lessThan","target":2000,"type":"responseTime"},{"operator":"validatesJSONPath","target":{"jsonPath":"topKey","operator":"isNot","targetValue":"0"},"type":"body"},{"operator":"validatesXPath","target":{"operator":"contains","targetValue":"0","xPath":"target-xpath"},"type":"body"}],"configVariables":[{"example":"content-type","name":"PROPERTY","pattern":"content-type","type":"text"}],"request":{"basicAuth":{"accessTokenUrl":"https://datadog-token.com","audience":"audience","clientId":"client-id","clientSecret":"client-secret","password":"oauth-password","resource":"resource","scope":"yoyo","tokenApiAuthentication":"body","type":"oauth-rop","username":"oauth-usermame"},"certificate":{"cert":{"content":"cert-content","filename":"cert-filename","updatedAt":"2020-10-16T09:23:24.857Z"},"key":{"content":"key-content","filename":"key-filename","updatedAt":"2020-10-16T09:23:24.857Z"}},"headers":{"unique":"testcreateanapihttpwithoauthroptestreturnsokreturnsthecreatedtestdetailsresponse1670409378"},"method":"GET","proxy":{"headers":{},"url":"https://datadoghq.com"},"timeout":10,"url":"https://datadoghq.com"}},"locations":["aws:us-east-2"],"message":"BDD
4+
test payload: synthetics_api_http_test_payload.json","name":"Test-Create_an_API_HTTP_with_oauth_rop_test_returns_OK_Returns_the_created_test_details_response-1670409378","options":{"accept_self_signed":false,"allow_insecure":true,"follow_redirects":true,"min_failure_duration":10,"min_location_failed":1,"monitor_name":"Test-Create_an_API_HTTP_with_oauth_rop_test_returns_OK_Returns_the_created_test_details_response-1670409378","monitor_priority":5,"retry":{"count":3,"interval":10},"tick_every":60},"subtype":"http","tags":["testing:api"],"type":"api"}'
5+
headers:
6+
accept:
7+
- application/json
8+
content-type:
9+
- application/json
10+
method: POST
11+
uri: https://api.datadoghq.com/api/v1/synthetics/tests/api
12+
response:
13+
body:
14+
string: '{"status":"live","public_id":"u7x-e98-98f","tags":["testing:api"],"org_id":569509,"locations":["aws:us-east-2"],"message":"BDD
15+
test payload: synthetics_api_http_test_payload.json","deleted_at":null,"name":"Test-Create_an_API_HTTP_with_oauth_rop_test_returns_OK_Returns_the_created_test_details_response-1670409378","monitor_id":105046994,"type":"api","created_at":"2022-12-07T10:36:19.000736+00:00","modified_at":"2022-12-07T10:36:19.000736+00:00","subtype":"http","config":{"request":{"certificate":{"cert":{"filename":"cert-filename","updatedAt":"2020-10-16T09:23:24.857Z"},"key":{"filename":"key-filename","updatedAt":"2020-10-16T09:23:24.857Z"}},"url":"https://datadoghq.com","basicAuth":{"username":"oauth-usermame","clientSecret":"client-secret","resource":"resource","accessTokenUrl":"https://datadog-token.com","audience":"audience","clientId":"client-id","scope":"yoyo","password":"oauth-password","type":"oauth-rop","tokenApiAuthentication":"body"},"headers":{"unique":"testcreateanapihttpwithoauthroptestreturnsokreturnsthecreatedtestdetailsresponse1670409378"},"proxy":{"url":"https://datadoghq.com","headers":{}},"timeout":10,"method":"GET"},"assertions":[{"operator":"is","property":"{{
16+
PROPERTY }}","type":"header","target":"text/html"},{"operator":"lessThan","type":"responseTime","target":2000},{"operator":"validatesJSONPath","type":"body","target":{"operator":"isNot","targetValue":"0","jsonPath":"topKey"}},{"operator":"validatesXPath","type":"body","target":{"operator":"contains","targetValue":"0","xPath":"target-xpath"}}],"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,"monitor_priority":5,"monitor_name":"Test-Create_an_API_HTTP_with_oauth_rop_test_returns_OK_Returns_the_created_test_details_response-1670409378","tick_every":60}}'
17+
headers:
18+
content-type:
19+
- application/json
20+
status:
21+
code: 200
22+
message: OK
23+
- request:
24+
body: '{"public_ids":["u7x-e98-98f"]}'
25+
headers:
26+
accept:
27+
- application/json
28+
content-type:
29+
- application/json
30+
method: POST
31+
uri: https://api.datadoghq.com/api/v1/synthetics/tests/delete
32+
response:
33+
body:
34+
string: '{"deleted_tests":[{"deleted_at":"2022-12-07T10:36:19.441845+00:00","public_id":"u7x-e98-98f"}]}
35+
36+
'
37+
headers:
38+
content-type:
39+
- application/json
40+
status:
41+
code: 200
42+
message: OK
43+
version: 1

tests/v1/features/synthetics.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ Feature: Synthetics
124124
Then the response status is 200 OK - Returns the created test details.
125125
And the response "name" is equal to "{{ unique }}"
126126

127+
@team:DataDog/synthetics-app
128+
Scenario: Create an API HTTP with oauth-rop test returns "OK - Returns the created test details." response
129+
Given new "CreateSyntheticsAPITest" request
130+
And body from file "synthetics_api_http_test_oauth_rop_payload.json"
131+
When the request is sent
132+
Then the response status is 200 OK - Returns the created test details.
133+
And the response "name" is equal to "{{ unique }}"
134+
127135
@team:DataDog/synthetics-app
128136
Scenario: Create an API SSL test returns "OK - Returns the created test details." response
129137
Given new "CreateSyntheticsAPITest" request
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"config": {
3+
"assertions": [
4+
{
5+
"operator": "is",
6+
"property": "{{ '{{ PROPERTY }}' }}",
7+
"target": "text/html",
8+
"type": "header"
9+
},
10+
{ "operator": "lessThan", "target": 2000, "type": "responseTime" },
11+
{
12+
"operator": "validatesJSONPath",
13+
"target": {
14+
"jsonPath": "topKey",
15+
"operator": "isNot",
16+
"targetValue": "0"
17+
},
18+
"type": "body"
19+
},
20+
{
21+
"operator": "validatesXPath",
22+
"target": {
23+
"xPath": "target-xpath",
24+
"targetValue": "0",
25+
"operator": "contains"
26+
},
27+
"type": "body"
28+
}
29+
],
30+
"configVariables": [
31+
{
32+
"example": "content-type",
33+
"name": "PROPERTY",
34+
"pattern": "content-type",
35+
"type": "text"
36+
}
37+
],
38+
"request": {
39+
"certificate": {
40+
"cert": {
41+
"content": "cert-content",
42+
"filename": "cert-filename",
43+
"updatedAt": "2020-10-16T09:23:24.857Z"
44+
},
45+
"key": {
46+
"content": "key-content",
47+
"filename": "key-filename",
48+
"updatedAt": "2020-10-16T09:23:24.857Z"
49+
}
50+
},
51+
"headers": { "unique": "{{ unique_lower_alnum }}" },
52+
"method": "GET",
53+
"timeout": 10,
54+
"url": "https://datadoghq.com",
55+
"proxy": {
56+
"url": "https://datadoghq.com",
57+
"headers": {}
58+
},
59+
"basicAuth": {
60+
"accessTokenUrl": "https://datadog-token.com",
61+
"audience": "audience",
62+
"clientId": "client-id",
63+
"clientSecret": "client-secret",
64+
"resource": "resource",
65+
"scope": "yoyo",
66+
"tokenApiAuthentication": "body",
67+
"type": "oauth-rop",
68+
"username": "oauth-usermame",
69+
"password": "oauth-password"
70+
}
71+
}
72+
},
73+
"locations": ["aws:us-east-2"],
74+
"message": "BDD test payload: synthetics_api_http_test_payload.json",
75+
"name": "{{ unique }}",
76+
"options": {
77+
"accept_self_signed": false,
78+
"allow_insecure": true,
79+
"follow_redirects": true,
80+
"min_failure_duration": 10,
81+
"min_location_failed": 1,
82+
"monitor_name": "{{ unique }}",
83+
"monitor_priority": 5,
84+
"retry": { "count": 3, "interval": 10 },
85+
"tick_every": 60
86+
},
87+
"subtype": "http",
88+
"tags": ["testing:api"],
89+
"type": "api"
90+
}

0 commit comments

Comments
 (0)