@@ -25,6 +25,7 @@ import { validate } from "uuid";
2525import type * as Jose from "jose" ;
2626import type * as OpenIdClient from "openid-client" ;
2727import { Session } from "./Session" ;
28+ import { randomUUID } from "crypto" ;
2829
2930// Camelcase identifiers are required in the OIDC specification.
3031/* eslint-disable camelcase*/
@@ -166,9 +167,10 @@ describe("Session static functions", () => {
166167
167168 describe ( "Session.fromTokens" , ( ) => {
168169 it ( "creates a session with the provided tokens" , async ( ) => {
170+ const mockedAccessToken = randomUUID ( ) ;
169171 const mockedIdToken = await mockIdToken ( { } ) ;
170172 const tokenSet : SessionTokenSet = {
171- accessToken : "access.token.jwt" ,
173+ accessToken : mockedAccessToken ,
172174 idToken : mockedIdToken ,
173175 clientId : mockClientId ,
174176 issuer : mockOpConfig ( ) . issuer ,
@@ -195,7 +197,9 @@ describe("Session static functions", () => {
195197 } ) as typeof fetch ;
196198 await session . fetch ( "https://some.resource" ) ;
197199 // @ts -expect-error We know headers is initialized.
198- expect ( headers . get ( "Authorization" ) ) . toBe ( `Bearer ${ mockedIdToken } ` ) ;
200+ expect ( headers . get ( "Authorization" ) ) . toBe (
201+ `Bearer ${ mockedAccessToken } ` ,
202+ ) ;
199203 globalThis . fetch = globalFetch ;
200204 } ) ;
201205
@@ -207,9 +211,10 @@ describe("Session static functions", () => {
207211 publicKey : await exportJWK ( dpopKeyPair . publicKey ) ,
208212 } ;
209213
214+ const mockedAccessToken = randomUUID ( ) ;
210215 const mockedIdToken = await mockIdToken ( { } ) ;
211216 const tokenSet : SessionTokenSet = {
212- accessToken : "access.token.jwt" ,
217+ accessToken : mockedAccessToken ,
213218 idToken : mockedIdToken ,
214219 clientId : mockClientId ,
215220 issuer : mockOpConfig ( ) . issuer ,
@@ -230,7 +235,7 @@ describe("Session static functions", () => {
230235 } ) as typeof fetch ;
231236 await session . fetch ( "https://some.resource" ) ;
232237 // @ts -expect-error We know headers is initialized.
233- expect ( headers . get ( "Authorization" ) ) . toBe ( `DPoP ${ mockedIdToken } ` ) ;
238+ expect ( headers . get ( "Authorization" ) ) . toBe ( `DPoP ${ mockedAccessToken } ` ) ;
234239 // @ts -expect-error We know headers is initialized.
235240 expect ( headers . get ( "dpop" ) ) . not . toBeNull ( ) ;
236241 globalThis . fetch = globalFetch ;
0 commit comments