From ca7659a86c6a98be9a187e7cbb71cea188a4e043 Mon Sep 17 00:00:00 2001 From: Doud-FR <59610009+Doud-FR@users.noreply.github.com> Date: Wed, 29 Jul 2026 08:58:08 +0200 Subject: [PATCH] test(desktop): guard native OAuth parser boundary --- apps/desktop/electron/native-oauth.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/desktop/electron/native-oauth.test.ts b/apps/desktop/electron/native-oauth.test.ts index 38abae643be..bf58ca996ef 100644 --- a/apps/desktop/electron/native-oauth.test.ts +++ b/apps/desktop/electron/native-oauth.test.ts @@ -193,6 +193,19 @@ test('parseStoredTokenSet maps the encrypted on-disk camelCase shape', () => { assert.equal(t.userId, 'u-stored') }) +test('parseTokenResponse cannot read a persisted set (the reload bug #73271)', () => { + // Guards against regressing to the wrong parser on the reload path: a + // persisted camelCase set has no snake_case access_token, so the raw-response + // parser throws — which is exactly why the stored path must use + // parseStoredTokenSet instead. + const persisted = JSON.parse( + JSON.stringify({ accessToken: 'AT', refreshToken: 'RT', expiresAt: 1, provider: 'nous', userId: 'u' }) + ) + + assert.throws(() => parseTokenResponse(persisted), /missing access_token/i) + assert.equal(parseStoredTokenSet(persisted).accessToken, 'AT') +}) + test('parseStoredTokenSet rejects a non-normalized server response', () => { assert.throws( () => parseStoredTokenSet({ access_token: 'AT-server' }),