feat: add Gemini ADC and access token auth (#312)
* feat: add Gemini ADC and access token auth * feat: add Gemini token and ADC provider setup * feat: add Gemini token and ADC provider setup * fix: honor Gemini auth mode on restart
This commit is contained in:
@@ -355,11 +355,38 @@ test('gemini profiles accept google api key fallback', () => {
|
||||
})
|
||||
|
||||
assert.deepEqual(env, {
|
||||
GEMINI_AUTH_MODE: 'api-key',
|
||||
GEMINI_MODEL: 'gemini-2.0-flash',
|
||||
GEMINI_API_KEY: 'gem-live',
|
||||
})
|
||||
})
|
||||
|
||||
test('gemini profiles support access-token auth mode without persisting a key', () => {
|
||||
const env = buildGeminiProfileEnv({
|
||||
authMode: 'access-token',
|
||||
model: 'gemini-2.5-flash',
|
||||
processEnv: {},
|
||||
})
|
||||
|
||||
assert.deepEqual(env, {
|
||||
GEMINI_AUTH_MODE: 'access-token',
|
||||
GEMINI_MODEL: 'gemini-2.5-flash',
|
||||
})
|
||||
})
|
||||
|
||||
test('gemini profiles support adc auth mode without persisting a key', () => {
|
||||
const env = buildGeminiProfileEnv({
|
||||
authMode: 'adc',
|
||||
model: 'gemini-2.5-flash',
|
||||
processEnv: {},
|
||||
})
|
||||
|
||||
assert.deepEqual(env, {
|
||||
GEMINI_AUTH_MODE: 'adc',
|
||||
GEMINI_MODEL: 'gemini-2.5-flash',
|
||||
})
|
||||
})
|
||||
|
||||
test('gemini profiles require a key', () => {
|
||||
const env = buildGeminiProfileEnv({
|
||||
processEnv: {},
|
||||
@@ -405,6 +432,39 @@ test('buildStartupEnvFromProfile applies persisted gemini settings when no provi
|
||||
assert.equal(env.GEMINI_MODEL, 'gemini-2.5-flash')
|
||||
})
|
||||
|
||||
test('buildStartupEnvFromProfile rehydrates stored Gemini access token for access-token profile mode', async () => {
|
||||
const env = await buildStartupEnvFromProfile({
|
||||
persisted: profile('gemini', {
|
||||
GEMINI_AUTH_MODE: 'access-token',
|
||||
GEMINI_MODEL: 'gemini-2.5-flash',
|
||||
}),
|
||||
processEnv: {},
|
||||
readGeminiAccessToken: () => 'token-live',
|
||||
})
|
||||
|
||||
assert.equal(env.CLAUDE_CODE_USE_GEMINI, '1')
|
||||
assert.equal(env.GEMINI_AUTH_MODE, 'access-token')
|
||||
assert.equal(env.GEMINI_ACCESS_TOKEN, 'token-live')
|
||||
assert.equal(env.GEMINI_API_KEY, undefined)
|
||||
assert.equal(env.GEMINI_MODEL, 'gemini-2.5-flash')
|
||||
})
|
||||
|
||||
test('buildStartupEnvFromProfile does not inject stored access token for adc profile mode', async () => {
|
||||
const env = await buildStartupEnvFromProfile({
|
||||
persisted: profile('gemini', {
|
||||
GEMINI_AUTH_MODE: 'adc',
|
||||
GEMINI_MODEL: 'gemini-2.5-flash',
|
||||
}),
|
||||
processEnv: {},
|
||||
readGeminiAccessToken: () => 'token-live',
|
||||
})
|
||||
|
||||
assert.equal(env.CLAUDE_CODE_USE_GEMINI, '1')
|
||||
assert.equal(env.GEMINI_AUTH_MODE, 'adc')
|
||||
assert.equal(env.GEMINI_ACCESS_TOKEN, undefined)
|
||||
assert.equal(env.GEMINI_API_KEY, undefined)
|
||||
})
|
||||
|
||||
test('buildStartupEnvFromProfile leaves explicit provider selections untouched', async () => {
|
||||
const processEnv = {
|
||||
CLAUDE_CODE_USE_GEMINI: '1',
|
||||
|
||||
Reference in New Issue
Block a user