@@ -25,55 +25,34 @@ describe("client fingerprint — helpers", () => {
2525 expect ( ua ) . not . toBe ( "antigravity" ) ;
2626 } ) ;
2727
28- test ( "antigravity UA honors an explicit version override " , async ( ) => {
28+ test ( "antigravity UA honors explicit version and authMethod overrides " , async ( ) => {
2929 expect ( antigravityUserAgent ( "9.9.9" ) ) . toBe ( "antigravity/ide/9.9.9 (os_type=windows; arch=amd64; aidev_client; auth_method=oauth)" ) ;
30+ expect ( antigravityUserAgent ( ANTIGRAVITY_IDE_VERSION , "api_key" ) ) . toBe (
31+ `antigravity/ide/${ ANTIGRAVITY_IDE_VERSION } (os_type=windows; arch=amd64; aidev_client; auth_method=api_key)` ,
32+ ) ;
3033 } ) ;
3134
3235 test ( "GOOGLE_ANTIGRAVITY_USER_AGENT env override trims surrounding whitespace" , async ( ) => {
3336 const prevGoogle = process . env . GOOGLE_ANTIGRAVITY_USER_AGENT ;
34- const prevPi = process . env . PI_AI_ANTIGRAVITY_USER_AGENT ;
3537 try {
3638 process . env . GOOGLE_ANTIGRAVITY_USER_AGENT = " custom-ua/1.2.3 " ;
37- delete process . env . PI_AI_ANTIGRAVITY_USER_AGENT ;
3839 expect ( antigravityUserAgent ( ) ) . toBe ( "custom-ua/1.2.3" ) ;
3940 } finally {
4041 if ( prevGoogle === undefined ) delete process . env . GOOGLE_ANTIGRAVITY_USER_AGENT ;
4142 else process . env . GOOGLE_ANTIGRAVITY_USER_AGENT = prevGoogle ;
42- if ( prevPi === undefined ) delete process . env . PI_AI_ANTIGRAVITY_USER_AGENT ;
43- else process . env . PI_AI_ANTIGRAVITY_USER_AGENT = prevPi ;
4443 }
4544 } ) ;
4645
47- test ( "PI_AI_ANTIGRAVITY_USER_AGENT env override works when GOOGLE override is absent " , async ( ) => {
46+ test ( "whitespace-only GOOGLE_ANTIGRAVITY_USER_AGENT falls back to default UA " , async ( ) => {
4847 const prevGoogle = process . env . GOOGLE_ANTIGRAVITY_USER_AGENT ;
49- const prevPi = process . env . PI_AI_ANTIGRAVITY_USER_AGENT ;
5048 try {
51- delete process . env . GOOGLE_ANTIGRAVITY_USER_AGENT ;
52- process . env . PI_AI_ANTIGRAVITY_USER_AGENT = " pi-ua/9.9.9 " ;
53- expect ( antigravityUserAgent ( ) ) . toBe ( "pi-ua/9.9.9" ) ;
54- } finally {
55- if ( prevGoogle === undefined ) delete process . env . GOOGLE_ANTIGRAVITY_USER_AGENT ;
56- else process . env . GOOGLE_ANTIGRAVITY_USER_AGENT = prevGoogle ;
57- if ( prevPi === undefined ) delete process . env . PI_AI_ANTIGRAVITY_USER_AGENT ;
58- else process . env . PI_AI_ANTIGRAVITY_USER_AGENT = prevPi ;
59- }
60- } ) ;
61-
62- test ( "GOOGLE_ANTIGRAVITY_USER_AGENT takes precedence over PI_AI override, whitespace-only falls back" , async ( ) => {
63- const prevGoogle = process . env . GOOGLE_ANTIGRAVITY_USER_AGENT ;
64- const prevPi = process . env . PI_AI_ANTIGRAVITY_USER_AGENT ;
65- try {
66- process . env . GOOGLE_ANTIGRAVITY_USER_AGENT = "google-wins/1.0" ;
67- process . env . PI_AI_ANTIGRAVITY_USER_AGENT = "pi-secondary/2.0" ;
68- expect ( antigravityUserAgent ( ) ) . toBe ( "google-wins/1.0" ) ;
69-
7049 process . env . GOOGLE_ANTIGRAVITY_USER_AGENT = " " ;
71- expect ( antigravityUserAgent ( ) ) . toBe ( "pi-secondary/2.0" ) ;
50+ expect ( antigravityUserAgent ( ) ) . toBe (
51+ `antigravity/ide/${ ANTIGRAVITY_IDE_VERSION } (os_type=windows; arch=amd64; aidev_client; auth_method=oauth)` ,
52+ ) ;
7253 } finally {
7354 if ( prevGoogle === undefined ) delete process . env . GOOGLE_ANTIGRAVITY_USER_AGENT ;
7455 else process . env . GOOGLE_ANTIGRAVITY_USER_AGENT = prevGoogle ;
75- if ( prevPi === undefined ) delete process . env . PI_AI_ANTIGRAVITY_USER_AGENT ;
76- else process . env . PI_AI_ANTIGRAVITY_USER_AGENT = prevPi ;
7756 }
7857 } ) ;
7958
0 commit comments