Skip to content

Commit

Permalink
Enable delete and update aws tests (#2294)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: HantingZhang2 <[email protected]>
  • Loading branch information
3 people authored Dec 4, 2023
1 parent 4716685 commit 78c4c63
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 23 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.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"
}
}
}
2 changes: 1 addition & 1 deletion examples/v1/aws-integration/DeleteAWSAccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
10 changes: 5 additions & 5 deletions examples/v1/aws-integration/UpdateAWSAccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions tests/scenarios/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023-11-21T19:25:15.118Z
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2022-05-17T15:38:07.190Z
2023-11-23T18:16:16.323Z
Original file line number Diff line number Diff line change
@@ -1,21 +1,65 @@
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:
- application/json
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
18 changes: 10 additions & 8 deletions tests/scenarios/features/v1/aws_integration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
13 changes: 13 additions & 0 deletions tests/scenarios/features/v1/given.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down

0 comments on commit 78c4c63

Please sign in to comment.