@@ -5,10 +5,10 @@ use Cwd qw(cwd);
5
5
6
6
repeat_each(2 );
7
7
8
- plan tests => repeat_each() * (blocks() * 4 + 5 );
8
+ plan tests => repeat_each() * (blocks() * 4 + 4 );
9
9
our $ HtmlDir = html_dir;
10
10
11
- my $ pwd = cwd();
11
+ our $ pwd = cwd();
12
12
13
13
our $ HttpConfig = qq {
14
14
lua_package_path "$ pwd /lib/?.lua;;";
@@ -699,3 +699,183 @@ GET /t
699
699
foo
700
700
wrote bytes : 3
701
701
wrote bytes : 3
702
+
703
+
704
+
705
+ === TEST 17 : SSL logging
706
+ -- - http_config eval
707
+ "
708
+ lua_package_path '$::pwd/lib/?.lua;;';
709
+ server {
710
+ listen unix: $::HtmlDir/ ssl. sock ssl;
711
+ server_name test. com;
712
+ ssl_certificate $::pwd/ t/ cert/ test. crt;
713
+ ssl_certificate_key $::pwd/ t/ cert/ test. key ;
714
+
715
+ location / test {
716
+ lua_need_request_body on;
717
+ default_type ' text/plain' ;
718
+ # 204 No content
719
+ content_by_lua '
720
+ ngx.log(ngx.WARN, \"Message received: \", ngx.var.http_message)
721
+ ngx.log(ngx.WARN, \"SNI Host: \", ngx.var.ssl_server_name)
722
+ ngx.exit(204)
723
+ ' ;
724
+ }
725
+ }
726
+ "
727
+ -- - config
728
+ location / t {
729
+ content_by_lua '
730
+ ngx.say("foo")
731
+ local logger = require "resty.logger.socket"
732
+ if not logger.initted() then
733
+ local ok, err = logger.init{
734
+ path = "$TEST_NGINX_HTML_DIR/ssl.sock",
735
+ flush_limit = 1,
736
+ drop_limit = 10000,
737
+ retry_interval = 1,
738
+ timeout = 50,
739
+ ssl = true,
740
+ ssl_verify = false,
741
+ sni_host = "test.com",
742
+ }
743
+ end
744
+
745
+ local bytes, err
746
+ bytes, err = logger.log("GET /test HTTP/1.0\\ r\\ nHost: test.com\\ r\\ nConnection: close\\ r\\ nMessage: Hello SSL\\ r\\ n\\ r\\ n")
747
+ if err then
748
+ ngx.log(ngx.ERR, err)
749
+ end
750
+ ngx.say("wrote bytes: ", bytes)
751
+
752
+ ngx.sleep(0.05)
753
+ ' ;
754
+ }
755
+ -- - request
756
+ GET / t
757
+ -- - wait : 0.1
758
+ -- - response_body
759
+ foo
760
+ wrote bytes : 77
761
+ -- - error_log
762
+ Message received: Hello SSL
763
+ SNI Host: test. com
764
+
765
+
766
+
767
+ === TEST 18 : SSL logging - Verify
768
+ -- - http_config eval
769
+ "
770
+ lua_package_path '$::pwd/lib/?.lua;;';
771
+ server {
772
+ listen unix: $::HtmlDir/ ssl. sock ssl;
773
+ server_name test. com;
774
+ ssl_certificate $::pwd/ t/ cert/ test. crt;
775
+ ssl_certificate_key $::pwd/ t/ cert/ test. key ;
776
+
777
+ location / test {
778
+ lua_need_request_body on;
779
+ default_type ' text/plain' ;
780
+ # 204 No content
781
+ content_by_lua ' ngx.log(ngx.WARN, \"Message received: \", ngx.var.http_message) ngx.exit(204)' ;
782
+ }
783
+ }
784
+ "
785
+ -- - config
786
+ location / t {
787
+ content_by_lua '
788
+ ngx.say("foo")
789
+ local logger = require "resty.logger.socket"
790
+ if not logger.initted() then
791
+ local ok, err = logger.init{
792
+ path = "$TEST_NGINX_HTML_DIR/ssl.sock",
793
+ flush_limit = 1,
794
+ drop_limit = 10000,
795
+ retry_interval = 1,
796
+ timeout = 50,
797
+ ssl = true,
798
+ ssl_verify = true,
799
+ sni_host = "test.com",
800
+ }
801
+ end
802
+
803
+ local bytes, err
804
+ bytes, err = logger.log("GET /test HTTP/1.0\\ r\\ nHost: test.com\\ r\\ nConnection: close\\ r\\ nMessage: Hello SSL\\ r\\ n\\ r\\ n")
805
+ if err then
806
+ ngx.log(ngx.ERR, err)
807
+ end
808
+ ngx.say("wrote bytes: ", bytes)
809
+
810
+ ngx.sleep(0.05)
811
+ ' ;
812
+ }
813
+ -- - request
814
+ GET / t
815
+ -- - wait : 0.1
816
+ -- - response_body
817
+ foo
818
+ wrote bytes : 77
819
+ -- - error_log
820
+ lua ssl certificate verify error
821
+
822
+
823
+
824
+ === TEST 19 : SSL logging - No SNI
825
+ -- - http_config eval
826
+ "
827
+ lua_package_path '$::pwd/lib/?.lua;;';
828
+ server {
829
+ listen unix: $::HtmlDir/ ssl. sock ssl;
830
+ server_name test. com;
831
+ ssl_certificate $::pwd/ t/ cert/ test. crt;
832
+ ssl_certificate_key $::pwd/ t/ cert/ test. key ;
833
+
834
+ location / test {
835
+ lua_need_request_body on;
836
+ default_type ' text/plain' ;
837
+ # 204 No content
838
+ content_by_lua '
839
+ ngx.log(ngx.WARN, \"Message received: \", ngx.var.http_message)
840
+ ngx.log(ngx.WARN, \"SNI Host: \", ngx.var.ssl_server_name)
841
+ ngx.exit(204)
842
+ ' ;
843
+ }
844
+ }
845
+ "
846
+ -- - config
847
+ location / t {
848
+ content_by_lua '
849
+ ngx.say("foo")
850
+ local logger = require "resty.logger.socket"
851
+ if not logger.initted() then
852
+ local ok, err = logger.init{
853
+ path = "$TEST_NGINX_HTML_DIR/ssl.sock",
854
+ flush_limit = 1,
855
+ drop_limit = 10000,
856
+ retry_interval = 1,
857
+ timeout = 50,
858
+ ssl = true,
859
+ ssl_verify = false,
860
+ }
861
+ end
862
+
863
+ local bytes, err
864
+ bytes, err = logger.log("GET /test HTTP/1.0\\ r\\ nHost: test.com\\ r\\ nConnection: close\\ r\\ nMessage: Hello SSL\\ r\\ n\\ r\\ n")
865
+ if err then
866
+ ngx.log(ngx.ERR, err)
867
+ end
868
+ ngx.say("wrote bytes: ", bytes)
869
+
870
+ ngx.sleep(0.05)
871
+ ' ;
872
+ }
873
+ -- - request
874
+ GET / t
875
+ -- - wait : 0.1
876
+ -- - response_body
877
+ foo
878
+ wrote bytes : 77
879
+ -- - error_log
880
+ Message received: Hello SSL
881
+ SNI Host: nil
0 commit comments