Skip to content

Commit

Permalink
fix: put comment in test
Browse files Browse the repository at this point in the history
  • Loading branch information
thomhickey committed Sep 3, 2024
1 parent ebe1f54 commit c78b645
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/backend/routers/routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import { createContext } from "@/backend/context";
import type { NextApiRequest, NextApiResponse } from "next";
import { TRPCError } from "@trpc/server";

/**
* This test suite verifies that all API endpoints in the application are properly protected by authentication.
*
* It works by:
* 1. Creating a mock request and response object.
* 2. Generating a context with no authentication.
* 3. Creating a trpc caller with this unauthenticated context.
* 4. Iterating through all procedures in the trpcRouter.
* 5. Attempting to call each procedure without authentication.
* 6. Expecting an UNAUTHORIZED error for each call (except for explicitly excluded endpoints).
*
* This ensures that no sensitive endpoints are accidentally left unprotected,
* maintaining the security of the API.
*/

test("All API endpoints are auth guarded", async (t) => {
/**
* This test verifies that all API endpoints in the application are properly protected by authentication.
*
* It works by:
* 1. Creating a mock request and response object.
* 2. Generating a context with no authentication.
* 3. Creating a trpc caller with this unauthenticated context.
* 4. Iterating through all procedures in the trpcRouter.
* 5. Attempting to call each procedure without authentication.
* 6. Expecting an UNAUTHORIZED error for each call (except for explicitly excluded endpoints).
*
* This ensures that no sensitive endpoints are accidentally left unprotected,
* maintaining the security of the API.
*/

// create a mock request object for our calls. purpose of this is to have no auth
const mockReq = {
headers: {},
Expand Down

0 comments on commit c78b645

Please sign in to comment.