Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions src/api/routes/membership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import { getEntraIdToken } from "api/functions/entraId.js";
import { genericConfig, roleArns } from "common/config.js";
import { getRoleCredentials } from "api/functions/sts.js";
import { SecretsManagerClient } from "@aws-sdk/client-secrets-manager";
import { DynamoDBClient, QueryCommand } from "@aws-sdk/client-dynamodb";
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import rateLimiter from "api/plugins/rateLimiter.js";
import { createCheckoutSession } from "api/functions/stripe.js";
import { getSecretValue } from "api/plugins/auth.js";
import stripe, { Stripe } from "stripe";
import { AvailableSQSFunctions, SQSPayload } from "common/types/sqsMessage.js";
import { SendMessageCommand, SQSClient } from "@aws-sdk/client-sqs";
import rawbody, { RawBodyPluginOptions } from "fastify-raw-body";
import rawbody from "fastify-raw-body";

const NONMEMBER_CACHE_SECONDS = 1800; // 30 minutes
const MEMBER_CACHE_SECONDS = 43200; // 12 hours
Expand Down Expand Up @@ -73,7 +73,7 @@ const membershipPlugin: FastifyPluginAsync = async (fastify, _options) => {
Body: undefined;
Params: { netId: string };
}>("/checkout/:netId", async (request, reply) => {
const netId = request.params.netId;
const netId = request.params.netId.toLowerCase();
if (!validateNetId(netId)) {
throw new ValidationError({
message: `${netId} is not a valid Illinois NetID!`,
Expand Down Expand Up @@ -147,7 +147,7 @@ const membershipPlugin: FastifyPluginAsync = async (fastify, _options) => {
Querystring: { list?: string };
Params: { netId: string };
}>("/:netId", async (request, reply) => {
const netId = request.params.netId;
const netId = request.params.netId.toLowerCase();
const list = request.query.list || "acmpaid";
if (!validateNetId(netId)) {
throw new ValidationError({
Expand Down
24 changes: 24 additions & 0 deletions tests/live/membership.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ describe("Membership API basic checks", async () => {

expect(wasCached(response.headers.get("x-acm-data-source"))).toBe(true);
});
test(
"Test that getting member with non-standard casing succeeds",
{ timeout: 3000 },
async () => {
const response = await fetch(
`${baseEndpoint}/api/v1/membership/DSingh14`,
{
method: "GET",
},
);

expect(response.status).toBe(200);

const responseBody = await response.json();
expect(responseBody).toStrictEqual({
netId: "dsingh14",
isPaidMember: true,
});

const wasCached = (value: string | null) => value && value !== "aad";

expect(wasCached(response.headers.get("x-acm-data-source"))).toBe(true);
},
);
test(
"Test that getting non-members succeeds",
{ timeout: 3000 },
Expand Down
Loading