Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions tests/live/iam.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { expect, test } from "vitest";
import { createJwt } from "./utils.js";
import {
EntraActionResponse,
GroupMemberGetResponse,
} from "../../src/common/types/iam.js";
import { allAppRoles, AppRoles } from "../../src/common/roles.js";

const baseEndpoint = `https://core.aws.qa.acmuiuc.org`;
test("getting members of a group", async () => {
const token = await createJwt();
const response = await fetch(
`${baseEndpoint}/api/v1/iam/groups/dbe18eb2-9675-46c4-b1ef-749a6db4fedd`,
{
method: "GET",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
},
);
expect(response.status).toBe(200);
const responseJson = (await response.json()) as GroupMemberGetResponse;
expect(responseJson.length).greaterThan(0);
for (const item of responseJson) {
expect(item).toHaveProperty("name");
expect(item).toHaveProperty("email");
expect(item["name"].length).greaterThan(0);
expect(item["email"].length).greaterThan(0);
expect(item["email"]).toContain("@");
}
});

test("inviting users to tenant", { timeout: 60000 }, async () => {
const token = await createJwt();
const response = await fetch(`${baseEndpoint}/api/v1/iam/inviteUsers`, {
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
emails: ["acm@illinois.edu"],
}),
});
expect(response.status).toBe(202);
const responseJson = (await response.json()) as EntraActionResponse;
expect(responseJson).toEqual({
success: [{ email: "acm@illinois.edu" }],
failure: [],
});
});

test("getting group roles", async () => {
const token = await createJwt();
const response = await fetch(`${baseEndpoint}/api/v1/iam/groups/0/roles`, {
method: "GET",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
});
expect(response.status).toBe(200);
const responseJson = (await response.json()) as AppRoles[];
expect(responseJson).toEqual(allAppRoles);
});
Loading