Skip to content

Commit 95b8b4c

Browse files
committed
fix IAM, add tests
1 parent b7a2f84 commit 95b8b4c

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

cloudformation/iam.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Resources:
6262
Effect: Allow
6363
Resource:
6464
- !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-events-api-records/*
65+
- !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-events-api-records
6566
PolicyName: lambda-dynamo
6667
Outputs:
6768
MainFunctionRoleArn:

src/routes/events.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,11 @@ const eventsPlugin: FastifyPluginAsync = async (fastify, _options) => {
9292
await dynamoClient.send(
9393
new PutItemCommand({
9494
TableName: genericConfig.DynamoTableName,
95-
Item: marshall(
96-
{
97-
...request.body,
98-
id: entryUUID,
99-
createdBy: request.username,
100-
},
101-
{ removeUndefinedValues: true },
102-
),
95+
Item: marshall({
96+
...request.body,
97+
id: entryUUID,
98+
createdBy: request.username,
99+
}),
103100
}),
104101
);
105102
reply.send({

tests/live/ical.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { expect, test } from "vitest";
2+
import { InternalServerError } from "../../src/errors/index.js";
3+
import { EventsGetResponse } from "../../src/routes/events.js";
4+
import { describe } from "node:test";
5+
import { OrganizationList } from "../../src/orgs.js";
6+
7+
const appKey = process.env.APPLICATION_KEY;
8+
if (!appKey) {
9+
throw new InternalServerError({ message: "No application key found" });
10+
}
11+
12+
const baseEndpoint = `https://${appKey}.aws.qa.acmuiuc.org`;
13+
test("getting all events", async () => {
14+
const response = await fetch(`${baseEndpoint}/api/v1/ical`);
15+
expect(response.status).toBe(200);
16+
});
17+
18+
describe("Getting specific calendars", async () => {
19+
for (const org of OrganizationList) {
20+
test(`Get ${org} calendar`, async () => {
21+
const response = await fetch(`${baseEndpoint}/api/v1/ical/${org}`);
22+
expect(response.status).toBe(200);
23+
expect(response.headers.get("Content-Disposition")).toEqual(
24+
'attachment; filename="calendar.ics"',
25+
);
26+
});
27+
}
28+
});

0 commit comments

Comments
 (0)