Skip to content

Commit

Permalink
fix: some auth guards were wrong, removed a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomhickey committed Oct 18, 2024
1 parent 642dad7 commit 6e1731e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
10 changes: 5 additions & 5 deletions src/backend/routers/iep.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { hasCaseManager, router } from "../trpc";
import { hasCaseManager, hasPara, router } from "../trpc";
import { jsonArrayFrom } from "kysely/helpers/postgres";
import { deleteFile } from "../lib/files";
import { substituteTransactionOnContext } from "../lib/utils/context";
Expand Down Expand Up @@ -217,7 +217,7 @@ export const iep = router({
return result;
}),

addTrialData: hasCaseManager
addTrialData: hasPara
.input(
z.object({
task_id: z.string(),
Expand Down Expand Up @@ -246,7 +246,7 @@ export const iep = router({
return result;
}),

updateTrialData: hasCaseManager
updateTrialData: hasPara
.input(
z.object({
trial_data_id: z.string(),
Expand Down Expand Up @@ -361,7 +361,7 @@ export const iep = router({
return result;
}),

getSubgoalAndTrialData: hasCaseManager
getSubgoalAndTrialData: hasPara
.input(
z.object({
task_id: z.string(),
Expand Down Expand Up @@ -424,7 +424,7 @@ export const iep = router({
return result;
}),

markAsSeen: hasCaseManager
markAsSeen: hasPara
.input(
z.object({
task_id: z.string(),
Expand Down
14 changes: 0 additions & 14 deletions src/backend/routers/student.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,6 @@ test("getStudentById - paras do not have access", async (t) => {
);
});

test("getStudentByTaskId - paras do not have access", async (t) => {
const { trpc } = await getTestServer(t, { authenticateAs: UserType.Para });

const error = await t.throwsAsync(async () => {
await trpc.student.getStudentByTaskId.query({ task_id: "task_id" });
});

t.is(
error?.message,
"UNAUTHORIZED",
"Expected an 'unauthorized' error message"
);
});

// TODO: This test looks to be testing the `UNIQUE` constraing on the schema.
// Improve this test
test("doNotAddDuplicateEmails", async (t) => {
Expand Down
4 changes: 2 additions & 2 deletions src/backend/routers/student.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { hasCaseManager, router } from "../trpc";
import { hasCaseManager, hasPara, router } from "../trpc";

// TODO: define .output() schemas for all procedures
export const student = router({
Expand All @@ -17,7 +17,7 @@ export const student = router({
return result;
}),

getStudentByTaskId: hasCaseManager
getStudentByTaskId: hasPara
.input(z.object({ task_id: z.string().uuid() }))
.query(async (req) => {
const { task_id } = req.input;
Expand Down

0 comments on commit 6e1731e

Please sign in to comment.