diff --git a/.apigentools-info b/.apigentools-info index cc8bc3e801..e2cd872344 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-04-04 17:56:42.820919", - "spec_repo_commit": "bf950df2" + "regenerated": "2024-04-04 19:26:54.191355", + "spec_repo_commit": "a96ed3f8" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-04-04 17:56:42.841894", - "spec_repo_commit": "bf950df2" + "regenerated": "2024-04-04 19:26:54.209619", + "spec_repo_commit": "a96ed3f8" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 6fa32ee012..c77a54174c 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -15866,6 +15866,11 @@ components: maximum: 65535 minimum: 1 type: integer + files: + description: Files to be used as part of the request in the test. + items: + $ref: '#/components/schemas/SyntheticsTestRequestBodyFile' + type: array follow_redirects: description: Specifies whether or not the request follows redirects. type: boolean @@ -15932,6 +15937,32 @@ components: example: https://example.com type: string type: object + SyntheticsTestRequestBodyFile: + description: Object describing a file to be used as part of the request in the + test. + properties: + bucketKey: + description: Bucket key of the file. + type: string + content: + description: Content of the file. + maxLength: 3145728 + type: string + name: + description: Name of the file. + maxLength: 1500 + type: string + size: + description: Size of the file. + format: int64 + maximum: 3145728 + minimum: 1 + type: integer + type: + description: Type of the file. + maxLength: 1500 + type: string + type: object SyntheticsTestRequestBodyType: description: Type of the request body. enum: @@ -15941,6 +15972,8 @@ components: - text/html - application/x-www-form-urlencoded - graphql + - application/octet-stream + - multipart/form-data example: text/plain type: string x-enum-varnames: @@ -15950,6 +15983,8 @@ components: - TEXT_HTML - APPLICATION_X_WWW_FORM_URLENCODED - GRAPHQL + - APPLICATION_OCTET_STREAM + - MULTIPART_FORM_DATA SyntheticsTestRequestCertificate: description: Client certificate to use when performing the test request. properties: diff --git a/docs/datadog_api_client.v1.model.rst b/docs/datadog_api_client.v1.model.rst index cb6c73fa75..ebec6fad48 100644 --- a/docs/datadog_api_client.v1.model.rst +++ b/docs/datadog_api_client.v1.model.rst @@ -4621,6 +4621,13 @@ synthetics\_test\_request :members: :show-inheritance: +synthetics\_test\_request\_body\_file +------------------------------------- + +.. automodule:: datadog_api_client.v1.model.synthetics_test_request_body_file + :members: + :show-inheritance: + synthetics\_test\_request\_body\_type ------------------------------------- diff --git a/examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.py b/examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.py new file mode 100644 index 0000000000..7d4c30e292 --- /dev/null +++ b/examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.py @@ -0,0 +1,159 @@ +""" +Create an API test with a file payload returns "OK - Returns the created test details." response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v1.api.synthetics_api import SyntheticsApi +from datadog_api_client.v1.model.synthetics_api_test import SyntheticsAPITest +from datadog_api_client.v1.model.synthetics_api_test_config import SyntheticsAPITestConfig +from datadog_api_client.v1.model.synthetics_api_test_type import SyntheticsAPITestType +from datadog_api_client.v1.model.synthetics_assertion_json_path_operator import SyntheticsAssertionJSONPathOperator +from datadog_api_client.v1.model.synthetics_assertion_json_path_target import SyntheticsAssertionJSONPathTarget +from datadog_api_client.v1.model.synthetics_assertion_json_path_target_target import ( + SyntheticsAssertionJSONPathTargetTarget, +) +from datadog_api_client.v1.model.synthetics_assertion_operator import SyntheticsAssertionOperator +from datadog_api_client.v1.model.synthetics_assertion_target import SyntheticsAssertionTarget +from datadog_api_client.v1.model.synthetics_assertion_timings_scope import SyntheticsAssertionTimingsScope +from datadog_api_client.v1.model.synthetics_assertion_type import SyntheticsAssertionType +from datadog_api_client.v1.model.synthetics_assertion_x_path_operator import SyntheticsAssertionXPathOperator +from datadog_api_client.v1.model.synthetics_assertion_x_path_target import SyntheticsAssertionXPathTarget +from datadog_api_client.v1.model.synthetics_assertion_x_path_target_target import SyntheticsAssertionXPathTargetTarget +from datadog_api_client.v1.model.synthetics_basic_auth_oauth_client import SyntheticsBasicAuthOauthClient +from datadog_api_client.v1.model.synthetics_basic_auth_oauth_client_type import SyntheticsBasicAuthOauthClientType +from datadog_api_client.v1.model.synthetics_basic_auth_oauth_token_api_authentication import ( + SyntheticsBasicAuthOauthTokenApiAuthentication, +) +from datadog_api_client.v1.model.synthetics_config_variable import SyntheticsConfigVariable +from datadog_api_client.v1.model.synthetics_config_variable_type import SyntheticsConfigVariableType +from datadog_api_client.v1.model.synthetics_test_details_sub_type import SyntheticsTestDetailsSubType +from datadog_api_client.v1.model.synthetics_test_headers import SyntheticsTestHeaders +from datadog_api_client.v1.model.synthetics_test_options import SyntheticsTestOptions +from datadog_api_client.v1.model.synthetics_test_options_http_version import SyntheticsTestOptionsHTTPVersion +from datadog_api_client.v1.model.synthetics_test_options_retry import SyntheticsTestOptionsRetry +from datadog_api_client.v1.model.synthetics_test_request import SyntheticsTestRequest +from datadog_api_client.v1.model.synthetics_test_request_body_file import SyntheticsTestRequestBodyFile +from datadog_api_client.v1.model.synthetics_test_request_body_type import SyntheticsTestRequestBodyType +from datadog_api_client.v1.model.synthetics_test_request_certificate import SyntheticsTestRequestCertificate +from datadog_api_client.v1.model.synthetics_test_request_certificate_item import SyntheticsTestRequestCertificateItem +from datadog_api_client.v1.model.synthetics_test_request_proxy import SyntheticsTestRequestProxy + +body = SyntheticsAPITest( + config=SyntheticsAPITestConfig( + assertions=[ + SyntheticsAssertionTarget( + operator=SyntheticsAssertionOperator.IS, + _property="{{ PROPERTY }}", + target="text/html", + type=SyntheticsAssertionType.HEADER, + ), + SyntheticsAssertionTarget( + operator=SyntheticsAssertionOperator.LESS_THAN, + target=2000, + type=SyntheticsAssertionType.RESPONSE_TIME, + timings_scope=SyntheticsAssertionTimingsScope.WITHOUT_DNS, + ), + SyntheticsAssertionJSONPathTarget( + operator=SyntheticsAssertionJSONPathOperator.VALIDATES_JSON_PATH, + target=SyntheticsAssertionJSONPathTargetTarget( + json_path="topKey", + operator="isNot", + target_value="0", + ), + type=SyntheticsAssertionType.BODY, + ), + SyntheticsAssertionXPathTarget( + operator=SyntheticsAssertionXPathOperator.VALIDATES_X_PATH, + target=SyntheticsAssertionXPathTargetTarget( + x_path="target-xpath", + target_value="0", + operator="contains", + ), + type=SyntheticsAssertionType.BODY, + ), + ], + config_variables=[ + SyntheticsConfigVariable( + example="content-type", + name="PROPERTY", + pattern="content-type", + type=SyntheticsConfigVariableType.TEXT, + ), + ], + request=SyntheticsTestRequest( + certificate=SyntheticsTestRequestCertificate( + cert=SyntheticsTestRequestCertificateItem( + content="cert-content", + filename="cert-filename", + updated_at="2020-10-16T09:23:24.857Z", + ), + key=SyntheticsTestRequestCertificateItem( + content="key-content", + filename="key-filename", + updated_at="2020-10-16T09:23:24.857Z", + ), + ), + headers=SyntheticsTestHeaders( + unique="examplesynthetic", + ), + method="GET", + timeout=10.0, + url="https://datadoghq.com", + proxy=SyntheticsTestRequestProxy( + url="https://datadoghq.com", + headers=SyntheticsTestHeaders(), + ), + body_type=SyntheticsTestRequestBodyType.APPLICATION_OCTET_STREAM, + files=[ + SyntheticsTestRequestBodyFile( + name="file name", + content="file content", + type="file type", + ), + ], + basic_auth=SyntheticsBasicAuthOauthClient( + access_token_url="https://datadog-token.com", + audience="audience", + client_id="client-id", + client_secret="client-secret", + resource="resource", + scope="yoyo", + token_api_authentication=SyntheticsBasicAuthOauthTokenApiAuthentication.HEADER, + type=SyntheticsBasicAuthOauthClientType.OAUTH_CLIENT, + ), + persist_cookies=True, + ), + ), + locations=[ + "aws:us-east-2", + ], + message="BDD test payload: synthetics_api_http_test_payload.json", + name="Example-Synthetic", + options=SyntheticsTestOptions( + accept_self_signed=False, + allow_insecure=True, + follow_redirects=True, + min_failure_duration=10, + min_location_failed=1, + monitor_name="Example-Synthetic", + monitor_priority=5, + retry=SyntheticsTestOptionsRetry( + count=3, + interval=10.0, + ), + tick_every=60, + http_version=SyntheticsTestOptionsHTTPVersion.HTTP2, + ), + subtype=SyntheticsTestDetailsSubType.HTTP, + tags=[ + "testing:api", + ], + type=SyntheticsAPITestType.API, +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = SyntheticsApi(api_client) + response = api_instance.create_synthetics_api_test(body=body) + + print(response) diff --git a/examples/v1/synthetics/UpdateBrowserTest.py b/examples/v1/synthetics/UpdateBrowserTest.py index ec6f483905..0b2d789625 100644 --- a/examples/v1/synthetics/UpdateBrowserTest.py +++ b/examples/v1/synthetics/UpdateBrowserTest.py @@ -31,6 +31,7 @@ ) from datadog_api_client.v1.model.synthetics_test_pause_status import SyntheticsTestPauseStatus from datadog_api_client.v1.model.synthetics_test_request import SyntheticsTestRequest +from datadog_api_client.v1.model.synthetics_test_request_body_file import SyntheticsTestRequestBodyFile from datadog_api_client.v1.model.synthetics_test_request_body_type import SyntheticsTestRequestBodyType from datadog_api_client.v1.model.synthetics_test_request_certificate import SyntheticsTestRequestCertificate from datadog_api_client.v1.model.synthetics_test_request_certificate_item import SyntheticsTestRequestCertificateItem @@ -59,6 +60,9 @@ key=SyntheticsTestRequestCertificateItem(), ), certificate_domains=[], + files=[ + SyntheticsTestRequestBodyFile(), + ], http_version=SyntheticsTestOptionsHTTPVersion.HTTP1, proxy=SyntheticsTestRequestProxy( url="https://example.com", diff --git a/src/datadog_api_client/v1/model/synthetics_test_request.py b/src/datadog_api_client/v1/model/synthetics_test_request.py index fdf8b5f641..6685efaf4d 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_request.py +++ b/src/datadog_api_client/v1/model/synthetics_test_request.py @@ -18,6 +18,7 @@ from datadog_api_client.v1.model.synthetics_test_request_body_type import SyntheticsTestRequestBodyType from datadog_api_client.v1.model.synthetics_test_call_type import SyntheticsTestCallType from datadog_api_client.v1.model.synthetics_test_request_certificate import SyntheticsTestRequestCertificate + from datadog_api_client.v1.model.synthetics_test_request_body_file import SyntheticsTestRequestBodyFile from datadog_api_client.v1.model.synthetics_test_headers import SyntheticsTestHeaders from datadog_api_client.v1.model.synthetics_test_options_http_version import SyntheticsTestOptionsHTTPVersion from datadog_api_client.v1.model.synthetics_test_metadata import SyntheticsTestMetadata @@ -48,6 +49,7 @@ def openapi_types(_): from datadog_api_client.v1.model.synthetics_test_request_body_type import SyntheticsTestRequestBodyType from datadog_api_client.v1.model.synthetics_test_call_type import SyntheticsTestCallType from datadog_api_client.v1.model.synthetics_test_request_certificate import SyntheticsTestRequestCertificate + from datadog_api_client.v1.model.synthetics_test_request_body_file import SyntheticsTestRequestBodyFile from datadog_api_client.v1.model.synthetics_test_headers import SyntheticsTestHeaders from datadog_api_client.v1.model.synthetics_test_options_http_version import SyntheticsTestOptionsHTTPVersion from datadog_api_client.v1.model.synthetics_test_metadata import SyntheticsTestMetadata @@ -65,6 +67,7 @@ def openapi_types(_): "compressed_proto_file": (str,), "dns_server": (str,), "dns_server_port": (int,), + "files": ([SyntheticsTestRequestBodyFile],), "follow_redirects": (bool,), "headers": (SyntheticsTestHeaders,), "host": (str,), @@ -97,6 +100,7 @@ def openapi_types(_): "compressed_proto_file": "compressedProtoFile", "dns_server": "dnsServer", "dns_server_port": "dnsServerPort", + "files": "files", "follow_redirects": "follow_redirects", "headers": "headers", "host": "host", @@ -139,6 +143,7 @@ def __init__( compressed_proto_file: Union[str, UnsetType] = unset, dns_server: Union[str, UnsetType] = unset, dns_server_port: Union[int, UnsetType] = unset, + files: Union[List[SyntheticsTestRequestBodyFile], UnsetType] = unset, follow_redirects: Union[bool, UnsetType] = unset, headers: Union[SyntheticsTestHeaders, UnsetType] = unset, host: Union[str, UnsetType] = unset, @@ -195,6 +200,9 @@ def __init__( :param dns_server_port: DNS server port to use for DNS tests. :type dns_server_port: int, optional + :param files: Files to be used as part of the request in the test. + :type files: [SyntheticsTestRequestBodyFile], optional + :param follow_redirects: Specifies whether or not the request follows redirects. :type follow_redirects: bool, optional @@ -273,6 +281,8 @@ def __init__( kwargs["dns_server"] = dns_server if dns_server_port is not unset: kwargs["dns_server_port"] = dns_server_port + if files is not unset: + kwargs["files"] = files if follow_redirects is not unset: kwargs["follow_redirects"] = follow_redirects if headers is not unset: diff --git a/src/datadog_api_client/v1/model/synthetics_test_request_body_file.py b/src/datadog_api_client/v1/model/synthetics_test_request_body_file.py new file mode 100644 index 0000000000..d82d450be1 --- /dev/null +++ b/src/datadog_api_client/v1/model/synthetics_test_request_body_file.py @@ -0,0 +1,88 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class SyntheticsTestRequestBodyFile(ModelNormal): + validations = { + "content": { + "max_length": 3145728, + }, + "name": { + "max_length": 1500, + }, + "size": { + "inclusive_maximum": 3145728, + "inclusive_minimum": 1, + }, + "type": { + "max_length": 1500, + }, + } + + @cached_property + def openapi_types(_): + return { + "bucket_key": (str,), + "content": (str,), + "name": (str,), + "size": (int,), + "type": (str,), + } + + attribute_map = { + "bucket_key": "bucketKey", + "content": "content", + "name": "name", + "size": "size", + "type": "type", + } + + def __init__( + self_, + bucket_key: Union[str, UnsetType] = unset, + content: Union[str, UnsetType] = unset, + name: Union[str, UnsetType] = unset, + size: Union[int, UnsetType] = unset, + type: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + Object describing a file to be used as part of the request in the test. + + :param bucket_key: Bucket key of the file. + :type bucket_key: str, optional + + :param content: Content of the file. + :type content: str, optional + + :param name: Name of the file. + :type name: str, optional + + :param size: Size of the file. + :type size: int, optional + + :param type: Type of the file. + :type type: str, optional + """ + if bucket_key is not unset: + kwargs["bucket_key"] = bucket_key + if content is not unset: + kwargs["content"] = content + if name is not unset: + kwargs["name"] = name + if size is not unset: + kwargs["size"] = size + if type is not unset: + kwargs["type"] = type + super().__init__(kwargs) diff --git a/src/datadog_api_client/v1/model/synthetics_test_request_body_type.py b/src/datadog_api_client/v1/model/synthetics_test_request_body_type.py index c1dbcb4386..08fc8e2852 100644 --- a/src/datadog_api_client/v1/model/synthetics_test_request_body_type.py +++ b/src/datadog_api_client/v1/model/synthetics_test_request_body_type.py @@ -16,7 +16,7 @@ class SyntheticsTestRequestBodyType(ModelSimple): """ Type of the request body. - :param value: Must be one of ["text/plain", "application/json", "text/xml", "text/html", "application/x-www-form-urlencoded", "graphql"]. + :param value: Must be one of ["text/plain", "application/json", "text/xml", "text/html", "application/x-www-form-urlencoded", "graphql", "application/octet-stream", "multipart/form-data"]. :type value: str """ @@ -27,6 +27,8 @@ class SyntheticsTestRequestBodyType(ModelSimple): "text/html", "application/x-www-form-urlencoded", "graphql", + "application/octet-stream", + "multipart/form-data", } TEXT_PLAIN: ClassVar["SyntheticsTestRequestBodyType"] APPLICATION_JSON: ClassVar["SyntheticsTestRequestBodyType"] @@ -34,6 +36,8 @@ class SyntheticsTestRequestBodyType(ModelSimple): TEXT_HTML: ClassVar["SyntheticsTestRequestBodyType"] APPLICATION_X_WWW_FORM_URLENCODED: ClassVar["SyntheticsTestRequestBodyType"] GRAPHQL: ClassVar["SyntheticsTestRequestBodyType"] + APPLICATION_OCTET_STREAM: ClassVar["SyntheticsTestRequestBodyType"] + MULTIPART_FORM_DATA: ClassVar["SyntheticsTestRequestBodyType"] @cached_property def openapi_types(_): @@ -50,3 +54,5 @@ def openapi_types(_): "application/x-www-form-urlencoded" ) SyntheticsTestRequestBodyType.GRAPHQL = SyntheticsTestRequestBodyType("graphql") +SyntheticsTestRequestBodyType.APPLICATION_OCTET_STREAM = SyntheticsTestRequestBodyType("application/octet-stream") +SyntheticsTestRequestBodyType.MULTIPART_FORM_DATA = SyntheticsTestRequestBodyType("multipart/form-data") diff --git a/src/datadog_api_client/v1/models/__init__.py b/src/datadog_api_client/v1/models/__init__.py index 35e3290635..ac92f65ad9 100644 --- a/src/datadog_api_client/v1/models/__init__.py +++ b/src/datadog_api_client/v1/models/__init__.py @@ -757,6 +757,7 @@ from datadog_api_client.v1.model.synthetics_test_pause_status import SyntheticsTestPauseStatus from datadog_api_client.v1.model.synthetics_test_process_status import SyntheticsTestProcessStatus from datadog_api_client.v1.model.synthetics_test_request import SyntheticsTestRequest +from datadog_api_client.v1.model.synthetics_test_request_body_file import SyntheticsTestRequestBodyFile from datadog_api_client.v1.model.synthetics_test_request_body_type import SyntheticsTestRequestBodyType from datadog_api_client.v1.model.synthetics_test_request_certificate import SyntheticsTestRequestCertificate from datadog_api_client.v1.model.synthetics_test_request_certificate_item import SyntheticsTestRequestCertificateItem @@ -1621,6 +1622,7 @@ "SyntheticsTestPauseStatus", "SyntheticsTestProcessStatus", "SyntheticsTestRequest", + "SyntheticsTestRequestBodyFile", "SyntheticsTestRequestBodyType", "SyntheticsTestRequestCertificate", "SyntheticsTestRequestCertificateItem", diff --git a/tests/v1/cassettes/test_scenarios/test_create_an_api_test_with_a_file_payload_returns_ok_returns_the_created_test_details_response.frozen b/tests/v1/cassettes/test_scenarios/test_create_an_api_test_with_a_file_payload_returns_ok_returns_the_created_test_details_response.frozen new file mode 100644 index 0000000000..42decaa940 --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_create_an_api_test_with_a_file_payload_returns_ok_returns_the_created_test_details_response.frozen @@ -0,0 +1 @@ +2024-04-02T15:35:39.188Z \ No newline at end of file diff --git a/tests/v1/cassettes/test_scenarios/test_create_an_api_test_with_a_file_payload_returns_ok_returns_the_created_test_details_response.yaml b/tests/v1/cassettes/test_scenarios/test_create_an_api_test_with_a_file_payload_returns_ok_returns_the_created_test_details_response.yaml new file mode 100644 index 0000000000..80bf8df5b3 --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_create_an_api_test_with_a_file_payload_returns_ok_returns_the_created_test_details_response.yaml @@ -0,0 +1,45 @@ +interactions: +- request: + body: '{"config":{"assertions":[{"operator":"is","property":"{{ PROPERTY }}","target":"text/html","type":"header"},{"operator":"lessThan","target":2000,"timingsScope":"withoutDNS","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","resource":"resource","scope":"yoyo","tokenApiAuthentication":"header","type":"oauth-client"},"bodyType":"application/octet-stream","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"}},"files":[{"content":"file + content","name":"file name","type":"file type"}],"headers":{"unique":"testcreateanapitestwithafilepayloadreturnsokreturnsthecreatedtestdetailsresponse1712072139"},"method":"GET","persistCookies":true,"proxy":{"headers":{},"url":"https://datadoghq.com"},"timeout":10,"url":"https://datadoghq.com"}},"locations":["aws:us-east-2"],"message":"BDD + test payload: synthetics_api_http_test_payload.json","name":"Test-Create_an_API_test_with_a_file_payload_returns_OK_Returns_the_created_test_details_response-1712072139","options":{"accept_self_signed":false,"allow_insecure":true,"follow_redirects":true,"httpVersion":"http2","min_failure_duration":10,"min_location_failed":1,"monitor_name":"Test-Create_an_API_test_with_a_file_payload_returns_OK_Returns_the_created_test_details_response-1712072139","monitor_priority":5,"retry":{"count":3,"interval":10},"tick_every":60},"subtype":"http","tags":["testing:api"],"type":"api"}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/synthetics/tests/api + response: + body: + string: '{"public_id":"sxp-kz5-mk7","name":"Test-Create_an_API_test_with_a_file_payload_returns_OK_Returns_the_created_test_details_response-1712072139","status":"live","type":"api","tags":["testing:api"],"created_at":"2024-04-02T15:35:40.509801+00:00","modified_at":"2024-04-02T15:35:40.509801+00:00","config":{"assertions":[{"operator":"is","property":"{{ + PROPERTY }}","target":"text/html","type":"header"},{"operator":"lessThan","target":2000,"timingsScope":"withoutDNS","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","resource":"resource","scope":"yoyo","tokenApiAuthentication":"header","type":"oauth-client"},"bodyType":"application/octet-stream","certificate":{"cert":{"filename":"cert-filename","updatedAt":"2020-10-16T09:23:24.857Z"},"key":{"filename":"key-filename","updatedAt":"2020-10-16T09:23:24.857Z"}},"files":[{"name":"file + name","type":"file type","bucketKey":"api-upload-file/sxp-kz5-mk7/2024-04-02T15:35:40.363501_da19b48f-1756-453d-a03d-90526e629d7e.json"}],"headers":{"unique":"testcreateanapitestwithafilepayloadreturnsokreturnsthecreatedtestdetailsresponse1712072139"},"method":"GET","persistCookies":true,"proxy":{"headers":{},"url":"https://datadoghq.com"},"timeout":10,"url":"https://datadoghq.com"}},"message":"BDD + test payload: synthetics_api_http_test_payload.json","options":{"accept_self_signed":false,"allow_insecure":true,"follow_redirects":true,"httpVersion":"http2","min_failure_duration":10,"min_location_failed":1,"monitor_name":"Test-Create_an_API_test_with_a_file_payload_returns_OK_Returns_the_created_test_details_response-1712072139","monitor_priority":5,"retry":{"count":3,"interval":10},"tick_every":60},"locations":["aws:us-east-2"],"subtype":"http","created_by":{"name":null,"handle":"frog@datadoghq.com","email":"frog@datadoghq.com"},"deleted_at":null,"monitor_id":142439982,"org_id":321813,"modified_by":{"name":null,"handle":"frog@datadoghq.com","email":"frog@datadoghq.com"}}' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: '{"public_ids":["sxp-kz5-mk7"]}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/synthetics/tests/delete + response: + body: + string: '{"deleted_tests":[{"public_id":"sxp-kz5-mk7","deleted_at":"2024-04-02T15:35:41.326918+00:00"}]} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +version: 1 diff --git a/tests/v1/features/synthetics.feature b/tests/v1/features/synthetics.feature index 4942cb45e2..64ccdb9469 100644 --- a/tests/v1/features/synthetics.feature +++ b/tests/v1/features/synthetics.feature @@ -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", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "httpVersion": "http1", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "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": [], "files": [{}], "httpVersion": "http1", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "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 @@ -61,7 +61,7 @@ Feature: Synthetics @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", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "httpVersion": "http1", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "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": [], "files": [{}], "httpVersion": "http1", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "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 @@ -193,6 +193,17 @@ Feature: Synthetics Then the response status is 200 OK - Returns the created test details. And the response "name" is equal to "{{ unique }}" + @team:DataDog/synthetics-app + Scenario: Create an API test with a file payload returns "OK - Returns the created test details." response + Given new "CreateSyntheticsAPITest" request + And body from file "synthetics_api_http_test_with_file_payload.json" + 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.request.files[0].name" is equal to "file name" + And the response "config.request.files[0].type" is equal to "file type" + And the response "config.request.files[0]" has field "bucketKey" + @team:DataDog/synthetics-app Scenario: Create an API test with multi subtype returns "OK - Returns the created test details." response Given new "CreateSyntheticsAPITest" request @@ -205,6 +216,7 @@ Feature: Synthetics And the response "config.steps[0].request.httpVersion" is equal to "http2" And the response "config.steps[0].extractedValues[0].secure" is equal to true And the response "config.steps[1].request.host" is equal to "grpcbin.test.k6.io" + And the response "config.steps[1].request.host" is equal to "grpcbin.test.k6.io" @generated @skip @team:DataDog/synthetics-app Scenario: Delete a global variable returns "JSON format is wrong" response @@ -268,7 +280,7 @@ 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", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "httpVersion": "http1", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "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": [], "files": [{}], "httpVersion": "http1", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "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 @@ -276,7 +288,7 @@ Feature: Synthetics 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", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "httpVersion": "http1", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "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": [], "files": [{}], "httpVersion": "http1", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "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 @@ -284,7 +296,7 @@ Feature: Synthetics 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", "secure": false, "type": "text"}], "request": {"basicAuth": {"password": "PaSSw0RD!", "type": "web", "username": "my_username"}, "bodyType": "text/plain", "callType": "unary", "certificate": {"cert": {}, "key": {}}, "certificateDomains": [], "httpVersion": "http1", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "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": [], "files": [{}], "httpVersion": "http1", "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": ["chrome.laptop_large"], "httpVersion": "http1", "monitor_options": {}, "restricted_roles": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], "retry": {}, "rumSettings": {"applicationId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "clientTokenId": 12345, "isEnabled": true}, "scheduling": {"timeframes": [{"day": 1, "from": "07:00", "to": "16:00"}, {"day": 3, "from": "07:00", "to": "16:00"}], "timezone": "America/New_York"}}, "status": "live", "steps": [{"type": "assertElementContent"}], "tags": ["env:prod"], "type": "browser"} When the request is sent Then the response status is 200 OK diff --git a/tests/v1/features/synthetics_api_http_test_with_file_payload.json b/tests/v1/features/synthetics_api_http_test_with_file_payload.json new file mode 100644 index 0000000000..bf4f0e4ad9 --- /dev/null +++ b/tests/v1/features/synthetics_api_http_test_with_file_payload.json @@ -0,0 +1,96 @@ +{ + "config": { + "assertions": [ + { + "operator": "is", + "property": "{{ '{{ PROPERTY }}' }}", + "target": "text/html", + "type": "header" + }, + { "operator": "lessThan", "target": 2000, "type": "responseTime", "timingsScope": "withoutDNS" }, + { + "operator": "validatesJSONPath", + "target": { + "jsonPath": "topKey", + "operator": "isNot", + "targetValue": "0" + }, + "type": "body" + }, + { + "operator": "validatesXPath", + "target": { + "xPath": "target-xpath", + "targetValue": "0", + "operator": "contains" + }, + "type": "body" + } + ], + "configVariables": [ + { + "example": "content-type", + "name": "PROPERTY", + "pattern": "content-type", + "type": "text" + } + ], + "request": { + "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": "{{ unique_lower_alnum }}" }, + "method": "GET", + "timeout": 10, + "url": "https://datadoghq.com", + "proxy": { + "url": "https://datadoghq.com", + "headers": {} + }, + "bodyType": "application/octet-stream", + "files": [{ + "name": "file name", + "content": "file content", + "type": "file type" + }], + "basicAuth": { + "accessTokenUrl": "https://datadog-token.com", + "audience": "audience", + "clientId": "client-id", + "clientSecret": "client-secret", + "resource": "resource", + "scope": "yoyo", + "tokenApiAuthentication": "header", + "type": "oauth-client" + }, + "persistCookies": true + } + }, + "locations": ["aws:us-east-2"], + "message": "BDD test payload: synthetics_api_http_test_payload.json", + "name": "{{ unique }}", + "options": { + "accept_self_signed": false, + "allow_insecure": true, + "follow_redirects": true, + "min_failure_duration": 10, + "min_location_failed": 1, + "monitor_name": "{{ unique }}", + "monitor_priority": 5, + "retry": { "count": 3, "interval": 10 }, + "tick_every": 60, + "httpVersion": "http2" + }, + "subtype": "http", + "tags": ["testing:api"], + "type": "api" + }