Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(e2e): un-skip revoked-session specs; a 403 keeps the session

M3gA-Mindc0c1b5fb52f6
diff --git a/app/test/e2e/specs/auth-access-control.spec.ts b/app/test/e2e/specs/auth-access-control.spec.ts
index 9aaf38ea69..13c7236d88 100644
--- a/app/test/e2e/specs/auth-access-control.spec.ts
+++ b/app/test/e2e/specs/auth-access-control.spec.ts
@@ -445,7 +445,7 @@ describe('Auth & Access Control', () => {
expect(onWelcome).toBe(true);
});
- it.skip('revoked session auto-logs out the user', async function () {
+ it('revoked session auto-logs out the user', async function () {
this.timeout(120_000);
// Login fresh
clearRequestLog();
@@ -524,4 +524,35 @@ describe('Auth & Access Control', () => {
expect(stillOnHome).toBeNull();
console.log('[AuthAccess] Revoked session auto-logout verified');
});
+
+ // The counterpart of the revoked case: only a 401 expires the session, so a
+ // 403 from `/auth/me` (a plan, WAF or proxy refusal) must leave the user
+ // signed in.
+ it('a forbidden /auth/me keeps the user signed in', async function () {
+ this.timeout(120_000);
+ clearRequestLog();
+ resetMockBehavior();
+ setMockBehavior('composioConnections', '[]');
+ await performFullLogin('e2e-forbidden-session-token');
+
+ setMockBehavior('session', 'forbidden');
+ await triggerAuthDeepLink('e2e-forbidden-check-token');
+
+ // 1. The injection landed: `/auth/me` was asked after the 403 was armed.
+ await browser.waitUntil(
+ async () => getRequestLog().some(r => r.method === 'GET' && r.url.includes('/auth/me')),
+ { timeout: 12_000, interval: 500, timeoutMsg: 'no /auth/me request after the 403 was armed' }
+ );
+
+ // 2. The core keeps the credential and the shell stays on Home. The wait
+ // matches the revoked case's 20 s window, in which the background
+ // `/auth/me` refresh of the existing session clears it on a 401 — so a
+ // 403 that still signed out would be caught here.
+ await browser.pause(20_000);
+ const state = await callOpenhumanRpc<AuthStateResponse>('openhuman.auth_get_state', {});
+ expectRpcOk('auth_get_state', state);
+ expect(authStateValue(state).isAuthenticated).toBe(true);
+ expect(await waitForHomePage(5_000)).not.toBeNull();
+ resetMockBehavior();
+ });
});
diff --git a/app/test/e2e/specs/login-flow.spec.ts b/app/test/e2e/specs/login-flow.spec.ts
index 8d405a21ad..7d24a08707 100644
--- a/app/test/e2e/specs/login-flow.spec.ts
+++ b/app/test/e2e/specs/login-flow.spec.ts
@@ -186,7 +186,7 @@ describe('Login flow — complete with mock data (Linux)', () => {
// The host session owner handles the backend credential. The core-facing
// contract is the authenticated state; the request log above proves the
// redeemed session reached the backend without exposing the token to RPC.
- it.skip('the core reports authenticated state after login', async () => {
+ it('the core reports authenticated state after login', async () => {
const state = await callOpenhumanRpc<AuthStateResponse>('openhuman.auth_get_state', {});
expectRpcOk('auth_get_state', state);
const authState = authStateValue(state);
diff --git a/scripts/mock-api/routes/auth.mjs b/scripts/mock-api/routes/auth.mjs
index f54bd70967..3c3560eb12 100644
--- a/scripts/mock-api/routes/auth.mjs
+++ b/scripts/mock-api/routes/auth.mjs
@@ -63,6 +63,11 @@ export async function handleAuth(ctx) {
json(res, 401, { success: false, error: "Unauthorized" });
return true;
}
+ // A refusal on a live session (plan, WAF, proxy): only a 401 expires it.
+ if (mockBehavior.session === "forbidden") {
+ json(res, 403, { success: false, error: "Forbidden", errorCode: "FORBIDDEN" });
+ return true;
+ }
json(res, 200, { success: true, data: getMockUser() });
return true;
}