Skip to content

Commit 29bada0

Browse files
committed
fix/add live tests
1 parent eb2b632 commit 29bada0

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

tests/live/iam.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { getBaseEndpoint } from "./utils.js";
1010
import { environmentConfig, genericConfig } from "../../src/common/config.js";
1111

1212
const baseEndpoint = getBaseEndpoint();
13-
test("getting groups", async () => {
13+
test("getting groups", { timeout: 10000 }, async () => {
1414
const token = await createJwt();
1515
const response = await fetch(`${baseEndpoint}/api/v1/iam/groups`, {
1616
method: "GET",

tests/live/membership.test.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect, test, describe } from "vitest";
22
import { createJwt, getBaseEndpoint } from "./utils.js";
3+
import { randomUUID } from "node:crypto";
34

45
const baseEndpoint = getBaseEndpoint();
56
const token = await createJwt();
@@ -232,3 +233,77 @@ describe("Membership API basic checks", async () => {
232233
},
233234
);
234235
});
236+
237+
test("External Membership List lifecycle test", async () => {
238+
const unixTimestampSeconds = Math.floor(Date.now() / 1000);
239+
const listId = `livetest-${unixTimestampSeconds}`;
240+
let response = await fetch(
241+
`${baseEndpoint}/api/v1/membership/externalList/${listId}`,
242+
{
243+
method: "PATCH",
244+
headers: {
245+
authorization: `Bearer ${token}`,
246+
"content-type": "application/json",
247+
},
248+
body: JSON.stringify({
249+
add: ["acmtest2"],
250+
remove: [],
251+
}),
252+
},
253+
);
254+
expect(response.status).toBe(201);
255+
response = await fetch(
256+
`${baseEndpoint}/api/v1/membership/externalList/${listId}`,
257+
{
258+
method: "GET",
259+
headers: {
260+
authorization: `Bearer ${token}`,
261+
"content-type": "application/json",
262+
},
263+
},
264+
);
265+
let responseJson = await response.json();
266+
expect(responseJson).toStrictEqual(["acmtest2"]);
267+
response = await fetch(
268+
`${baseEndpoint}/api/v1/membership/externalList/${listId}`,
269+
{
270+
method: "PATCH",
271+
headers: {
272+
authorization: `Bearer ${token}`,
273+
"content-type": "application/json",
274+
},
275+
body: JSON.stringify({
276+
add: ["acmtest3"],
277+
remove: ["acmtest2"],
278+
}),
279+
},
280+
);
281+
expect(response.status).toEqual(201);
282+
response = await fetch(
283+
`${baseEndpoint}/api/v1/membership/externalList/${listId}`,
284+
{
285+
method: "GET",
286+
headers: {
287+
authorization: `Bearer ${token}`,
288+
"content-type": "application/json",
289+
},
290+
},
291+
);
292+
responseJson = await response.json();
293+
expect(responseJson).toStrictEqual(["acmtest3"]);
294+
response = await fetch(
295+
`${baseEndpoint}/api/v1/membership/externalList/${listId}`,
296+
{
297+
method: "PATCH",
298+
headers: {
299+
authorization: `Bearer ${token}`,
300+
"content-type": "application/json",
301+
},
302+
body: JSON.stringify({
303+
remove: ["acmtest3"],
304+
add: [],
305+
}),
306+
},
307+
);
308+
expect(response.status).toEqual(201);
309+
});

0 commit comments

Comments
 (0)