From 78c4c6331003f5c80e690f068aeff09dadcc7070 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Mon, 4 Dec 2023 18:57:12 +0000 Subject: [PATCH] Enable delete and update aws tests (#2294) * Regenerate client from commit 8855a8d3 of spec repo * Adds Origin support for Given * Regenerate client from commit 07df9ec5 of spec repo --------- Co-authored-by: ci.datadog-api-spec Co-authored-by: HantingZhang2 --- .apigentools-info | 8 +-- .../v1/aws-integration/DeleteAWSAccount.go | 2 +- .../v1/aws-integration/UpdateAWSAccount.go | 10 +-- tests/scenarios/actions.go | 1 + ...AWS_integration_returns_OK_response.freeze | 1 + ...n_AWS_integration_returns_OK_response.yaml | 63 +++++++++++++++++++ ...AWS_integration_returns_OK_response.freeze | 2 +- ...n_AWS_integration_returns_OK_response.yaml | 52 +++++++++++++-- .../features/v1/aws_integration.feature | 18 +++--- tests/scenarios/features/v1/given.json | 13 ++++ 10 files changed, 147 insertions(+), 23 deletions(-) create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Delete_an_AWS_integration_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Delete_an_AWS_integration_returns_OK_response.yaml diff --git a/.apigentools-info b/.apigentools-info index 9637da36f4e..246dd6a866a 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2023-12-04 15:37:48.058716", - "spec_repo_commit": "e66bf244" + "regenerated": "2023-12-04 18:32:07.810092", + "spec_repo_commit": "07df9ec5" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2023-12-04 15:37:48.084181", - "spec_repo_commit": "e66bf244" + "regenerated": "2023-12-04 18:32:07.832646", + "spec_repo_commit": "07df9ec5" } } } \ No newline at end of file diff --git a/examples/v1/aws-integration/DeleteAWSAccount.go b/examples/v1/aws-integration/DeleteAWSAccount.go index 6e6fd248918..57a3e1001b4 100644 --- a/examples/v1/aws-integration/DeleteAWSAccount.go +++ b/examples/v1/aws-integration/DeleteAWSAccount.go @@ -14,7 +14,7 @@ import ( func main() { body := datadogV1.AWSAccountDeleteRequest{ - AccountId: datadog.PtrString("123456789012"), + AccountId: datadog.PtrString("163662907100"), RoleName: datadog.PtrString("DatadogAWSIntegrationRole"), } ctx := datadog.NewDefaultContext(context.Background()) diff --git a/examples/v1/aws-integration/UpdateAWSAccount.go b/examples/v1/aws-integration/UpdateAWSAccount.go index c2fa08291c0..3fcba70059b 100644 --- a/examples/v1/aws-integration/UpdateAWSAccount.go +++ b/examples/v1/aws-integration/UpdateAWSAccount.go @@ -14,11 +14,11 @@ import ( func main() { body := datadogV1.AWSAccount{ - AccountId: datadog.PtrString("123456789012"), + AccountId: datadog.PtrString("163662907100"), AccountSpecificNamespaceRules: map[string]bool{ "auto_scaling": false, }, - CspmResourceCollectionEnabled: datadog.PtrBool(true), + CspmResourceCollectionEnabled: datadog.PtrBool(false), ExcludedRegions: []string{ "us-east-1", "us-west-2", @@ -29,15 +29,15 @@ func main() { HostTags: []string{ "$KEY:$VALUE", }, - MetricsCollectionEnabled: datadog.PtrBool(false), + MetricsCollectionEnabled: datadog.PtrBool(true), ResourceCollectionEnabled: datadog.PtrBool(true), - RoleName: datadog.PtrString("datadog-role"), + RoleName: datadog.PtrString("DatadogAWSIntegrationRole"), } ctx := datadog.NewDefaultContext(context.Background()) configuration := datadog.NewConfiguration() apiClient := datadog.NewAPIClient(configuration) api := datadogV1.NewAWSIntegrationApi(apiClient) - resp, r, err := api.UpdateAWSAccount(ctx, body, *datadogV1.NewUpdateAWSAccountOptionalParameters().WithAccountId("123456789012").WithRoleName("datadog-role")) + resp, r, err := api.UpdateAWSAccount(ctx, body, *datadogV1.NewUpdateAWSAccountOptionalParameters().WithAccountId("163662907100").WithRoleName("DatadogAWSIntegrationRole")) if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `AWSIntegrationApi.UpdateAWSAccount`: %v\n", err) diff --git a/tests/scenarios/actions.go b/tests/scenarios/actions.go index 92537484ca7..1c644de5d4a 100644 --- a/tests/scenarios/actions.go +++ b/tests/scenarios/actions.go @@ -45,6 +45,7 @@ type operationParameter struct { Name string `json:"name"` Source *string `json:"source"` Value *string `json:"value"` + Origin *string `json:"origin"` } func (p operationParameter) Resolve(t gobdd.StepTest, ctx gobdd.Context, tp reflect.Type) reflect.Value { diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Delete_an_AWS_integration_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Delete_an_AWS_integration_returns_OK_response.freeze new file mode 100644 index 00000000000..e3ae39811fa --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Delete_an_AWS_integration_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-11-21T19:25:15.118Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Delete_an_AWS_integration_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Delete_an_AWS_integration_returns_OK_response.yaml new file mode 100644 index 00000000000..768b72cd3d1 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Delete_an_AWS_integration_returns_OK_response.yaml @@ -0,0 +1,63 @@ +interactions: +- request: + body: | + {"account_id":"170059471500","account_specific_namespace_rules":{"auto_scaling":false},"cspm_resource_collection_enabled":true,"excluded_regions":["us-east-1","us-west-2"],"filter_tags":["$KEY:$VALUE"],"host_tags":["$KEY:$VALUE"],"metrics_collection_enabled":false,"resource_collection_enabled":true,"role_name":"DatadogAWSIntegrationRole"} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v1/integration/aws + response: + body: '{"external_id":"77c77ead62584b0fa1bb6a9fe7d2fa28"} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: | + {"account_id":"170059471500","role_name":"DatadogAWSIntegrationRole"} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: DELETE + url: https://api.datadoghq.com/api/v1/integration/aws + response: + body: '{} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: | + {"account_id":"170059471500","role_name":"DatadogAWSIntegrationRole"} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: DELETE + url: https://api.datadoghq.com/api/v1/integration/aws + response: + body: '{"errors":["AWS account 170059471500 does not exist in integration"]}' + code: 400 + duration: '' + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Update_an_AWS_integration_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Update_an_AWS_integration_returns_OK_response.freeze index c139a36bd51..34d80ee0cd5 100644 --- a/tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Update_an_AWS_integration_returns_OK_response.freeze +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Update_an_AWS_integration_returns_OK_response.freeze @@ -1 +1 @@ -2022-05-17T15:38:07.190Z \ No newline at end of file +2023-11-23T18:16:16.323Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Update_an_AWS_integration_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Update_an_AWS_integration_returns_OK_response.yaml index 35436c55f89..305049eada5 100644 --- a/tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Update_an_AWS_integration_returns_OK_response.yaml +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_AWS_Integration/Scenario_Update_an_AWS_integration_returns_OK_response.yaml @@ -1,7 +1,28 @@ interactions: - request: body: | - {"account_id":"123456789012","account_specific_namespace_rules":{"auto_scaling":false},"cspm_resource_collection_enabled":true,"excluded_regions":["us-east-1","us-west-2"],"filter_tags":["$KEY:$VALUE"],"host_tags":["$KEY:$VALUE"],"metrics_collection_enabled":false,"resource_collection_enabled":true,"role_name":"datadog-role"} + {"account_id":"170076337600","account_specific_namespace_rules":{"auto_scaling":false},"cspm_resource_collection_enabled":true,"excluded_regions":["us-east-1","us-west-2"],"filter_tags":["$KEY:$VALUE"],"host_tags":["$KEY:$VALUE"],"metrics_collection_enabled":false,"resource_collection_enabled":true,"role_name":"DatadogAWSIntegrationRole"} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v1/integration/aws + response: + body: '{"external_id":"c7298c166e774bf1bd1bc0419e68f1a0"} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: | + {"account_id":"170076337600","account_specific_namespace_rules":{"auto_scaling":false},"cspm_resource_collection_enabled":false,"excluded_regions":["us-east-1","us-west-2"],"filter_tags":["$KEY:$VALUE"],"host_tags":["$KEY:$VALUE"],"metrics_collection_enabled":true,"resource_collection_enabled":true,"role_name":"DatadogAWSIntegrationRole"} form: {} headers: Accept: @@ -9,13 +30,36 @@ interactions: Content-Type: - application/json method: PUT - url: https://api.datadoghq.com/api/v1/integration/aws?account_id=123456789012&role_name=datadog-role + url: https://api.datadoghq.com/api/v1/integration/aws?account_id=170076337600&role_name=DatadogAWSIntegrationRole response: - body: '{}' + body: '{} + + ' code: 200 duration: '' headers: Content-Type: - - application/json;charset=utf-8 + - application/json + status: 200 OK +- request: + body: | + {"account_id":"170076337600","role_name":"DatadogAWSIntegrationRole"} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: DELETE + url: https://api.datadoghq.com/api/v1/integration/aws + response: + body: '{} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json status: 200 OK version: 1 diff --git a/tests/scenarios/features/v1/aws_integration.feature b/tests/scenarios/features/v1/aws_integration.feature index 6adfe4764f9..b37be660e0e 100644 --- a/tests/scenarios/features/v1/aws_integration.feature +++ b/tests/scenarios/features/v1/aws_integration.feature @@ -72,10 +72,11 @@ Feature: AWS Integration When the request is sent Then the response status is 409 Conflict Error - @generated @skip @team:DataDog/cloud-integrations + @team:DataDog/cloud-integrations Scenario: Delete an AWS integration returns "OK" response - Given new "DeleteAWSAccount" request - And body with value {"account_id": "123456789012", "role_name": "DatadogAWSIntegrationRole"} + Given there is a valid "aws_account" in the system + And new "DeleteAWSAccount" request + And body with value {"account_id": "{{ timestamp("now") }}00", "role_name": "DatadogAWSIntegrationRole"} When the request is sent Then the response status is 200 OK @@ -179,11 +180,12 @@ Feature: AWS Integration When the request is sent Then the response status is 409 Conflict Error - @replay-only @skip-typescript @team:DataDog/cloud-integrations + @team:DataDog/cloud-integrations Scenario: Update an AWS integration returns "OK" response - Given new "UpdateAWSAccount" request - And body with value {"account_id": "123456789012", "account_specific_namespace_rules": {"auto_scaling": false}, "cspm_resource_collection_enabled": true, "excluded_regions": ["us-east-1", "us-west-2"], "filter_tags": ["$KEY:$VALUE"], "host_tags": ["$KEY:$VALUE"], "metrics_collection_enabled": false, "resource_collection_enabled": true, "role_name": "datadog-role"} - And request contains "account_id" parameter with value "123456789012" - And request contains "role_name" parameter with value "datadog-role" + Given there is a valid "aws_account" in the system + And new "UpdateAWSAccount" request + And body with value {"account_id": "{{ timestamp("now") }}00", "account_specific_namespace_rules": {"auto_scaling": false}, "cspm_resource_collection_enabled": false, "excluded_regions": ["us-east-1", "us-west-2"], "filter_tags": ["$KEY:$VALUE"], "host_tags": ["$KEY:$VALUE"], "metrics_collection_enabled": true, "resource_collection_enabled": true, "role_name": "DatadogAWSIntegrationRole"} + And request contains "account_id" parameter with value "{{ timestamp("now") }}00" + And request contains "role_name" parameter with value "DatadogAWSIntegrationRole" When the request is sent Then the response status is 200 OK diff --git a/tests/scenarios/features/v1/given.json b/tests/scenarios/features/v1/given.json index ea1945985bc..02854bcd670 100644 --- a/tests/scenarios/features/v1/given.json +++ b/tests/scenarios/features/v1/given.json @@ -99,6 +99,19 @@ "tag": "Downtimes", "operationId": "CreateDowntime" }, + { + "parameters": [ + { + "name": "body", + "origin": "request", + "value": "{\n \"account_id\": \"{{ timestamp(\"now\") }}00\",\n \"account_specific_namespace_rules\": {\n \"auto_scaling\": false\n },\n \"cspm_resource_collection_enabled\": true,\n \"excluded_regions\": [\n \"us-east-1\",\n \"us-west-2\"\n ],\n \"filter_tags\": [\n \"$KEY:$VALUE\"\n ],\n \"host_tags\": [\n \"$KEY:$VALUE\"\n ],\n \"metrics_collection_enabled\": false,\n \"resource_collection_enabled\": true,\n \"role_name\": \"DatadogAWSIntegrationRole\"\n}" + } + ], + "step": "there is a valid \"aws_account\" in the system", + "key": "aws_account", + "tag": "AWS Integration", + "operationId": "CreateAWSAccount" + }, { "parameters": [ {