11import { expect } from "chai"
2- import { Client } from "../../src"
2+ import { Client , connect } from "../../src"
33import { createClient } from "../support/fake_data"
44import { Rabbit } from "../support/rabbit"
55import { eventually , username , password } from "../support/util"
6+ import { getTestNodesFromEnv } from "../support/util"
67import { Version } from "../../src/versions"
78import { randomUUID } from "node:crypto"
9+ import { readFile } from "node:fs/promises"
10+
11+ async function createTlsClient ( ) : Promise < Client > {
12+ const [ firstNode ] = getTestNodesFromEnv ( )
13+ return connect (
14+ {
15+ hostname : firstNode . host ,
16+ port : 5551 ,
17+ mechanism : 'EXTERNAL' ,
18+ ssl : {
19+ ca : await readFile ( "./tls-gen/basic/result/ca_certificate.pem" ) ,
20+ cert : await readFile ( "./tls-gen/basic/result/client_rabbitmq_certificate.pem" ) ,
21+ key : await readFile ( "./tls-gen/basic/result/client_rabbitmq_key.pem" ) ,
22+ } ,
23+ vhost : "/" ,
24+ }
25+ )
26+ }
827
928describe ( "connect" , ( ) => {
1029 let client : Client
@@ -28,6 +47,14 @@ describe("connect", () => {
2847 } , 5000 )
2948 } ) . timeout ( 10000 )
3049
50+ it ( "using EXTERNAL auth" , async ( ) => {
51+ client = await createTlsClient ( )
52+
53+ await eventually ( async ( ) => {
54+ expect ( await rabbit . getConnections ( ) ) . lengthOf ( 1 )
55+ } , 5000 )
56+ } ) . timeout ( 10000 )
57+
3158 it ( "declaring connection name" , async ( ) => {
3259 const connectionName = `connection-name-${ randomUUID ( ) } `
3360 client = await createClient ( username , password , undefined , undefined , undefined , undefined , connectionName )
0 commit comments