@@ -204,6 +204,99 @@ tap.test('route unbind', function (t) {
204
204
} )
205
205
} )
206
206
207
+ tap . test ( 'bind/unbind identity anonymous' , function ( t ) {
208
+ const server = ldap . createServer ( {
209
+ connectionRouter : function ( c ) {
210
+ server . newConnection ( c )
211
+ server . emit ( 'testconnection' , c )
212
+ }
213
+ } )
214
+
215
+ server . unbind ( function ( req , res , next ) {
216
+ t . ok ( true , 'server unbind successful' )
217
+ res . end ( )
218
+ return next ( )
219
+ } )
220
+
221
+ server . bind ( '' , function ( req , res , next ) {
222
+ t . ok ( true , 'server bind successful' )
223
+ res . end ( )
224
+ return next ( )
225
+ } )
226
+
227
+ const anonDN = ldap . dn . parse ( 'cn=anonymous' )
228
+
229
+ server . listen ( t . context . sock , function ( ) {
230
+ t . ok ( true , 'server startup' )
231
+
232
+ const client = ldap . createClient ( { socketPath : t . context . sock } )
233
+ server . once ( 'testconnection' , ( c ) => {
234
+ t . ok ( anonDN . equals ( c . ldap . bindDN ) , 'pre bind dn is correct' )
235
+ client . bind ( '' , '' , function ( err ) {
236
+ t . error ( err , 'client anon bind error' )
237
+ t . ok ( anonDN . equals ( c . ldap . bindDN ) , 'anon bind dn is correct' )
238
+ client . unbind ( function ( err ) {
239
+ t . error ( err , 'client anon unbind error' )
240
+ t . ok ( anonDN . equals ( c . ldap . bindDN ) , 'anon unbind dn is correct' )
241
+ server . close ( ( ) => t . end ( ) )
242
+ } )
243
+ } )
244
+ } )
245
+ } )
246
+ } )
247
+
248
+ tap . test ( 'bind/unbind identity user' , function ( t ) {
249
+ const server = ldap . createServer ( {
250
+ connectionRouter : function ( c ) {
251
+ server . newConnection ( c )
252
+ server . emit ( 'testconnection' , c )
253
+ }
254
+ } )
255
+
256
+ server . unbind ( function ( req , res , next ) {
257
+ t . ok ( true , 'server unbind successful' )
258
+ res . end ( )
259
+ return next ( )
260
+ } )
261
+
262
+ server . bind ( '' , function ( req , res , next ) {
263
+ t . ok ( true , 'server bind successful' )
264
+ res . end ( )
265
+ return next ( )
266
+ } )
267
+
268
+ const anonDN = ldap . dn . parse ( 'cn=anonymous' )
269
+ const testDN = ldap . dn . parse ( 'cn=anotheruser' )
270
+
271
+ server . listen ( t . context . sock , function ( ) {
272
+ t . ok ( true , 'server startup' )
273
+
274
+ const client = ldap . createClient ( { socketPath : t . context . sock } )
275
+ server . once ( 'testconnection' , ( c ) => {
276
+ t . ok ( anonDN . equals ( c . ldap . bindDN ) , 'pre bind dn is correct' )
277
+ client . bind ( testDN . toString ( ) , 'somesecret' , function ( err ) {
278
+ t . error ( err , 'user bind error' )
279
+ t . ok ( testDN . equals ( c . ldap . bindDN ) , 'user bind dn is correct' )
280
+ // check rebinds too
281
+ client . bind ( '' , '' , function ( err ) {
282
+ t . error ( err , 'client anon bind error' )
283
+ t . ok ( anonDN . equals ( c . ldap . bindDN ) , 'anon bind dn is correct' )
284
+ // user rebind
285
+ client . bind ( testDN . toString ( ) , 'somesecret' , function ( err ) {
286
+ t . error ( err , 'user bind error' )
287
+ t . ok ( testDN . equals ( c . ldap . bindDN ) , 'user rebind dn is correct' )
288
+ client . unbind ( function ( err ) {
289
+ t . error ( err , 'user unbind error' )
290
+ t . ok ( anonDN . equals ( c . ldap . bindDN ) , 'user unbind dn is correct' )
291
+ server . close ( ( ) => t . end ( ) )
292
+ } )
293
+ } )
294
+ } )
295
+ } )
296
+ } )
297
+ } )
298
+ } )
299
+
207
300
tap . test ( 'strict routing' , function ( t ) {
208
301
const testDN = 'cn=valid'
209
302
let clt
0 commit comments