Skip to content

Commit

Permalink
improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Dec 15, 2024
1 parent d73feda commit 3c42267
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/openauth/test/authorizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { authorizer } from "../src/authorizer.js"
import { createClient } from "../src/client.js"
import { createSubjects } from "../src/index.js"
import { MemoryStorage } from "../src/storage/memory.js"
import { Adapter } from "../src/adapter/adapter.js"

const subjects = createSubjects({
user: object({
Expand All @@ -23,11 +24,6 @@ const auth = authorizer({
storage,
subjects,
allow: async () => true,
success: async (ctx) => {
return ctx.subject("user", {
userID: "123",
})
},
ttl: {
access: 60,
refresh: 6000,
Expand All @@ -47,10 +43,18 @@ const auth = authorizer({
throw new Error("Wrong credentials")
}
return {
clientID,
email: "foo@bar.com",
}
},
},
} satisfies Adapter<{ email: string }>,
},
success: async (ctx, value) => {
if (value.provider === "dummy") {
return ctx.subject("user", {
userID: "123",
})
}
throw new Error("Invalid provider: " + value.provider)
},
})

Expand Down

0 comments on commit 3c42267

Please sign in to comment.