@@ -50,7 +50,7 @@ export class Backend {
5050 private server : Server | null = null ;
5151 private receivedCallCount = 0 ;
5252 private callListeners : ( ( ) => void ) [ ] = [ ] ;
53- constructor ( private port : number , private useXdsServer : boolean , private serverOptions ?: ServerOptions ) {
53+ constructor ( private port : number , private useXdsServer : boolean , private creds ?: ServerCredentials | undefined , private serverOptions ?: ServerOptions ) {
5454 }
5555 Echo ( call : ServerUnaryCall < EchoRequest__Output , EchoResponse > , callback : sendUnaryData < EchoResponse > ) {
5656 // call.request.params is currently ignored
@@ -90,9 +90,8 @@ export class Backend {
9090 }
9191 const server = this . server ;
9292 server . addService ( loadedProtos . grpc . testing . EchoTestService . service , this as unknown as UntypedServiceImplementation ) ;
93- const insecureCredentials = ServerCredentials . createInsecure ( ) ;
94- const xdsCredentials = new XdsServerCredentials ( insecureCredentials ) ;
95- server . bindAsync ( `[::1]:${ this . port } ` , xdsCredentials , ( error , port ) => {
93+ const credentials = this . creds ?? ServerCredentials . createInsecure ( ) ;
94+ server . bindAsync ( `[::1]:${ this . port } ` , credentials , ( error , port ) => {
9695 if ( ! error ) {
9796 this . port = port ;
9897 }
@@ -148,7 +147,7 @@ export class Backend {
148147 }
149148}
150149
151- export async function createBackends ( count : number , useXdsServer ?: boolean , serverOptions ?: ServerOptions ) : Promise < Backend [ ] > {
150+ export async function createBackends ( count : number , useXdsServer ?: boolean , creds ?: ServerCredentials | undefined , serverOptions ?: ServerOptions ) : Promise < Backend [ ] > {
152151 const ports = await findFreePorts ( count ) ;
153- return ports . map ( port => new Backend ( port , useXdsServer ?? true , serverOptions ) ) ;
152+ return ports . map ( port => new Backend ( port , useXdsServer ?? true , creds , serverOptions ) ) ;
154153}
0 commit comments