@@ -17,7 +17,6 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
1717 await importOriginal < typeof import ( '@google/gemini-cli-core' ) > ( ) ;
1818 return {
1919 ...actual ,
20- getErrorMessage : ( e : unknown ) => ( e as Error ) . message ,
2120 } ;
2221} ) ;
2322
@@ -32,7 +31,7 @@ describe('auth', () => {
3231
3332 it ( 'should return null if authType is undefined' , async ( ) => {
3433 const result = await performInitialAuth ( mockConfig , undefined ) ;
35- expect ( result ) . toBeNull ( ) ;
34+ expect ( result ) . toEqual ( { authError : null , accountSuspensionInfo : null } ) ;
3635 expect ( mockConfig . refreshAuth ) . not . toHaveBeenCalled ( ) ;
3736 } ) ;
3837
@@ -41,7 +40,7 @@ describe('auth', () => {
4140 mockConfig ,
4241 AuthType . LOGIN_WITH_GOOGLE ,
4342 ) ;
44- expect ( result ) . toBeNull ( ) ;
43+ expect ( result ) . toEqual ( { authError : null , accountSuspensionInfo : null } ) ;
4544 expect ( mockConfig . refreshAuth ) . toHaveBeenCalledWith (
4645 AuthType . LOGIN_WITH_GOOGLE ,
4746 ) ;
@@ -54,7 +53,10 @@ describe('auth', () => {
5453 mockConfig ,
5554 AuthType . LOGIN_WITH_GOOGLE ,
5655 ) ;
57- expect ( result ) . toBe ( 'Failed to login. Message: Auth failed' ) ;
56+ expect ( result ) . toEqual ( {
57+ authError : 'Failed to login. Message: Auth failed' ,
58+ accountSuspensionInfo : null ,
59+ } ) ;
5860 expect ( mockConfig . refreshAuth ) . toHaveBeenCalledWith (
5961 AuthType . LOGIN_WITH_GOOGLE ,
6062 ) ;
@@ -68,7 +70,48 @@ describe('auth', () => {
6870 mockConfig ,
6971 AuthType . LOGIN_WITH_GOOGLE ,
7072 ) ;
71- expect ( result ) . toBeNull ( ) ;
73+ expect ( result ) . toEqual ( { authError : null , accountSuspensionInfo : null } ) ;
74+ expect ( mockConfig . refreshAuth ) . toHaveBeenCalledWith (
75+ AuthType . LOGIN_WITH_GOOGLE ,
76+ ) ;
77+ } ) ;
78+
79+ it ( 'should return accountSuspensionInfo for 403 TOS_VIOLATION error' , async ( ) => {
80+ vi . mocked ( mockConfig . refreshAuth ) . mockRejectedValue ( {
81+ response : {
82+ data : {
83+ error : {
84+ code : 403 ,
85+ message :
86+ 'This service has been disabled for violation of Terms of Service.' ,
87+ details : [
88+ {
89+ '@type' : 'type.googleapis.com/google.rpc.ErrorInfo' ,
90+ reason : 'TOS_VIOLATION' ,
91+ domain : 'example.googleapis.com' ,
92+ metadata : {
93+ appeal_url : 'https://example.com/appeal' ,
94+ appeal_url_link_text : 'Appeal Here' ,
95+ } ,
96+ } ,
97+ ] ,
98+ } ,
99+ } ,
100+ } ,
101+ } ) ;
102+ const result = await performInitialAuth (
103+ mockConfig ,
104+ AuthType . LOGIN_WITH_GOOGLE ,
105+ ) ;
106+ expect ( result ) . toEqual ( {
107+ authError : null ,
108+ accountSuspensionInfo : {
109+ message :
110+ 'This service has been disabled for violation of Terms of Service.' ,
111+ appealUrl : 'https://example.com/appeal' ,
112+ appealLinkText : 'Appeal Here' ,
113+ } ,
114+ } ) ;
72115 expect ( mockConfig . refreshAuth ) . toHaveBeenCalledWith (
73116 AuthType . LOGIN_WITH_GOOGLE ,
74117 ) ;
0 commit comments