| 
 | 1 | +import { expect, test } from "vitest";  | 
 | 2 | +import { createJwt } from "./utils.js";  | 
 | 3 | +import {  | 
 | 4 | +  EntraActionResponse,  | 
 | 5 | +  GroupMemberGetResponse,  | 
 | 6 | +} from "../../src/common/types/iam.js";  | 
 | 7 | +import { allAppRoles, AppRoles } from "../../src/common/roles.js";  | 
 | 8 | + | 
 | 9 | +const baseEndpoint = `https://core.aws.qa.acmuiuc.org`;  | 
 | 10 | +test("getting members of a group", async () => {  | 
 | 11 | +  const token = await createJwt();  | 
 | 12 | +  const response = await fetch(  | 
 | 13 | +    `${baseEndpoint}/api/v1/iam/groups/dbe18eb2-9675-46c4-b1ef-749a6db4fedd`,  | 
 | 14 | +    {  | 
 | 15 | +      method: "GET",  | 
 | 16 | +      headers: {  | 
 | 17 | +        Authorization: `Bearer ${token}`,  | 
 | 18 | +        "Content-Type": "application/json",  | 
 | 19 | +      },  | 
 | 20 | +    },  | 
 | 21 | +  );  | 
 | 22 | +  expect(response.status).toBe(200);  | 
 | 23 | +  const responseJson = (await response.json()) as GroupMemberGetResponse;  | 
 | 24 | +  expect(responseJson.length).greaterThan(0);  | 
 | 25 | +  for (const item of responseJson) {  | 
 | 26 | +    expect(item).toHaveProperty("name");  | 
 | 27 | +    expect(item).toHaveProperty("email");  | 
 | 28 | +    expect(item["name"].length).greaterThan(0);  | 
 | 29 | +    expect(item["email"].length).greaterThan(0);  | 
 | 30 | +    expect(item["email"]).toContain("@");  | 
 | 31 | +  }  | 
 | 32 | +});  | 
 | 33 | + | 
 | 34 | +test("inviting users to tenant", { timeout: 60000 }, async () => {  | 
 | 35 | +  const token = await createJwt();  | 
 | 36 | +  const response = await fetch(`${baseEndpoint}/api/v1/iam/inviteUsers`, {  | 
 | 37 | +    method: "POST",  | 
 | 38 | +    headers: {  | 
 | 39 | +      Authorization: `Bearer ${token}`,  | 
 | 40 | +      "Content-Type": "application/json",  | 
 | 41 | +    },  | 
 | 42 | +    body: JSON.stringify({  | 
 | 43 | + | 
 | 44 | +    }),  | 
 | 45 | +  });  | 
 | 46 | +  expect(response.status).toBe(202);  | 
 | 47 | +  const responseJson = (await response.json()) as EntraActionResponse;  | 
 | 48 | +  expect(responseJson).toEqual({  | 
 | 49 | +    success:  [{ email:  "[email protected]" }],  | 
 | 50 | +    failure: [],  | 
 | 51 | +  });  | 
 | 52 | +});  | 
 | 53 | + | 
 | 54 | +test("getting group roles", async () => {  | 
 | 55 | +  const token = await createJwt();  | 
 | 56 | +  const response = await fetch(`${baseEndpoint}/api/v1/iam/groups/0/roles`, {  | 
 | 57 | +    method: "GET",  | 
 | 58 | +    headers: {  | 
 | 59 | +      Authorization: `Bearer ${token}`,  | 
 | 60 | +      "Content-Type": "application/json",  | 
 | 61 | +    },  | 
 | 62 | +  });  | 
 | 63 | +  expect(response.status).toBe(200);  | 
 | 64 | +  const responseJson = (await response.json()) as AppRoles[];  | 
 | 65 | +  expect(responseJson).toEqual(allAppRoles);  | 
 | 66 | +});  | 
0 commit comments