Skip to content

Commit bc4041c

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
[OMG-1161] Update BDD tests for Teams API (#3880)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 53617fb commit bc4041c

7 files changed

Lines changed: 261 additions & 6 deletions

examples/v2/teams/DeleteTeamMembership.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ func main() {
1515
// there is a valid "dd_team" in the system
1616
DdTeamDataID := os.Getenv("DD_TEAM_DATA_ID")
1717

18+
// there is a valid "user" in the system
19+
UserDataID := os.Getenv("USER_DATA_ID")
20+
1821
ctx := datadog.NewDefaultContext(context.Background())
1922
configuration := datadog.NewConfiguration()
2023
apiClient := datadog.NewAPIClient(configuration)
2124
api := datadogV2.NewTeamsApi(apiClient)
22-
r, err := api.DeleteTeamMembership(ctx, DdTeamDataID, "user_id")
25+
r, err := api.DeleteTeamMembership(ctx, DdTeamDataID, UserDataID)
2326

2427
if err != nil {
2528
fmt.Fprintf(os.Stderr, "Error when calling `TeamsApi.DeleteTeamMembership`: %v\n", err)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Update a team with partial update returns "OK" response
2+
3+
package main
4+
5+
import (
6+
"context"
7+
"encoding/json"
8+
"fmt"
9+
"os"
10+
11+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
12+
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
13+
)
14+
15+
func main() {
16+
// there is a valid "dd_team" in the system
17+
DdTeamDataAttributesHandle := os.Getenv("DD_TEAM_DATA_ATTRIBUTES_HANDLE")
18+
DdTeamDataID := os.Getenv("DD_TEAM_DATA_ID")
19+
20+
body := datadogV2.TeamUpdateRequest{
21+
Data: datadogV2.TeamUpdate{
22+
Attributes: datadogV2.TeamUpdateAttributes{
23+
Handle: DdTeamDataAttributesHandle,
24+
Name: "Example Team updated",
25+
},
26+
Type: datadogV2.TEAMTYPE_TEAM,
27+
},
28+
}
29+
ctx := datadog.NewDefaultContext(context.Background())
30+
configuration := datadog.NewConfiguration()
31+
apiClient := datadog.NewAPIClient(configuration)
32+
api := datadogV2.NewTeamsApi(apiClient)
33+
resp, r, err := api.UpdateTeam(ctx, DdTeamDataID, body)
34+
35+
if err != nil {
36+
fmt.Fprintf(os.Stderr, "Error when calling `TeamsApi.UpdateTeam`: %v\n", err)
37+
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
38+
}
39+
40+
responseContent, _ := json.MarshalIndent(resp, "", " ")
41+
fmt.Fprintf(os.Stdout, "Response from `TeamsApi.UpdateTeam`:\n%s\n", responseContent)
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026-03-25T10:51:13.320Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
interactions:
2+
- request:
3+
body: |
4+
{"data":{"attributes":{"handle":"test-handle-789e569afaa52bde","name":"test-name-789e569afaa52bde"},"type":"team"}}
5+
form: {}
6+
headers:
7+
Accept:
8+
- application/json
9+
Content-Type:
10+
- application/json
11+
id: 0
12+
method: POST
13+
url: https://api.datadoghq.com/api/v2/team
14+
response:
15+
body: '{"data":{"id":"1d059472-0eff-4857-a6c8-5e5041448b54","type":"team","attributes":{"avatar":null,"banner":5,"created_at":"2026-03-25T10:51:13.938804+00:00","description":null,"handle":"test-handle-789e569afaa52bde","hidden_modules":null,"is_managed":false,"link_count":0,"modified_at":"2026-03-25T10:51:13.938804+00:00","name":"test-name-789e569afaa52bde","summary":null,"user_count":0,"visible_modules":null},"relationships":{"team_links":{"data":[],"links":{"related":"/api/v2/team/1d059472-0eff-4857-a6c8-5e5041448b54/links"}},"user_team_permissions":{"data":null,"links":{"related":"/api/v2/team/1d059472-0eff-4857-a6c8-5e5041448b54/permission-settings"}}}}}'
16+
code: 201
17+
duration: 0ms
18+
headers:
19+
Content-Type:
20+
- application/vnd.api+json
21+
status: 201 Created
22+
- request:
23+
body: |
24+
{"data":{"attributes":{"email":"Test-Remove_a_user_from_a_team_returns_No_Content_response-1774435873@datadoghq.com","title":"user title"},"type":"users"}}
25+
form: {}
26+
headers:
27+
Accept:
28+
- application/json
29+
Content-Type:
30+
- application/json
31+
id: 1
32+
method: POST
33+
url: https://api.datadoghq.com/api/v2/users
34+
response:
35+
body: '{"data": {"type": "users", "id": "66e25b0b-3f3b-427e-b162-e779f4535abb",
36+
"attributes": {"name": null, "handle": "test-remove_a_user_from_a_team_returns_no_content_response-1774435873@datadoghq.com",
37+
"created_at": "2026-03-25T10:51:14.481612+00:00", "modified_at": "2026-03-25T10:51:14.481612+00:00",
38+
"email": "test-remove_a_user_from_a_team_returns_no_content_response-1774435873@datadoghq.com",
39+
"icon": "https://secure.gravatar.com/avatar/be9f1c5abecde28b4c01cc8aa0680377?s=48&d=retro",
40+
"title": "user title", "verified": false, "service_account": false, "disabled":
41+
false, "allowed_login_methods": [], "status": "Pending", "last_login_time":
42+
null}, "relationships": {"roles": {"data": []}, "org": {"data": {"type": "orgs",
43+
"id": "4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}}'
44+
code: 201
45+
duration: 0ms
46+
headers:
47+
Content-Type:
48+
- application/json
49+
status: 201 Created
50+
- request:
51+
body: |
52+
{"data":{"attributes":{"role":"admin"},"relationships":{"user":{"data":{"id":"66e25b0b-3f3b-427e-b162-e779f4535abb","type":"users"}}},"type":"team_memberships"}}
53+
form: {}
54+
headers:
55+
Accept:
56+
- application/json
57+
Content-Type:
58+
- application/json
59+
id: 2
60+
method: POST
61+
url: https://api.datadoghq.com/api/v2/team/1d059472-0eff-4857-a6c8-5e5041448b54/memberships
62+
response:
63+
body: '{"data":{"id":"TeamMembership-1d059472-0eff-4857-a6c8-5e5041448b54-66092046","type":"team_memberships","attributes":{"provisioned_by":null,"provisioned_by_id":"a1d5ff5a-c6dd-11f0-9cb6-06640ca27ad4","role":"admin"},"relationships":{"user":{"data":{"id":"66e25b0b-3f3b-427e-b162-e779f4535abb","type":"users"}}}},"included":[{"id":"66e25b0b-3f3b-427e-b162-e779f4535abb","type":"users","attributes":{"disabled":false,"email":"test-remove_a_user_from_a_team_returns_no_content_response-1774435873@datadoghq.com","handle":"test-remove_a_user_from_a_team_returns_no_content_response-1774435873@datadoghq.com","icon":"https://secure.gravatar.com/avatar/be9f1c5abecde28b4c01cc8aa0680377?d=retro\u0026s=48","name":null,"service_account":false,"status":"Pending"}}]}'
64+
code: 200
65+
duration: 0ms
66+
headers:
67+
Content-Type:
68+
- application/vnd.api+json
69+
status: 200 OK
70+
- request:
71+
body: ''
72+
form: {}
73+
headers:
74+
Accept:
75+
- '*/*'
76+
id: 3
77+
method: DELETE
78+
url: https://api.datadoghq.com/api/v2/team/1d059472-0eff-4857-a6c8-5e5041448b54/memberships/66e25b0b-3f3b-427e-b162-e779f4535abb
79+
response:
80+
body: ''
81+
code: 204
82+
duration: 0ms
83+
headers: {}
84+
status: 204 No Content
85+
- request:
86+
body: ''
87+
form: {}
88+
headers:
89+
Accept:
90+
- '*/*'
91+
id: 4
92+
method: DELETE
93+
url: https://api.datadoghq.com/api/v2/team/1d059472-0eff-4857-a6c8-5e5041448b54/memberships/66e25b0b-3f3b-427e-b162-e779f4535abb
94+
response:
95+
body: '{"errors":["User 66e25b0b-3f3b-427e-b162-e779f4535abb is not a member of
96+
Team 1d059472-0eff-4857-a6c8-5e5041448b54 not found"]}'
97+
code: 404
98+
duration: 0ms
99+
headers:
100+
Content-Type:
101+
- application/json
102+
status: 404 Not Found
103+
- request:
104+
body: ''
105+
form: {}
106+
headers:
107+
Accept:
108+
- '*/*'
109+
id: 5
110+
method: DELETE
111+
url: https://api.datadoghq.com/api/v2/users/66e25b0b-3f3b-427e-b162-e779f4535abb
112+
response:
113+
body: ''
114+
code: 204
115+
duration: 0ms
116+
headers: {}
117+
status: 204 No Content
118+
- request:
119+
body: ''
120+
form: {}
121+
headers:
122+
Accept:
123+
- '*/*'
124+
id: 6
125+
method: DELETE
126+
url: https://api.datadoghq.com/api/v2/team/1d059472-0eff-4857-a6c8-5e5041448b54
127+
response:
128+
body: ''
129+
code: 204
130+
duration: 0ms
131+
headers: {}
132+
status: 204 No Content
133+
version: 2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026-03-25T11:58:33.497Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
interactions:
2+
- request:
3+
body: |
4+
{"data":{"attributes":{"handle":"test-handle-1aa8ea88c040ca48","name":"test-name-1aa8ea88c040ca48"},"type":"team"}}
5+
form: {}
6+
headers:
7+
Accept:
8+
- application/json
9+
Content-Type:
10+
- application/json
11+
id: 0
12+
method: POST
13+
url: https://api.datadoghq.com/api/v2/team
14+
response:
15+
body: '{"data":{"id":"5f6e649c-340c-46e7-96bc-bc5ececc7839","type":"team","attributes":{"avatar":null,"banner":15,"created_at":"2026-03-25T11:58:34.181069+00:00","description":null,"handle":"test-handle-1aa8ea88c040ca48","hidden_modules":null,"is_managed":false,"link_count":0,"modified_at":"2026-03-25T11:58:34.181069+00:00","name":"test-name-1aa8ea88c040ca48","summary":null,"user_count":0,"visible_modules":null},"relationships":{"team_links":{"data":[],"links":{"related":"/api/v2/team/5f6e649c-340c-46e7-96bc-bc5ececc7839/links"}},"user_team_permissions":{"data":null,"links":{"related":"/api/v2/team/5f6e649c-340c-46e7-96bc-bc5ececc7839/permission-settings"}}}}}'
16+
code: 201
17+
duration: 0ms
18+
headers:
19+
Content-Type:
20+
- application/vnd.api+json
21+
status: 201 Created
22+
- request:
23+
body: |
24+
{"data":{"attributes":{"handle":"test-handle-1aa8ea88c040ca48","name":"test-name-1aa8ea88c040ca48 updated"},"type":"team"}}
25+
form: {}
26+
headers:
27+
Accept:
28+
- application/json
29+
Content-Type:
30+
- application/json
31+
id: 1
32+
method: PATCH
33+
url: https://api.datadoghq.com/api/v2/team/5f6e649c-340c-46e7-96bc-bc5ececc7839
34+
response:
35+
body: '{"data":{"type":"team","id":"5f6e649c-340c-46e7-96bc-bc5ececc7839","attributes":{"name":"test-name-1aa8ea88c040ca48
36+
updated","handle":"test-handle-1aa8ea88c040ca48","summary":null,"description":null,"avatar":null,"banner":15,"visible_modules":null,"hidden_modules":null,"created_at":"2026-03-25T11:58:34.181069+00:00","modified_at":"2026-03-25T11:58:34.727617+00:00","user_count":0,"link_count":0,"is_managed":false},"relationships":{"team_links":{"links":{"related":"/api/v2/team/5f6e649c-340c-46e7-96bc-bc5ececc7839/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/5f6e649c-340c-46e7-96bc-bc5ececc7839/permission-settings"}}}}}
37+
38+
'
39+
code: 200
40+
duration: 0ms
41+
headers:
42+
Content-Type:
43+
- application/json
44+
status: 200 OK
45+
- request:
46+
body: ''
47+
form: {}
48+
headers:
49+
Accept:
50+
- '*/*'
51+
id: 2
52+
method: DELETE
53+
url: https://api.datadoghq.com/api/v2/team/5f6e649c-340c-46e7-96bc-bc5ececc7839
54+
response:
55+
body: ''
56+
code: 204
57+
duration: 0ms
58+
headers: {}
59+
status: 204 No Content
60+
version: 2

tests/scenarios/features/v2/teams.feature

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,14 @@ Feature: Teams
573573
When the request is sent
574574
Then the response status is 404 API error response.
575575

576-
@skip @team:DataDog/aaa-omg
576+
@team:DataDog/aaa-omg
577577
Scenario: Remove a user from a team returns "No Content" response
578578
Given new "DeleteTeamMembership" request
579579
And there is a valid "dd_team" in the system
580+
And there is a valid "user" in the system
581+
And there is a valid "team_membership" in the system
580582
And request contains "team_id" parameter from "dd_team.data.id"
581-
And request contains "user_id" parameter from "REPLACE.ME"
583+
And request contains "user_id" parameter from "user.data.id"
582584
When the request is sent
583585
Then the response status is 204 No Content
584586

@@ -607,11 +609,13 @@ Feature: Teams
607609
And the response "data.attributes.label" is equal to "New Label"
608610
And the response "data.attributes.url" is equal to "https://example.com"
609611

610-
@generated @skip @team:DataDog/aaa-omg
612+
@skip @team:DataDog/aaa-omg
611613
Scenario: Update a team returns "API error response." response
612614
Given new "UpdateTeam" request
613-
And request contains "team_id" parameter from "REPLACE.ME"
614-
And body with value {"data": {"attributes": {"avatar": "\ud83e\udd51", "banner": null, "handle": "example-team", "hidden_modules": [], "name": "Example Team", "visible_modules": []}, "relationships": {"team_links": {"data": [{"id": "f9bb8444-af7f-11ec-ac2c-da7ad0900001", "type": "team_links"}], "links": {"related": "/api/v2/team/c75a4a8e-20c7-11ee-a3a5-da7ad0900002/links"}}}, "type": "team"}}
615+
And there is a valid "dd_team" in the system
616+
And there is a valid "dd_team_2" in the system
617+
And request contains "team_id" parameter from "dd_team.data.id"
618+
And body with value {"data": {"attributes": {"handle": "{{dd_team_2.data.attributes.handle}}", "name": "{{dd_team.data.attributes.name}}"}, "type": "team"}}
615619
When the request is sent
616620
Then the response status is 409 API error response.
617621

@@ -631,6 +635,17 @@ Feature: Teams
631635
And the response "data.attributes.hidden_modules" is equal to ["m3"]
632636
And the response "data.attributes.visible_modules" is equal to ["m1", "m2"]
633637

638+
@team:DataDog/aaa-omg
639+
Scenario: Update a team with partial update returns "OK" response
640+
Given new "UpdateTeam" request
641+
And there is a valid "dd_team" in the system
642+
And request contains "team_id" parameter from "dd_team.data.id"
643+
And body with value {"data": {"attributes": {"handle": "{{dd_team.data.attributes.handle}}", "name": "{{dd_team.data.attributes.name}} updated"}, "type": "team"}}
644+
When the request is sent
645+
Then the response status is 200 OK
646+
And the response "data.attributes.name" is equal to "{{dd_team.data.attributes.name}} updated"
647+
And the response "data.attributes.handle" is equal to "{{dd_team.data.attributes.handle}}"
648+
634649
@team:DataDog/aaa-omg
635650
Scenario: Update a user's membership attributes on a team returns "API error response." response
636651
Given new "UpdateTeamMembership" request

0 commit comments

Comments
 (0)