Skip to content

Commit 6af388f

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

7 files changed

+333
-6
lines changed

examples/v2/teams/DeleteTeamMembership.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ public static void main(String[] args) {
1212
// there is a valid "dd_team" in the system
1313
String DD_TEAM_DATA_ID = System.getenv("DD_TEAM_DATA_ID");
1414

15+
// there is a valid "user" in the system
16+
String USER_DATA_ID = System.getenv("USER_DATA_ID");
17+
1518
try {
16-
apiInstance.deleteTeamMembership(DD_TEAM_DATA_ID, "user_id");
19+
apiInstance.deleteTeamMembership(DD_TEAM_DATA_ID, USER_DATA_ID);
1720
} catch (ApiException e) {
1821
System.err.println("Exception when calling TeamsApi#deleteTeamMembership");
1922
System.err.println("Status code: " + e.getCode());
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Update a team with partial update returns "OK" response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v2.api.TeamsApi;
6+
import com.datadog.api.client.v2.model.TeamResponse;
7+
import com.datadog.api.client.v2.model.TeamType;
8+
import com.datadog.api.client.v2.model.TeamUpdate;
9+
import com.datadog.api.client.v2.model.TeamUpdateAttributes;
10+
import com.datadog.api.client.v2.model.TeamUpdateRequest;
11+
12+
public class Example {
13+
public static void main(String[] args) {
14+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
15+
TeamsApi apiInstance = new TeamsApi(defaultClient);
16+
17+
// there is a valid "dd_team" in the system
18+
String DD_TEAM_DATA_ATTRIBUTES_HANDLE = System.getenv("DD_TEAM_DATA_ATTRIBUTES_HANDLE");
19+
String DD_TEAM_DATA_ATTRIBUTES_NAME = System.getenv("DD_TEAM_DATA_ATTRIBUTES_NAME");
20+
String DD_TEAM_DATA_ID = System.getenv("DD_TEAM_DATA_ID");
21+
22+
TeamUpdateRequest body =
23+
new TeamUpdateRequest()
24+
.data(
25+
new TeamUpdate()
26+
.attributes(
27+
new TeamUpdateAttributes()
28+
.handle(DD_TEAM_DATA_ATTRIBUTES_HANDLE)
29+
.name("Example Team updated"))
30+
.type(TeamType.TEAM));
31+
32+
try {
33+
TeamResponse result = apiInstance.updateTeam(DD_TEAM_DATA_ID, body);
34+
System.out.println(result);
35+
} catch (ApiException e) {
36+
System.err.println("Exception when calling TeamsApi#updateTeam");
37+
System.err.println("Status code: " + e.getCode());
38+
System.err.println("Reason: " + e.getResponseBody());
39+
System.err.println("Response headers: " + e.getResponseHeaders());
40+
e.printStackTrace();
41+
}
42+
}
43+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026-03-25T10:51:13.320Z
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
[
2+
{
3+
"httpRequest": {
4+
"body": {
5+
"type": "JSON",
6+
"json": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-789e569afaa52bde\",\"name\":\"test-name-789e569afaa52bde\"},\"type\":\"team\"}}"
7+
},
8+
"headers": {},
9+
"method": "POST",
10+
"path": "/api/v2/team",
11+
"keepAlive": false,
12+
"secure": true
13+
},
14+
"httpResponse": {
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+
"headers": {
17+
"Content-Type": [
18+
"application/vnd.api+json"
19+
]
20+
},
21+
"statusCode": 201,
22+
"reasonPhrase": "Created"
23+
},
24+
"times": {
25+
"remainingTimes": 1
26+
},
27+
"timeToLive": {
28+
"unlimited": true
29+
},
30+
"id": "06adab81-5152-105a-98eb-24da866c8255"
31+
},
32+
{
33+
"httpRequest": {
34+
"body": {
35+
"type": "JSON",
36+
"json": "{\"data\":{\"attributes\":{\"email\":\"Test-Remove_a_user_from_a_team_returns_No_Content_response-1774435873@datadoghq.com\",\"title\":\"user title\"},\"type\":\"users\"}}"
37+
},
38+
"headers": {},
39+
"method": "POST",
40+
"path": "/api/v2/users",
41+
"keepAlive": false,
42+
"secure": true
43+
},
44+
"httpResponse": {
45+
"body": "{\"data\": {\"type\": \"users\", \"id\": \"66e25b0b-3f3b-427e-b162-e779f4535abb\", \"attributes\": {\"name\": null, \"handle\": \"test-remove_a_user_from_a_team_returns_no_content_response-1774435873@datadoghq.com\", \"created_at\": \"2026-03-25T10:51:14.481612+00:00\", \"modified_at\": \"2026-03-25T10:51:14.481612+00:00\", \"email\": \"test-remove_a_user_from_a_team_returns_no_content_response-1774435873@datadoghq.com\", \"icon\": \"https://secure.gravatar.com/avatar/be9f1c5abecde28b4c01cc8aa0680377?s=48&d=retro\", \"title\": \"user title\", \"verified\": false, \"service_account\": false, \"disabled\": false, \"allowed_login_methods\": [], \"status\": \"Pending\", \"last_login_time\": null}, \"relationships\": {\"roles\": {\"data\": []}, \"org\": {\"data\": {\"type\": \"orgs\", \"id\": \"4dee724d-00cc-11ea-a77b-570c9d03c6c5\"}}}}}",
46+
"headers": {
47+
"Content-Type": [
48+
"application/json"
49+
]
50+
},
51+
"statusCode": 201,
52+
"reasonPhrase": "Created"
53+
},
54+
"times": {
55+
"remainingTimes": 1
56+
},
57+
"timeToLive": {
58+
"unlimited": true
59+
},
60+
"id": "3dc77df1-1901-1be1-eb29-329a067fc083"
61+
},
62+
{
63+
"httpRequest": {
64+
"body": {
65+
"type": "JSON",
66+
"json": "{\"data\":{\"attributes\":{\"role\":\"admin\"},\"relationships\":{\"user\":{\"data\":{\"id\":\"66e25b0b-3f3b-427e-b162-e779f4535abb\",\"type\":\"users\"}}},\"type\":\"team_memberships\"}}"
67+
},
68+
"headers": {},
69+
"method": "POST",
70+
"path": "/api/v2/team/1d059472-0eff-4857-a6c8-5e5041448b54/memberships",
71+
"keepAlive": false,
72+
"secure": true
73+
},
74+
"httpResponse": {
75+
"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\"}}]}",
76+
"headers": {
77+
"Content-Type": [
78+
"application/vnd.api+json"
79+
]
80+
},
81+
"statusCode": 200,
82+
"reasonPhrase": "OK"
83+
},
84+
"times": {
85+
"remainingTimes": 1
86+
},
87+
"timeToLive": {
88+
"unlimited": true
89+
},
90+
"id": "ad5388a0-0a48-5363-8709-c59f5cbfee62"
91+
},
92+
{
93+
"httpRequest": {
94+
"headers": {},
95+
"method": "DELETE",
96+
"path": "/api/v2/team/1d059472-0eff-4857-a6c8-5e5041448b54/memberships/66e25b0b-3f3b-427e-b162-e779f4535abb",
97+
"keepAlive": false,
98+
"secure": true
99+
},
100+
"httpResponse": {
101+
"headers": {},
102+
"statusCode": 204,
103+
"reasonPhrase": "No Content"
104+
},
105+
"times": {
106+
"remainingTimes": 1
107+
},
108+
"timeToLive": {
109+
"unlimited": true
110+
},
111+
"id": "3aeec0bd-eac4-015d-33e5-3eade6d0f1cf"
112+
},
113+
{
114+
"httpRequest": {
115+
"headers": {},
116+
"method": "DELETE",
117+
"path": "/api/v2/team/1d059472-0eff-4857-a6c8-5e5041448b54/memberships/66e25b0b-3f3b-427e-b162-e779f4535abb",
118+
"keepAlive": false,
119+
"secure": true
120+
},
121+
"httpResponse": {
122+
"body": "{\"errors\":[\"User 66e25b0b-3f3b-427e-b162-e779f4535abb is not a member of Team 1d059472-0eff-4857-a6c8-5e5041448b54 not found\"]}",
123+
"headers": {
124+
"Content-Type": [
125+
"application/json"
126+
]
127+
},
128+
"statusCode": 404,
129+
"reasonPhrase": "Not Found"
130+
},
131+
"times": {
132+
"remainingTimes": 1
133+
},
134+
"timeToLive": {
135+
"unlimited": true
136+
},
137+
"id": "3aeec0bd-eac4-015d-33e5-3eade6d0f1d0"
138+
},
139+
{
140+
"httpRequest": {
141+
"headers": {},
142+
"method": "DELETE",
143+
"path": "/api/v2/users/66e25b0b-3f3b-427e-b162-e779f4535abb",
144+
"keepAlive": false,
145+
"secure": true
146+
},
147+
"httpResponse": {
148+
"headers": {},
149+
"statusCode": 204,
150+
"reasonPhrase": "No Content"
151+
},
152+
"times": {
153+
"remainingTimes": 1
154+
},
155+
"timeToLive": {
156+
"unlimited": true
157+
},
158+
"id": "d4b0b03d-2643-9397-d8c0-9dfe0a6b9934"
159+
},
160+
{
161+
"httpRequest": {
162+
"headers": {},
163+
"method": "DELETE",
164+
"path": "/api/v2/team/1d059472-0eff-4857-a6c8-5e5041448b54",
165+
"keepAlive": false,
166+
"secure": true
167+
},
168+
"httpResponse": {
169+
"headers": {},
170+
"statusCode": 204,
171+
"reasonPhrase": "No Content"
172+
},
173+
"times": {
174+
"remainingTimes": 1
175+
},
176+
"timeToLive": {
177+
"unlimited": true
178+
},
179+
"id": "6dd9b9f9-5091-41eb-1746-8737f2857a45"
180+
}
181+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026-03-25T11:58:33.497Z
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
[
2+
{
3+
"httpRequest": {
4+
"body": {
5+
"type": "JSON",
6+
"json": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-1aa8ea88c040ca48\",\"name\":\"test-name-1aa8ea88c040ca48\"},\"type\":\"team\"}}"
7+
},
8+
"headers": {},
9+
"method": "POST",
10+
"path": "/api/v2/team",
11+
"keepAlive": false,
12+
"secure": true
13+
},
14+
"httpResponse": {
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+
"headers": {
17+
"Content-Type": [
18+
"application/vnd.api+json"
19+
]
20+
},
21+
"statusCode": 201,
22+
"reasonPhrase": "Created"
23+
},
24+
"times": {
25+
"remainingTimes": 1
26+
},
27+
"timeToLive": {
28+
"unlimited": true
29+
},
30+
"id": "ccd9e7c9-39b8-d4e0-131c-9326f37c9d97"
31+
},
32+
{
33+
"httpRequest": {
34+
"body": {
35+
"type": "JSON",
36+
"json": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-1aa8ea88c040ca48\",\"name\":\"test-name-1aa8ea88c040ca48 updated\"},\"type\":\"team\"}}"
37+
},
38+
"headers": {},
39+
"method": "PATCH",
40+
"path": "/api/v2/team/5f6e649c-340c-46e7-96bc-bc5ececc7839",
41+
"keepAlive": false,
42+
"secure": true
43+
},
44+
"httpResponse": {
45+
"body": "{\"data\":{\"type\":\"team\",\"id\":\"5f6e649c-340c-46e7-96bc-bc5ececc7839\",\"attributes\":{\"name\":\"test-name-1aa8ea88c040ca48 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\"}}}}}\n",
46+
"headers": {
47+
"Content-Type": [
48+
"application/json"
49+
]
50+
},
51+
"statusCode": 200,
52+
"reasonPhrase": "OK"
53+
},
54+
"times": {
55+
"remainingTimes": 1
56+
},
57+
"timeToLive": {
58+
"unlimited": true
59+
},
60+
"id": "e090e31a-f93e-3c02-5f5d-cf1169aa5d80"
61+
},
62+
{
63+
"httpRequest": {
64+
"headers": {},
65+
"method": "DELETE",
66+
"path": "/api/v2/team/5f6e649c-340c-46e7-96bc-bc5ececc7839",
67+
"keepAlive": false,
68+
"secure": true
69+
},
70+
"httpResponse": {
71+
"headers": {},
72+
"statusCode": 204,
73+
"reasonPhrase": "No Content"
74+
},
75+
"times": {
76+
"remainingTimes": 1
77+
},
78+
"timeToLive": {
79+
"unlimited": true
80+
},
81+
"id": "20ab5a15-8050-32eb-841b-b60db95008d0"
82+
}
83+
]

src/test/resources/com/datadog/api/client/v2/api/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)