@@ -16,14 +16,11 @@ function suffix() {
1616 return Math . random ( ) . toString ( 36 ) . slice ( 2 , 10 ) ;
1717}
1818
19- // IMPERSONATION_ENABLED=false must make impersonation fully inert: starting
20- // one 404s, and an existing cookie resolves to nothing however it was
21- // obtained. Stopping stays possible with the flag off — that's how lingering
22- // sessions get terminated — and must still clear the cookie.
19+ // IMPERSONATION_ENABLED=false: starting 404s, cookies resolve to nothing,
20+ // stopping still works so lingering sessions can be terminated.
2321describe ( "impersonation disabled" , ( ) => {
2422 postgresTest ( "the flag defaults to enabled" , async ( ) => {
25- // Flipping this default would kill impersonation on every existing
26- // deployment that never heard of the flag.
23+ // Flipping the default would kill impersonation on every existing deployment.
2724 expect ( env . IMPERSONATION_ENABLED ) . toBe ( true ) ;
2825 } ) ;
2926
@@ -50,8 +47,8 @@ describe("impersonation disabled", () => {
5047 new Request ( "http://localhost:3030/" , { headers : { Cookie : cookie } } ) ;
5148
5249 expect ( await getImpersonationId ( requestWithCookie ( ) ) ) . toBe ( target . id ) ;
53- // resolvedUserId must match the impersonated id for the state to count as
54- // impersonating — that's what getUserId resolves to while the cookie works .
50+ // resolvedUserId must be the impersonated id or the state is false even
51+ // with the flag on, making the disabled assertion below vacuous .
5552 const enabledState = await getImpersonationState ( requestWithCookie ( ) , target . id ) ;
5653 expect ( enabledState . isImpersonating ) . toBe ( true ) ;
5754
@@ -76,8 +73,7 @@ describe("impersonation disabled", () => {
7673 const disabledState = await getImpersonationState ( requestWithCookie ( ) , target . id ) ;
7774 expect ( disabledState . isImpersonating ) . toBe ( false ) ;
7875
79- // The ungated reader still sees the cookie — it's what stop/scrub paths
80- // use to terminate a session the gated reader no longer resolves.
76+ // The ungated reader still sees the cookie (stop/scrub paths need it).
8177 expect ( await getRawImpersonationId ( requestWithCookie ( ) ) ) . toBe ( target . id ) ;
8278
8379 // Stopping works with the flag off and clears the cookie.
0 commit comments