mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
Automatically detect non-interactive environments and fall back to a manual, code-based authentication flow (#4475)
This commit is contained in:
committed by
GitHub
parent
003609239f
commit
5b7b6fe608
@@ -31,6 +31,9 @@ vi.mock('http');
|
||||
vi.mock('open');
|
||||
vi.mock('crypto');
|
||||
vi.mock('node:readline');
|
||||
vi.mock('../utils/browser.js', () => ({
|
||||
shouldAttemptBrowserLaunch: () => true,
|
||||
}));
|
||||
|
||||
const mockConfig = {
|
||||
getNoBrowser: () => false,
|
||||
@@ -83,7 +86,7 @@ describe('oauth2', () => {
|
||||
);
|
||||
|
||||
vi.spyOn(crypto, 'randomBytes').mockReturnValue(mockState as never);
|
||||
(open as Mock).mockImplementation(async () => ({}) as never);
|
||||
(open as Mock).mockImplementation(async () => ({ on: vi.fn() }) as never);
|
||||
|
||||
// Mock the UserInfo API response
|
||||
(global.fetch as Mock).mockResolvedValue({
|
||||
@@ -236,7 +239,7 @@ describe('oauth2', () => {
|
||||
expect(mockGetToken).toHaveBeenCalledWith({
|
||||
code: mockCode,
|
||||
codeVerifier: mockCodeVerifier.codeVerifier,
|
||||
redirect_uri: 'https://sdk.cloud.google.com/authcode_cloudcode.html',
|
||||
redirect_uri: 'https://codeassist.google.com/authcode',
|
||||
});
|
||||
expect(mockSetCredentials).toHaveBeenCalledWith(mockTokens);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user