@@ -69,6 +69,7 @@ describe('DataConnectApiClient', () => {
6969 const connectorConfig : ConnectorConfig = {
7070 location : 'us-west2' ,
7171 serviceId : 'my-service' ,
72+ connector : 'my-connector' ,
7273 } ;
7374
7475 const clientWithoutProjectId = new DataConnectApiClient (
@@ -251,6 +252,16 @@ describe('DataConnectApiClient', () => {
251252 clientWithoutProjectId . impersonateQuery ( unauthenticatedOptions )
252253 . should . eventually . be . rejectedWith ( noProjectId ) ;
253254 } ) ;
255+ it ( 'should reject when no connectorId is provided' , ( ) => {
256+ apiClient = new DataConnectApiClient (
257+ { location : connectorConfig . location , serviceId : connectorConfig . serviceId } ,
258+ app
259+ ) ;
260+ apiClient . impersonateQuery ( { impersonate : { unauthenticated : true } } )
261+ . should . eventually . be . rejectedWith (
262+ '`connectorConfig.connector` field used to instantiate Data Connect instance \
263+ must be a non-empty string (the connectorId) when calling impersonate APIs.' ) ;
264+ } ) ;
254265
255266 it ( 'should reject when a full platform error response is received' , ( ) => {
256267 sandbox
@@ -310,7 +321,7 @@ describe('DataConnectApiClient', () => {
310321 expect ( resp . data . users ) . to . deep . equal ( TEST_RESPONSE . data . users ) ;
311322 expect ( stub ) . to . have . been . calledOnce . and . calledWith ( {
312323 method : 'POST' ,
313- url : `https://firebasedataconnect.googleapis.com/v1alpha/projects/test-project/locations/${ connectorConfig . location } /services/${ connectorConfig . serviceId } /connectors/${ connectorConfig . location } - ${ connectorConfig . serviceId } :impersonateQuery` ,
324+ url : `https://firebasedataconnect.googleapis.com/v1alpha/projects/test-project/locations/${ connectorConfig . location } /services/${ connectorConfig . serviceId } /connectors/${ connectorConfig . connector } :impersonateQuery` ,
314325 headers : EXPECTED_HEADERS ,
315326 data : {
316327 operationName : unauthenticatedOptions . operationName ,
@@ -329,7 +340,7 @@ describe('DataConnectApiClient', () => {
329340 . then ( ( ) => {
330341 expect ( stub ) . to . have . been . calledOnce . and . calledWith ( {
331342 method : 'POST' ,
332- url : `http://localhost:9399/v1alpha/projects/test-project/locations/${ connectorConfig . location } /services/${ connectorConfig . serviceId } /connectors/${ connectorConfig . location } - ${ connectorConfig . serviceId } :impersonateQuery` ,
343+ url : `http://localhost:9399/v1alpha/projects/test-project/locations/${ connectorConfig . location } /services/${ connectorConfig . serviceId } /connectors/${ connectorConfig . connector } :impersonateQuery` ,
333344 headers : EMULATOR_EXPECTED_HEADERS ,
334345 data : {
335346 operationName : unauthenticatedOptions . operationName ,
@@ -360,6 +371,16 @@ describe('DataConnectApiClient', () => {
360371 clientWithoutProjectId . impersonateMutation ( unauthenticatedOptions )
361372 . should . eventually . be . rejectedWith ( noProjectId ) ;
362373 } ) ;
374+ it ( 'should reject when no connectorId is provided' , ( ) => {
375+ apiClient = new DataConnectApiClient (
376+ { location : connectorConfig . location , serviceId : connectorConfig . serviceId } ,
377+ app
378+ ) ;
379+ apiClient . impersonateMutation ( { impersonate : { unauthenticated : true } } )
380+ . should . eventually . be . rejectedWith (
381+ '`connectorConfig.connector` field used to instantiate Data Connect instance \
382+ must be a non-empty string (the connectorId) when calling impersonate APIs.' ) ;
383+ } ) ;
363384
364385 it ( 'should reject when a full platform error response is received' , ( ) => {
365386 sandbox
@@ -419,7 +440,7 @@ describe('DataConnectApiClient', () => {
419440 expect ( resp . data . users ) . to . deep . equal ( TEST_RESPONSE . data . users ) ;
420441 expect ( stub ) . to . have . been . calledOnce . and . calledWith ( {
421442 method : 'POST' ,
422- url : `https://firebasedataconnect.googleapis.com/v1alpha/projects/test-project/locations/${ connectorConfig . location } /services/${ connectorConfig . serviceId } /connectors/${ connectorConfig . location } - ${ connectorConfig . serviceId } :impersonateMutation` ,
443+ url : `https://firebasedataconnect.googleapis.com/v1alpha/projects/test-project/locations/${ connectorConfig . location } /services/${ connectorConfig . serviceId } /connectors/${ connectorConfig . connector } :impersonateMutation` ,
423444 headers : EXPECTED_HEADERS ,
424445 data : {
425446 operationName : unauthenticatedOptions . operationName ,
@@ -438,7 +459,7 @@ describe('DataConnectApiClient', () => {
438459 . then ( ( ) => {
439460 expect ( stub ) . to . have . been . calledOnce . and . calledWith ( {
440461 method : 'POST' ,
441- url : `http://localhost:9399/v1alpha/projects/test-project/locations/${ connectorConfig . location } /services/${ connectorConfig . serviceId } /connectors/${ connectorConfig . location } - ${ connectorConfig . serviceId } :impersonateMutation` ,
462+ url : `http://localhost:9399/v1alpha/projects/test-project/locations/${ connectorConfig . location } /services/${ connectorConfig . serviceId } /connectors/${ connectorConfig . connector } :impersonateMutation` ,
442463 headers : EMULATOR_EXPECTED_HEADERS ,
443464 data : {
444465 operationName : unauthenticatedOptions . operationName ,
@@ -459,6 +480,7 @@ describe('DataConnectApiClient CRUD helpers', () => {
459480 const connectorConfig : ConnectorConfig = {
460481 location : 'us-west1' ,
461482 serviceId : 'my-crud-service' ,
483+ connector : 'my-crud-connector' ,
462484 } ;
463485
464486 const mockOptions = {
0 commit comments