@@ -456,7 +456,7 @@ describe('ApiClient', () => {
456456 expect ( client . isVertexAI ( ) ) . toBe ( true ) ;
457457 expect ( client . getProject ( ) ) . toBe ( 'vertex-project' ) ;
458458 expect ( client . getLocation ( ) ) . toBe ( 'vertex-location' ) ;
459- expect ( client . getApiKey ( ) ) . toBeUndefined ( ) ; // API key is ignored when setting opts.vertexai
459+ expect ( client . getApiKey ( ) ) . toBe ( 'apikey-from-opts' ) ;
460460 expect ( client . getRequestUrl ( ) ) . toBe (
461461 'https://vertex-location-aiplatform.googleapis.com/v1beta1' ,
462462 ) ;
@@ -478,7 +478,7 @@ describe('ApiClient', () => {
478478 expect ( client . isVertexAI ( ) ) . toBe ( true ) ;
479479 expect ( client . getProject ( ) ) . toBe ( 'vertex-project' ) ;
480480 expect ( client . getLocation ( ) ) . toBe ( 'us' ) ;
481- expect ( client . getApiKey ( ) ) . toBeUndefined ( ) ;
481+ expect ( client . getApiKey ( ) ) . toBe ( 'apikey-from-opts' ) ;
482482 expect ( client . getRequestUrl ( ) ) . toBe (
483483 'https://aiplatform.us.rep.googleapis.com/v1beta1' ,
484484 ) ;
@@ -500,7 +500,7 @@ describe('ApiClient', () => {
500500 expect ( client . isVertexAI ( ) ) . toBe ( true ) ;
501501 expect ( client . getProject ( ) ) . toBe ( 'vertex-project' ) ;
502502 expect ( client . getLocation ( ) ) . toBe ( 'eu' ) ;
503- expect ( client . getApiKey ( ) ) . toBeUndefined ( ) ;
503+ expect ( client . getApiKey ( ) ) . toBe ( 'apikey-from-opts' ) ;
504504 expect ( client . getRequestUrl ( ) ) . toBe (
505505 'https://aiplatform.eu.rep.googleapis.com/v1beta1' ,
506506 ) ;
@@ -523,12 +523,12 @@ describe('ApiClient', () => {
523523 expect ( client . isVertexAI ( ) ) . toBe ( true ) ;
524524 expect ( client . getProject ( ) ) . toBe ( 'vertex-project' ) ;
525525 expect ( client . getLocation ( ) ) . toBe ( 'us' ) ;
526- expect ( client . getApiKey ( ) ) . toBeUndefined ( ) ;
526+ expect ( client . getApiKey ( ) ) . toBe ( 'apikey-from-opts' ) ;
527527 expect ( client . getRequestUrl ( ) ) . toBe ( 'https://my-custom-url.com/v1beta1' ) ;
528528 expect ( client . getApiVersion ( ) ) . toBe ( 'v1beta1' ) ;
529529 } ) ;
530530
531- it ( 'should not have api key if project/location is provided for vertexai' , ( ) => {
531+ it ( 'should preserve api key if project/location is provided for vertexai' , ( ) => {
532532 const client = new ApiClient ( {
533533 auth : new FakeAuth ( ) ,
534534 project : 'vertex-project' ,
@@ -542,7 +542,7 @@ describe('ApiClient', () => {
542542 expect ( client . isVertexAI ( ) ) . toBe ( true ) ;
543543 expect ( client . getProject ( ) ) . toBe ( 'vertex-project' ) ;
544544 expect ( client . getLocation ( ) ) . toBe ( 'vertex-location' ) ;
545- expect ( client . getApiKey ( ) ) . toBeUndefined ( ) ;
545+ expect ( client . getApiKey ( ) ) . toBe ( 'apikey-from-opts' ) ;
546546 expect ( client . getRequestUrl ( ) ) . toBe (
547547 'https://vertex-location-aiplatform.googleapis.com/v1beta1' ,
548548 ) ;
0 commit comments