Skip to content

Commit 1c7deff

Browse files
committed
adds test case
1 parent 376b4e4 commit 1c7deff

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

packages/backend/src/tokens/__tests__/request.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,31 @@ describe('tokens.authenticateRequest(options)', () => {
15201520
});
15211521
});
15221522

1523+
test('does not trigger handshake when referer is same origin', async () => {
1524+
const request = mockRequestWithCookies(
1525+
{
1526+
host: 'localhost:3000',
1527+
referer: 'http://localhost:3000',
1528+
'sec-fetch-dest': 'document',
1529+
},
1530+
{
1531+
__clerk_db_jwt: mockJwt,
1532+
__session: mockJwt,
1533+
__client_uat: '12345',
1534+
},
1535+
'http://localhost:3000',
1536+
);
1537+
1538+
const requestState = await authenticateRequest(request, {
1539+
...mockOptions(),
1540+
signInUrl: 'http://localhost:3000/sign-in',
1541+
});
1542+
1543+
expect(requestState).toBeSignedIn({
1544+
signInUrl: 'http://localhost:3000/sign-in',
1545+
});
1546+
});
1547+
15231548
test('does not trigger handshake when no referer header', async () => {
15241549
const request = mockRequestWithCookies(
15251550
{

0 commit comments

Comments
 (0)