mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-28 14:04:41 -07:00
migrating console.error to debugger for installationManager, oauth-provider, modifiable-tool (#12279)
This commit is contained in:
@@ -27,6 +27,11 @@ vi.mock('./oauth-token-storage.js', () => {
|
||||
})),
|
||||
};
|
||||
});
|
||||
vi.mock('../utils/events.js', () => ({
|
||||
coreEvents: {
|
||||
emitFeedback: vi.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import * as http from 'node:http';
|
||||
@@ -43,6 +48,7 @@ import type {
|
||||
OAuthAuthorizationServerMetadata,
|
||||
OAuthProtectedResourceMetadata,
|
||||
} from './oauth-utils.js';
|
||||
import { coreEvents } from '../utils/events.js';
|
||||
|
||||
// Mock fetch globally
|
||||
const mockFetch = vi.fn();
|
||||
@@ -938,8 +944,10 @@ describe('MCPOAuthProvider', () => {
|
||||
expect(tokenStorage.deleteCredentials).toHaveBeenCalledWith(
|
||||
'test-server',
|
||||
);
|
||||
expect(console.error).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Failed to refresh token'),
|
||||
expect(coreEvents.emitFeedback).toHaveBeenCalledWith(
|
||||
'error',
|
||||
expect.stringContaining('Failed to refresh auth token'),
|
||||
expect.any(Error),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import type { OAuthToken } from './token-storage/types.js';
|
||||
import { MCPOAuthTokenStorage } from './oauth-token-storage.js';
|
||||
import { getErrorMessage } from '../utils/errors.js';
|
||||
import { OAuthUtils } from './oauth-utils.js';
|
||||
import { coreEvents } from '../utils/events.js';
|
||||
import { debugLogger } from '../utils/debugLogger.js';
|
||||
|
||||
export const OAUTH_DISPLAY_MESSAGE_EVENT = 'oauth-display-message' as const;
|
||||
@@ -811,12 +812,12 @@ ${authUrl}
|
||||
`✓ Token verification successful (fingerprint: ${tokenFingerprint})`,
|
||||
);
|
||||
} else {
|
||||
console.error(
|
||||
debugLogger.warn(
|
||||
'Token verification failed: token not found or invalid after save',
|
||||
);
|
||||
}
|
||||
} catch (saveError) {
|
||||
console.error(`Failed to save token: ${getErrorMessage(saveError)}`);
|
||||
debugLogger.error('Failed to save auth token.', saveError);
|
||||
throw saveError;
|
||||
}
|
||||
|
||||
@@ -889,7 +890,11 @@ ${authUrl}
|
||||
|
||||
return newToken.accessToken;
|
||||
} catch (error) {
|
||||
console.error(`Failed to refresh token: ${getErrorMessage(error)}`);
|
||||
coreEvents.emitFeedback(
|
||||
'error',
|
||||
'Failed to refresh auth token.',
|
||||
error,
|
||||
);
|
||||
// Remove invalid token
|
||||
await this.tokenStorage.deleteCredentials(serverName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user