mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-23 19:44:30 -07:00
feat: consolidate remote MCP servers to use url in config (#13762)
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { isAuthenticationError, UnauthorizedError } from './errors.js';
|
||||
|
||||
describe('isAuthenticationError', () => {
|
||||
it('should detect error with code: 401 property (MCP SDK style)', () => {
|
||||
const error = { code: 401, message: 'Unauthorized' };
|
||||
expect(isAuthenticationError(error)).toBe(true);
|
||||
});
|
||||
|
||||
it('should detect UnauthorizedError instance', () => {
|
||||
const error = new UnauthorizedError('Authentication required');
|
||||
expect(isAuthenticationError(error)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for 404 errors', () => {
|
||||
const error = { code: 404, message: 'Not Found' };
|
||||
expect(isAuthenticationError(error)).toBe(false);
|
||||
});
|
||||
|
||||
it('should handle null and undefined gracefully', () => {
|
||||
expect(isAuthenticationError(null)).toBe(false);
|
||||
expect(isAuthenticationError(undefined)).toBe(false);
|
||||
});
|
||||
|
||||
it('should handle non-error objects', () => {
|
||||
expect(isAuthenticationError('string error')).toBe(false);
|
||||
expect(isAuthenticationError(123)).toBe(false);
|
||||
expect(isAuthenticationError({})).toBe(false);
|
||||
});
|
||||
|
||||
it('should detect 401 in various message formats', () => {
|
||||
expect(isAuthenticationError(new Error('401 Unauthorized'))).toBe(true);
|
||||
expect(isAuthenticationError(new Error('HTTP 401'))).toBe(true);
|
||||
expect(isAuthenticationError(new Error('Status code: 401'))).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user