bug fixes: subnets listing, icons resizing and some shenanigans
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
createEc2SecurityGroup,
|
||||
revokeEc2SecurityGroupEgress,
|
||||
revokeEc2SecurityGroupIngress,
|
||||
updateEc2InstanceSecurityGroups,
|
||||
} from "./ec2.api";
|
||||
|
||||
describe("createEc2SecurityGroup", () => {
|
||||
@@ -84,3 +85,29 @@ describe("EC2 security-group rule requests", () => {
|
||||
expect(new Headers(init?.headers).get("content-type")).toBe("application/json");
|
||||
});
|
||||
});
|
||||
|
||||
describe("updateEc2InstanceSecurityGroups", () => {
|
||||
const fetchMock = vi.fn<typeof fetch>();
|
||||
|
||||
beforeEach(() => {
|
||||
fetchMock.mockResolvedValue(new Response(JSON.stringify({ ok: true }), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
}));
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
fetchMock.mockReset();
|
||||
});
|
||||
|
||||
it("sends the selected group IDs as a JSON object", async () => {
|
||||
await updateEc2InstanceSecurityGroups("i-test", ["sg-default", "sg-web"]);
|
||||
|
||||
const [url, init] = fetchMock.mock.calls[0];
|
||||
expect(String(url)).toContain("/api/ec2/instances/i-test/security-groups");
|
||||
expect(init?.method).toBe("PUT");
|
||||
expect(JSON.parse(String(init?.body))).toEqual({groupIds: ["sg-default", "sg-web"]});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -338,7 +338,7 @@ export async function updateEc2InstanceTags(
|
||||
export async function updateEc2InstanceSecurityGroups(instanceId: string, groupIds: string[]): Promise<void> {
|
||||
await apiClient.call(
|
||||
apiEndpointKeys.aws.ec2.instances.securityGroups,
|
||||
{ body: JSON.stringify({ groupIds }), headers: { "content-type": "application/json" } },
|
||||
{ body: { groupIds } },
|
||||
{ instanceId },
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user