From 19cf15e02f85d4362f874227671d31ad6fb0125b Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 17:53:01 +0000 Subject: [PATCH] Support providing files for the file upload feature when creating a Synthetic API test (#2460) Co-authored-by: ci.datadog-api-spec Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> --- .apigentools-info | 8 +- .generator/schemas/v1/openapi.yaml | 35 +++ .../model_synthetics_test_request.go | 37 ++- ...model_synthetics_test_request_body_file.go | 242 ++++++++++++++++++ ...model_synthetics_test_request_body_type.go | 4 + .../CreateSyntheticsAPITest_1241981394.go | 146 +++++++++++ examples/v1/synthetics/UpdateBrowserTest.go | 5 +- ..._the_created_test_details._response.freeze | 1 + ...ns_the_created_test_details._response.yaml | 47 ++++ .../scenarios/features/v1/synthetics.feature | 22 +- ...etics_api_http_test_with_file_payload.json | 96 +++++++ 11 files changed, 632 insertions(+), 11 deletions(-) create mode 100644 api/datadogV1/model_synthetics_test_request_body_file.go create mode 100644 examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.go create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Synthetics/Scenario_Create_an_API_test_with_a_file_payload_returns_OK_-_Returns_the_created_test_details._response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Synthetics/Scenario_Create_an_API_test_with_a_file_payload_returns_OK_-_Returns_the_created_test_details._response.yaml create mode 100644 tests/scenarios/features/v1/synthetics_api_http_test_with_file_payload.json diff --git a/.apigentools-info b/.apigentools-info index 83d4021b345..e20057ec8e3 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-04-04 19:22:30.504579", - "spec_repo_commit": "fd06108d" + "regenerated": "2024-04-05 17:05:08.760606", + "spec_repo_commit": "9b7c8967" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-04-04 19:22:30.523928", - "spec_repo_commit": "fd06108d" + "regenerated": "2024-04-05 17:05:08.779289", + "spec_repo_commit": "9b7c8967" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 228f2933623..e08c005f426 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -15871,6 +15871,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 @@ -15937,6 +15942,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: @@ -15946,6 +15977,8 @@ components: - text/html - application/x-www-form-urlencoded - graphql + - application/octet-stream + - multipart/form-data example: text/plain type: string x-enum-varnames: @@ -15955,6 +15988,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/api/datadogV1/model_synthetics_test_request.go b/api/datadogV1/model_synthetics_test_request.go index b1663210ce8..17f9089cd59 100644 --- a/api/datadogV1/model_synthetics_test_request.go +++ b/api/datadogV1/model_synthetics_test_request.go @@ -32,6 +32,8 @@ type SyntheticsTestRequest struct { DnsServer *string `json:"dnsServer,omitempty"` // DNS server port to use for DNS tests. DnsServerPort *int32 `json:"dnsServerPort,omitempty"` + // Files to be used as part of the request in the test. + Files []SyntheticsTestRequestBodyFile `json:"files,omitempty"` // Specifies whether or not the request follows redirects. FollowRedirects *bool `json:"follow_redirects,omitempty"` // Headers to include when performing the test. @@ -400,6 +402,34 @@ func (o *SyntheticsTestRequest) SetDnsServerPort(v int32) { o.DnsServerPort = &v } +// GetFiles returns the Files field value if set, zero value otherwise. +func (o *SyntheticsTestRequest) GetFiles() []SyntheticsTestRequestBodyFile { + if o == nil || o.Files == nil { + var ret []SyntheticsTestRequestBodyFile + return ret + } + return o.Files +} + +// GetFilesOk returns a tuple with the Files field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsTestRequest) GetFilesOk() (*[]SyntheticsTestRequestBodyFile, bool) { + if o == nil || o.Files == nil { + return nil, false + } + return &o.Files, true +} + +// HasFiles returns a boolean if a field has been set. +func (o *SyntheticsTestRequest) HasFiles() bool { + return o != nil && o.Files != nil +} + +// SetFiles gets a reference to the given []SyntheticsTestRequestBodyFile and assigns it to the Files field. +func (o *SyntheticsTestRequest) SetFiles(v []SyntheticsTestRequestBodyFile) { + o.Files = v +} + // GetFollowRedirects returns the FollowRedirects field value if set, zero value otherwise. func (o *SyntheticsTestRequest) GetFollowRedirects() bool { if o == nil || o.FollowRedirects == nil { @@ -943,6 +973,9 @@ func (o SyntheticsTestRequest) MarshalJSON() ([]byte, error) { if o.DnsServerPort != nil { toSerialize["dnsServerPort"] = o.DnsServerPort } + if o.Files != nil { + toSerialize["files"] = o.Files + } if o.FollowRedirects != nil { toSerialize["follow_redirects"] = o.FollowRedirects } @@ -1018,6 +1051,7 @@ func (o *SyntheticsTestRequest) UnmarshalJSON(bytes []byte) (err error) { CompressedProtoFile *string `json:"compressedProtoFile,omitempty"` DnsServer *string `json:"dnsServer,omitempty"` DnsServerPort *int32 `json:"dnsServerPort,omitempty"` + Files []SyntheticsTestRequestBodyFile `json:"files,omitempty"` FollowRedirects *bool `json:"follow_redirects,omitempty"` Headers map[string]string `json:"headers,omitempty"` Host *string `json:"host,omitempty"` @@ -1042,7 +1076,7 @@ func (o *SyntheticsTestRequest) UnmarshalJSON(bytes []byte) (err error) { } additionalProperties := make(map[string]interface{}) if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"allow_insecure", "basicAuth", "body", "bodyType", "callType", "certificate", "certificateDomains", "compressedJsonDescriptor", "compressedProtoFile", "dnsServer", "dnsServerPort", "follow_redirects", "headers", "host", "httpVersion", "message", "metadata", "method", "noSavingResponseBody", "numberOfPackets", "persistCookies", "port", "proxy", "query", "servername", "service", "shouldTrackHops", "timeout", "url"}) + datadog.DeleteKeys(additionalProperties, &[]string{"allow_insecure", "basicAuth", "body", "bodyType", "callType", "certificate", "certificateDomains", "compressedJsonDescriptor", "compressedProtoFile", "dnsServer", "dnsServerPort", "files", "follow_redirects", "headers", "host", "httpVersion", "message", "metadata", "method", "noSavingResponseBody", "numberOfPackets", "persistCookies", "port", "proxy", "query", "servername", "service", "shouldTrackHops", "timeout", "url"}) } else { return err } @@ -1070,6 +1104,7 @@ func (o *SyntheticsTestRequest) UnmarshalJSON(bytes []byte) (err error) { o.CompressedProtoFile = all.CompressedProtoFile o.DnsServer = all.DnsServer o.DnsServerPort = all.DnsServerPort + o.Files = all.Files o.FollowRedirects = all.FollowRedirects o.Headers = all.Headers o.Host = all.Host diff --git a/api/datadogV1/model_synthetics_test_request_body_file.go b/api/datadogV1/model_synthetics_test_request_body_file.go new file mode 100644 index 00000000000..0eb0ff0c5ea --- /dev/null +++ b/api/datadogV1/model_synthetics_test_request_body_file.go @@ -0,0 +1,242 @@ +// 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. + +package datadogV1 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsTestRequestBodyFile Object describing a file to be used as part of the request in the test. +type SyntheticsTestRequestBodyFile struct { + // Bucket key of the file. + BucketKey *string `json:"bucketKey,omitempty"` + // Content of the file. + Content *string `json:"content,omitempty"` + // Name of the file. + Name *string `json:"name,omitempty"` + // Size of the file. + Size *int64 `json:"size,omitempty"` + // Type of the file. + Type *string `json:"type,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewSyntheticsTestRequestBodyFile instantiates a new SyntheticsTestRequestBodyFile object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSyntheticsTestRequestBodyFile() *SyntheticsTestRequestBodyFile { + this := SyntheticsTestRequestBodyFile{} + return &this +} + +// NewSyntheticsTestRequestBodyFileWithDefaults instantiates a new SyntheticsTestRequestBodyFile object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewSyntheticsTestRequestBodyFileWithDefaults() *SyntheticsTestRequestBodyFile { + this := SyntheticsTestRequestBodyFile{} + return &this +} + +// GetBucketKey returns the BucketKey field value if set, zero value otherwise. +func (o *SyntheticsTestRequestBodyFile) GetBucketKey() string { + if o == nil || o.BucketKey == nil { + var ret string + return ret + } + return *o.BucketKey +} + +// GetBucketKeyOk returns a tuple with the BucketKey field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsTestRequestBodyFile) GetBucketKeyOk() (*string, bool) { + if o == nil || o.BucketKey == nil { + return nil, false + } + return o.BucketKey, true +} + +// HasBucketKey returns a boolean if a field has been set. +func (o *SyntheticsTestRequestBodyFile) HasBucketKey() bool { + return o != nil && o.BucketKey != nil +} + +// SetBucketKey gets a reference to the given string and assigns it to the BucketKey field. +func (o *SyntheticsTestRequestBodyFile) SetBucketKey(v string) { + o.BucketKey = &v +} + +// GetContent returns the Content field value if set, zero value otherwise. +func (o *SyntheticsTestRequestBodyFile) GetContent() string { + if o == nil || o.Content == nil { + var ret string + return ret + } + return *o.Content +} + +// GetContentOk returns a tuple with the Content field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsTestRequestBodyFile) GetContentOk() (*string, bool) { + if o == nil || o.Content == nil { + return nil, false + } + return o.Content, true +} + +// HasContent returns a boolean if a field has been set. +func (o *SyntheticsTestRequestBodyFile) HasContent() bool { + return o != nil && o.Content != nil +} + +// SetContent gets a reference to the given string and assigns it to the Content field. +func (o *SyntheticsTestRequestBodyFile) SetContent(v string) { + o.Content = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *SyntheticsTestRequestBodyFile) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsTestRequestBodyFile) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *SyntheticsTestRequestBodyFile) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *SyntheticsTestRequestBodyFile) SetName(v string) { + o.Name = &v +} + +// GetSize returns the Size field value if set, zero value otherwise. +func (o *SyntheticsTestRequestBodyFile) GetSize() int64 { + if o == nil || o.Size == nil { + var ret int64 + return ret + } + return *o.Size +} + +// GetSizeOk returns a tuple with the Size field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsTestRequestBodyFile) GetSizeOk() (*int64, bool) { + if o == nil || o.Size == nil { + return nil, false + } + return o.Size, true +} + +// HasSize returns a boolean if a field has been set. +func (o *SyntheticsTestRequestBodyFile) HasSize() bool { + return o != nil && o.Size != nil +} + +// SetSize gets a reference to the given int64 and assigns it to the Size field. +func (o *SyntheticsTestRequestBodyFile) SetSize(v int64) { + o.Size = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *SyntheticsTestRequestBodyFile) GetType() string { + if o == nil || o.Type == nil { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsTestRequestBodyFile) GetTypeOk() (*string, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *SyntheticsTestRequestBodyFile) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *SyntheticsTestRequestBodyFile) SetType(v string) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsTestRequestBodyFile) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.BucketKey != nil { + toSerialize["bucketKey"] = o.BucketKey + } + if o.Content != nil { + toSerialize["content"] = o.Content + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Size != nil { + toSerialize["size"] = o.Size + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsTestRequestBodyFile) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + BucketKey *string `json:"bucketKey,omitempty"` + Content *string `json:"content,omitempty"` + Name *string `json:"name,omitempty"` + Size *int64 `json:"size,omitempty"` + Type *string `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"bucketKey", "content", "name", "size", "type"}) + } else { + return err + } + o.BucketKey = all.BucketKey + o.Content = all.Content + o.Name = all.Name + o.Size = all.Size + o.Type = all.Type + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV1/model_synthetics_test_request_body_type.go b/api/datadogV1/model_synthetics_test_request_body_type.go index bda04fb419d..490a4b49561 100644 --- a/api/datadogV1/model_synthetics_test_request_body_type.go +++ b/api/datadogV1/model_synthetics_test_request_body_type.go @@ -21,6 +21,8 @@ const ( SYNTHETICSTESTREQUESTBODYTYPE_TEXT_HTML SyntheticsTestRequestBodyType = "text/html" SYNTHETICSTESTREQUESTBODYTYPE_APPLICATION_X_WWW_FORM_URLENCODED SyntheticsTestRequestBodyType = "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" ) var allowedSyntheticsTestRequestBodyTypeEnumValues = []SyntheticsTestRequestBodyType{ @@ -30,6 +32,8 @@ var allowedSyntheticsTestRequestBodyTypeEnumValues = []SyntheticsTestRequestBody SYNTHETICSTESTREQUESTBODYTYPE_TEXT_HTML, SYNTHETICSTESTREQUESTBODYTYPE_APPLICATION_X_WWW_FORM_URLENCODED, SYNTHETICSTESTREQUESTBODYTYPE_GRAPHQL, + SYNTHETICSTESTREQUESTBODYTYPE_APPLICATION_OCTET_STREAM, + SYNTHETICSTESTREQUESTBODYTYPE_MULTIPART_FORM_DATA, } // GetAllowedValues reeturns the list of possible values. diff --git a/examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.go b/examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.go new file mode 100644 index 00000000000..88de714bc7e --- /dev/null +++ b/examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.go @@ -0,0 +1,146 @@ +// Create an API test with a file payload returns "OK - Returns the created test details." response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV1" +) + +func main() { + body := datadogV1.SyntheticsAPITest{ + Config: datadogV1.SyntheticsAPITestConfig{ + Assertions: []datadogV1.SyntheticsAssertion{ + datadogV1.SyntheticsAssertion{ + SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{ + Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_IS, + Property: datadog.PtrString("{{ PROPERTY }}"), + Target: "text/html", + Type: datadogV1.SYNTHETICSASSERTIONTYPE_HEADER, + }}, + datadogV1.SyntheticsAssertion{ + SyntheticsAssertionTarget: &datadogV1.SyntheticsAssertionTarget{ + Operator: datadogV1.SYNTHETICSASSERTIONOPERATOR_LESS_THAN, + Target: 2000, + Type: datadogV1.SYNTHETICSASSERTIONTYPE_RESPONSE_TIME, + TimingsScope: datadogV1.SYNTHETICSASSERTIONTIMINGSSCOPE_WITHOUT_DNS.Ptr(), + }}, + datadogV1.SyntheticsAssertion{ + SyntheticsAssertionJSONPathTarget: &datadogV1.SyntheticsAssertionJSONPathTarget{ + Operator: datadogV1.SYNTHETICSASSERTIONJSONPATHOPERATOR_VALIDATES_JSON_PATH, + Target: &datadogV1.SyntheticsAssertionJSONPathTargetTarget{ + JsonPath: datadog.PtrString("topKey"), + Operator: datadog.PtrString("isNot"), + TargetValue: "0", + }, + Type: datadogV1.SYNTHETICSASSERTIONTYPE_BODY, + }}, + datadogV1.SyntheticsAssertion{ + SyntheticsAssertionXPathTarget: &datadogV1.SyntheticsAssertionXPathTarget{ + Operator: datadogV1.SYNTHETICSASSERTIONXPATHOPERATOR_VALIDATES_X_PATH, + Target: &datadogV1.SyntheticsAssertionXPathTargetTarget{ + XPath: datadog.PtrString("target-xpath"), + TargetValue: "0", + Operator: datadog.PtrString("contains"), + }, + Type: datadogV1.SYNTHETICSASSERTIONTYPE_BODY, + }}, + }, + ConfigVariables: []datadogV1.SyntheticsConfigVariable{ + { + Example: datadog.PtrString("content-type"), + Name: "PROPERTY", + Pattern: datadog.PtrString("content-type"), + Type: datadogV1.SYNTHETICSCONFIGVARIABLETYPE_TEXT, + }, + }, + Request: &datadogV1.SyntheticsTestRequest{ + Certificate: &datadogV1.SyntheticsTestRequestCertificate{ + Cert: &datadogV1.SyntheticsTestRequestCertificateItem{ + Content: datadog.PtrString("cert-content"), + Filename: datadog.PtrString("cert-filename"), + UpdatedAt: datadog.PtrString("2020-10-16T09:23:24.857Z"), + }, + Key: &datadogV1.SyntheticsTestRequestCertificateItem{ + Content: datadog.PtrString("key-content"), + Filename: datadog.PtrString("key-filename"), + UpdatedAt: datadog.PtrString("2020-10-16T09:23:24.857Z"), + }, + }, + Headers: map[string]string{ + "unique": "examplesynthetic", + }, + Method: datadog.PtrString("GET"), + Timeout: datadog.PtrFloat64(10), + Url: datadog.PtrString("https://datadoghq.com"), + Proxy: &datadogV1.SyntheticsTestRequestProxy{ + Url: "https://datadoghq.com", + Headers: map[string]string{}, + }, + BodyType: datadogV1.SYNTHETICSTESTREQUESTBODYTYPE_APPLICATION_OCTET_STREAM.Ptr(), + Files: []datadogV1.SyntheticsTestRequestBodyFile{ + { + Name: datadog.PtrString("file name"), + Content: datadog.PtrString("file content"), + Type: datadog.PtrString("file type"), + }, + }, + BasicAuth: &datadogV1.SyntheticsBasicAuth{ + SyntheticsBasicAuthOauthClient: &datadogV1.SyntheticsBasicAuthOauthClient{ + AccessTokenUrl: "https://datadog-token.com", + Audience: datadog.PtrString("audience"), + ClientId: "client-id", + ClientSecret: "client-secret", + Resource: datadog.PtrString("resource"), + Scope: datadog.PtrString("yoyo"), + TokenApiAuthentication: datadogV1.SYNTHETICSBASICAUTHOAUTHTOKENAPIAUTHENTICATION_HEADER, + Type: datadogV1.SYNTHETICSBASICAUTHOAUTHCLIENTTYPE_OAUTH_CLIENT.Ptr(), + }}, + PersistCookies: datadog.PtrBool(true), + }, + }, + Locations: []string{ + "aws:us-east-2", + }, + Message: "BDD test payload: synthetics_api_http_test_payload.json", + Name: "Example-Synthetic", + Options: datadogV1.SyntheticsTestOptions{ + AcceptSelfSigned: datadog.PtrBool(false), + AllowInsecure: datadog.PtrBool(true), + FollowRedirects: datadog.PtrBool(true), + MinFailureDuration: datadog.PtrInt64(10), + MinLocationFailed: datadog.PtrInt64(1), + MonitorName: datadog.PtrString("Example-Synthetic"), + MonitorPriority: datadog.PtrInt32(5), + Retry: &datadogV1.SyntheticsTestOptionsRetry{ + Count: datadog.PtrInt64(3), + Interval: datadog.PtrFloat64(10), + }, + TickEvery: datadog.PtrInt64(60), + HttpVersion: datadogV1.SYNTHETICSTESTOPTIONSHTTPVERSION_HTTP2.Ptr(), + }, + Subtype: datadogV1.SYNTHETICSTESTDETAILSSUBTYPE_HTTP.Ptr(), + Tags: []string{ + "testing:api", + }, + Type: datadogV1.SYNTHETICSAPITESTTYPE_API, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV1.NewSyntheticsApi(apiClient) + resp, r, err := api.CreateSyntheticsAPITest(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.CreateSyntheticsAPITest`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.CreateSyntheticsAPITest`:\n%s\n", responseContent) +} diff --git a/examples/v1/synthetics/UpdateBrowserTest.go b/examples/v1/synthetics/UpdateBrowserTest.go index 0679c2351d4..1927ea29176 100644 --- a/examples/v1/synthetics/UpdateBrowserTest.go +++ b/examples/v1/synthetics/UpdateBrowserTest.go @@ -37,7 +37,10 @@ func main() { Key: &datadogV1.SyntheticsTestRequestCertificateItem{}, }, CertificateDomains: []string{}, - HttpVersion: datadogV1.SYNTHETICSTESTOPTIONSHTTPVERSION_HTTP1.Ptr(), + Files: []datadogV1.SyntheticsTestRequestBodyFile{ + {}, + }, + HttpVersion: datadogV1.SYNTHETICSTESTOPTIONSHTTPVERSION_HTTP1.Ptr(), Proxy: &datadogV1.SyntheticsTestRequestProxy{ Url: "https://example.com", }, diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Synthetics/Scenario_Create_an_API_test_with_a_file_payload_returns_OK_-_Returns_the_created_test_details._response.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Synthetics/Scenario_Create_an_API_test_with_a_file_payload_returns_OK_-_Returns_the_created_test_details._response.freeze new file mode 100644 index 00000000000..42decaa9400 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Synthetics/Scenario_Create_an_API_test_with_a_file_payload_returns_OK_-_Returns_the_created_test_details._response.freeze @@ -0,0 +1 @@ +2024-04-02T15:35:39.188Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Synthetics/Scenario_Create_an_API_test_with_a_file_payload_returns_OK_-_Returns_the_created_test_details._response.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Synthetics/Scenario_Create_an_API_test_with_a_file_payload_returns_OK_-_Returns_the_created_test_details._response.yaml new file mode 100644 index 00000000000..27d55d93ec5 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Synthetics/Scenario_Create_an_API_test_with_a_file_payload_returns_OK_-_Returns_the_created_test_details._response.yaml @@ -0,0 +1,47 @@ +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"} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v1/synthetics/tests/api + response: + body: '{"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"}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: | + {"public_ids":["sxp-kz5-mk7"]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: POST + url: https://api.datadoghq.com/api/v1/synthetics/tests/delete + response: + body: '{"deleted_tests":[{"public_id":"sxp-kz5-mk7","deleted_at":"2024-04-02T15:35:41.326918+00:00"}]} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +version: 2 diff --git a/tests/scenarios/features/v1/synthetics.feature b/tests/scenarios/features/v1/synthetics.feature index 4942cb45e28..64ccdb94695 100644 --- a/tests/scenarios/features/v1/synthetics.feature +++ b/tests/scenarios/features/v1/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/scenarios/features/v1/synthetics_api_http_test_with_file_payload.json b/tests/scenarios/features/v1/synthetics_api_http_test_with_file_payload.json new file mode 100644 index 00000000000..bf4f0e4ad95 --- /dev/null +++ b/tests/scenarios/features/v1/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" + }