Skip to content

The agent that grows with you

test(desktop): guard native OAuth parser boundary

Doud-FRca7659a86c6a
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' }),