@@ -2,13 +2,13 @@ import { deepStrictEqual, ok, rejects } from 'node:assert'
22import { once } from 'node:events'
33import { before , test } from 'node:test'
44import {
5+ allowedSASLMechanisms ,
56 AuthenticationError ,
67 Base ,
78 MultipleErrors ,
89 NetworkError ,
910 parseBroker ,
10- sleep ,
11- type SASLMechanism
11+ sleep
1212} from '../../../src/index.ts'
1313import { createScramUsers } from '../../fixtures/create-users.ts'
1414import { kafkaSaslBootstrapServers } from '../../helpers.ts'
@@ -29,14 +29,20 @@ test('UNAUTHENTICATED - should not connect to SASL protected broker by default',
2929 await rejects ( ( ) => base . metadata ( { topics : [ ] } ) )
3030} )
3131
32- for ( const mechanism of [ 'PLAIN' , 'SCRAM-SHA-256' , 'SCRAM-SHA-512' ] ) {
32+ for ( const mechanism of allowedSASLMechanisms ) {
33+ if ( mechanism === 'OAUTHBEARER' ) {
34+ // GSSAPI requires a properly configured Kerberos environment
35+ // which is out of scope for these tests
36+ continue
37+ }
38+
3339 test ( `${ mechanism } - should connect to SASL protected broker` , async t => {
3440 const base = new Base ( {
3541 clientId : 'clientId' ,
3642 bootstrapBrokers : kafkaSaslBootstrapServers ,
3743 strict : true ,
3844 retries : 0 ,
39- sasl : { mechanism : mechanism as SASLMechanism , username : 'admin' , password : 'admin' }
45+ sasl : { mechanism, username : 'admin' , password : 'admin' }
4046 } )
4147
4248 t . after ( ( ) => base . close ( ) )
@@ -51,7 +57,7 @@ for (const mechanism of ['PLAIN', 'SCRAM-SHA-256', 'SCRAM-SHA-512']) {
5157 clientId : 'clientId' ,
5258 bootstrapBrokers : kafkaSaslBootstrapServers ,
5359 retries : 0 ,
54- sasl : { mechanism : mechanism as SASLMechanism , username : 'admin' , password : 'invalid' }
60+ sasl : { mechanism, username : 'admin' , password : 'invalid' }
5561 } )
5662
5763 t . after ( ( ) => base . close ( ) )
@@ -72,7 +78,7 @@ for (const mechanism of ['PLAIN', 'SCRAM-SHA-256', 'SCRAM-SHA-512']) {
7278 strict : true ,
7379 retries : 0 ,
7480 sasl : {
75- mechanism : mechanism as SASLMechanism ,
81+ mechanism,
7682 username ( ) {
7783 return 'admin'
7884 } ,
@@ -94,7 +100,7 @@ for (const mechanism of ['PLAIN', 'SCRAM-SHA-256', 'SCRAM-SHA-512']) {
94100 strict : true ,
95101 retries : 0 ,
96102 sasl : {
97- mechanism : mechanism as SASLMechanism ,
103+ mechanism,
98104 username : 'admin' ,
99105 async password ( ) {
100106 await sleep ( 1000 )
@@ -117,7 +123,7 @@ for (const mechanism of ['PLAIN', 'SCRAM-SHA-256', 'SCRAM-SHA-512']) {
117123 strict : true ,
118124 retries : 0 ,
119125 sasl : {
120- mechanism : mechanism as SASLMechanism ,
126+ mechanism,
121127 username ( ) {
122128 throw new Error ( 'Kaboom!' )
123129 }
@@ -150,7 +156,7 @@ for (const mechanism of ['PLAIN', 'SCRAM-SHA-256', 'SCRAM-SHA-512']) {
150156 strict : true ,
151157 retries : 0 ,
152158 sasl : {
153- mechanism : mechanism as SASLMechanism ,
159+ mechanism,
154160 username : 'admin' ,
155161 async password ( ) {
156162 throw new Error ( 'Kaboom!' )
@@ -183,7 +189,7 @@ for (const mechanism of ['PLAIN', 'SCRAM-SHA-256', 'SCRAM-SHA-512']) {
183189 bootstrapBrokers : kafkaSaslBootstrapServers ,
184190 strict : true ,
185191 retries : 0 ,
186- sasl : { mechanism : mechanism as SASLMechanism , username : 'admin' , password : 'admin' }
192+ sasl : { mechanism, username : 'admin' , password : 'admin' }
187193 } )
188194
189195 t . after ( ( ) => base . close ( ) )
0 commit comments