@@ -21,24 +21,38 @@ function parsed(): OcxParsedRequest {
2121describe ( "client fingerprint — helpers" , ( ) => {
2222 test ( "antigravity UA has the real IDE shape, never the literal giveaway" , async ( ) => {
2323 const ua = antigravityUserAgent ( ) ;
24- expect ( ua ) . toBe ( `antigravity/ide/${ ANTIGRAVITY_IDE_VERSION } (aidev_client; os_type=windows; arch=amd64)` ) ;
24+ expect ( ua ) . toBe ( `antigravity/ide/${ ANTIGRAVITY_IDE_VERSION } (os_type=windows; arch=amd64; aidev_client; auth_method=oauth )` ) ;
2525 expect ( ua ) . not . toBe ( "antigravity" ) ;
2626 } ) ;
2727
28- test ( "antigravity UA honors an explicit version override" , async ( ) => {
29- expect ( antigravityUserAgent ( "9.9.9" ) ) . toBe ( "antigravity/ide/9.9.9 (aidev_client; os_type=windows; arch=amd64)" ) ;
28+ test ( "antigravity UA honors explicit version and authMethod overrides" , async ( ) => {
29+ 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
32- test ( "GOOGLE_ANTIGRAVITY_USER_AGENT env override wins over the default UA" , async ( ) => {
33- const prev = process . env . GOOGLE_ANTIGRAVITY_USER_AGENT ;
34- process . env . GOOGLE_ANTIGRAVITY_USER_AGENT = "custom-ua/1.2.3" ;
35+ test ( "GOOGLE_ANTIGRAVITY_USER_AGENT env override trims surrounding whitespace" , async ( ) => {
36+ const prevGoogle = process . env . GOOGLE_ANTIGRAVITY_USER_AGENT ;
3537 try {
36- // Fresh module instance so the env-driven constant is re-evaluated at import time.
37- const mod = await import ( `../src/adapters/google-antigravity-wire?override=${ Date . now ( ) } ` ) ;
38- expect ( mod . ANTIGRAVITY_REQUEST_UA ) . toBe ( "custom-ua/1.2.3" ) ;
38+ process . env . GOOGLE_ANTIGRAVITY_USER_AGENT = " custom-ua/1.2.3 " ;
39+ expect ( antigravityUserAgent ( ) ) . toBe ( "custom-ua/1.2.3" ) ;
3940 } finally {
40- if ( prev === undefined ) delete process . env . GOOGLE_ANTIGRAVITY_USER_AGENT ;
41- else process . env . GOOGLE_ANTIGRAVITY_USER_AGENT = prev ;
41+ if ( prevGoogle === undefined ) delete process . env . GOOGLE_ANTIGRAVITY_USER_AGENT ;
42+ else process . env . GOOGLE_ANTIGRAVITY_USER_AGENT = prevGoogle ;
43+ }
44+ } ) ;
45+
46+ test ( "whitespace-only GOOGLE_ANTIGRAVITY_USER_AGENT falls back to default UA" , async ( ) => {
47+ const prevGoogle = process . env . GOOGLE_ANTIGRAVITY_USER_AGENT ;
48+ try {
49+ process . env . GOOGLE_ANTIGRAVITY_USER_AGENT = " " ;
50+ expect ( antigravityUserAgent ( ) ) . toBe (
51+ `antigravity/ide/${ ANTIGRAVITY_IDE_VERSION } (os_type=windows; arch=amd64; aidev_client; auth_method=oauth)` ,
52+ ) ;
53+ } finally {
54+ if ( prevGoogle === undefined ) delete process . env . GOOGLE_ANTIGRAVITY_USER_AGENT ;
55+ else process . env . GOOGLE_ANTIGRAVITY_USER_AGENT = prevGoogle ;
4256 }
4357 } ) ;
4458
0 commit comments