@@ -27,44 +27,6 @@ function extractSessionCookie(
2727
2828// Test secret key (32+ characters required)
2929const TEST_SECRET = "this-is-a-test-secret-key-32chars!" ;
30- Deno . test ( "use memory store" , async ( ) => {
31- const store = new MemorySessionStore ( ) ;
32- const sessionSaveRes = await ( async ( ) => {
33- const handler = new App < State > ( )
34- . use ( session ( store , TEST_SECRET ) )
35- . get ( "/" , ( ctx ) => {
36- ctx . state . session . set ( "userId" , "user123" ) ;
37- return new Response ( "Hello, World!" ) ;
38- } ) . handler ( ) ;
39- const req = new Request ( "http://localhost" ) ;
40- const res = await handler ( req ) ;
41-
42- assertEquals ( await res . text ( ) , "Hello, World!" ) ;
43-
44- return res ;
45- } ) ( ) ;
46-
47- const sessionCookie = extractSessionCookie ( sessionSaveRes ) ;
48-
49- {
50- const handler = new App < State > ( )
51- . use ( session ( store , TEST_SECRET ) )
52- . get ( "/get" , ( ctx ) => {
53- const userId = ctx . state . session . get ( "userId" ) as string | undefined ;
54- return new Response ( userId ?? "No User" ) ;
55- } )
56- . handler ( ) ;
57-
58- const req = new Request ( "http://localhost/get" , {
59- headers : {
60- "Cookie" : `fresh_session=${ sessionCookie } ` ,
61- } ,
62- } ) ;
63- const res = await handler ( req ) ;
64-
65- assertEquals ( await res . text ( ) , "user123" ) ;
66- }
67- } ) ;
6830
6931Deno . test ( "use cookie store" , async ( ) => {
7032 const store = new CookieSessionStore ( ) ;
0 commit comments