@@ -571,3 +571,118 @@ GET /t
571
571
-- - no_error_log
572
572
[error]
573
573
-- - error_code: 200
574
+
575
+
576
+
577
+ === TEST 17 : add new Chinese attribute to user01
578
+ -- - http_config eval: $::HttpConfig
579
+ -- - config
580
+ location / t {
581
+ content_by_lua_block {
582
+ local ldap_client = require (" resty.ldap.client" )
583
+ local ldap_protocol = require (" resty.ldap.protocol" )
584
+
585
+ local client = ldap_client: new(" 127.0.0.1" , 1389 )
586
+
587
+ -- auth
588
+ local res, err = client: simple_bind(" cn=admin,dc=example,dc=org" , " adminpassword" )
589
+ if not res then
590
+ ngx. log (ngx. ERR, err)
591
+ ngx. exit(401 )
592
+ end
593
+
594
+ assert(res, " failed to bind admin" )
595
+
596
+ -- modify
597
+ local res, err = client: unknown(
598
+ " 304b02012266460424636e3d7573657230312c6f753d75736572732c64633d6578616d706c652c64633d6f7267301e301c0a01003017040b646973706c61794e616d6531080406e4b8ade69687" , -- hex
599
+ false
600
+ )
601
+ if not res then
602
+ ngx. log (ngx. ERR, err)
603
+ ngx. exit(401 )
604
+ end
605
+
606
+ assert(res. protocol_op == 7 , " protocol_op is not equal to 7, " .. res. protocol_op)
607
+ assert(res. result_code == 0 , " result_code is not equal to 0, " .. res. result_code)
608
+ }
609
+ }
610
+ -- - request
611
+ GET / t
612
+ -- - no_error_log
613
+ [error]
614
+ -- - error_code: 200
615
+
616
+
617
+
618
+ === TEST 18 : search filter (attribute value in Chinese)
619
+ -- - http_config eval: $::HttpConfig
620
+ -- - config
621
+ location / t {
622
+ content_by_lua_block {
623
+ local ldap_client = require (" resty.ldap.client" )
624
+ local ldap_protocol = require (" resty.ldap.protocol" )
625
+
626
+ local client = ldap_client: new(" 127.0.0.1" , 1389 )
627
+ local res, err = client: search(
628
+ " dc=example,dc=org" ,
629
+ ldap_protocol. SEARCH_SCOPE_WHOLE_SUBTREE, nil, nil, nil, nil,
630
+ " (displayName=中文)" , {" gidNumber" }
631
+ )
632
+
633
+ if not res then
634
+ ngx. log (ngx. ERR, err)
635
+ ngx. exit(401 )
636
+ end
637
+
638
+ assert(# res == 1, "result length is not equal to 1")
639
+ assert(res[1 ]. entryDN == " cn=user01,ou=users,dc=example,dc=org" , " result entryDN is not equal to cn=user01,ou=users,dc=example,dc=org" )
640
+ assert(res[1 ]. attributes . gidNumber == " 1000" , " result gidNumber attribute is not equal to 1000" )
641
+ }
642
+ }
643
+ -- - request
644
+ GET / t
645
+ -- - no_error_log
646
+ [error]
647
+ -- - error_code: 200
648
+
649
+
650
+
651
+ === TEST 19 : remove Chinese attribute in user01
652
+ -- - http_config eval: $::HttpConfig
653
+ -- - config
654
+ location / t {
655
+ content_by_lua_block {
656
+ local ldap_client = require (" resty.ldap.client" )
657
+ local ldap_protocol = require (" resty.ldap.protocol" )
658
+
659
+ local client = ldap_client: new(" 127.0.0.1" , 1389 )
660
+
661
+ -- auth
662
+ local res, err = client: simple_bind(" cn=admin,dc=example,dc=org" , " adminpassword" )
663
+ if not res then
664
+ ngx. log (ngx. ERR, err)
665
+ ngx. exit(401 )
666
+ end
667
+
668
+ assert(res, " failed to bind admin" )
669
+
670
+ -- modify
671
+ local res, err = client: unknown(
672
+ " 304b02014066460424636e3d7573657230312c6f753d75736572732c64633d6578616d706c652c64633d6f7267301e301c0a01013017040b646973706c61794e616d6531080406e4b8ade69687" , -- hex
673
+ false
674
+ )
675
+ if not res then
676
+ ngx. log (ngx. ERR, err)
677
+ ngx. exit(401 )
678
+ end
679
+
680
+ assert(res. protocol_op == 7 , " protocol_op is not equal to 7, " .. res. protocol_op)
681
+ assert(res. result_code == 0 , " result_code is not equal to 0, " .. res. result_code)
682
+ }
683
+ }
684
+ -- - request
685
+ GET / t
686
+ -- - no_error_log
687
+ [error]
688
+ -- - error_code: 200
0 commit comments