@@ -10,6 +10,7 @@ const Attribute = require('@ldapjs/attribute')
10
10
const Change = require ( '@ldapjs/change' )
11
11
const messages = require ( '@ldapjs/messages' )
12
12
const controls = require ( '@ldapjs/controls' )
13
+ const dn = require ( '@ldapjs/dn' )
13
14
const ldap = require ( '../lib' )
14
15
15
16
const {
@@ -761,6 +762,36 @@ tap.test('search basic', function (t) {
761
762
} )
762
763
} )
763
764
765
+ tap . test ( 'search basic with DN' , function ( t ) {
766
+ const { SearchResultEntry, SearchResultDone } = messages
767
+
768
+ t . context . client . search ( dn . DN . fromString ( 'cn=test, ' + SUFFIX , '(objectclass=*)' ) , function ( err , res ) {
769
+ t . error ( err )
770
+ t . ok ( res )
771
+ let gotEntry = 0
772
+ res . on ( 'searchEntry' , function ( entry ) {
773
+ t . ok ( entry )
774
+ t . ok ( entry instanceof SearchResultEntry )
775
+ t . equal ( entry . dn . toString ( ) , 'cn=test,' + SUFFIX )
776
+ t . ok ( entry . attributes )
777
+ t . ok ( entry . attributes . length )
778
+ t . equal ( entry . attributes [ 0 ] . type , 'cn' )
779
+ t . equal ( entry . attributes [ 1 ] . type , 'SN' )
780
+ gotEntry ++
781
+ } )
782
+ res . on ( 'error' , function ( err ) {
783
+ t . fail ( err )
784
+ } )
785
+ res . on ( 'end' , function ( res ) {
786
+ t . ok ( res )
787
+ t . ok ( res instanceof SearchResultDone )
788
+ t . equal ( res . status , 0 )
789
+ t . equal ( gotEntry , 2 )
790
+ t . end ( )
791
+ } )
792
+ } )
793
+ } )
794
+
764
795
tap . test ( 'GH-602 search basic with delayed event listener binding' , function ( t ) {
765
796
t . context . client . search ( 'cn=test, ' + SUFFIX , '(objectclass=*)' , function ( err , res ) {
766
797
t . error ( err )
0 commit comments