test(desktop): guard native OAuth parser boundary

This commit is contained in:
Doud-FR 2026-07-29 08:58:08 +02:00 committed by Austin Pickett
parent df1f825ce7
commit ca7659a86c

View file

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