You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2017/07/10 12:08:45 UTC

svn commit: r1801452 - in /httpd/test/framework/trunk/t: conf/extra.conf.in htdocs/modules/remoteip/ htdocs/modules/remoteip/index.html modules/remoteip.t

Author: jim
Date: Mon Jul 10 12:08:45 2017
New Revision: 1801452

URL: http://svn.apache.org/viewvc?rev=1801452&view=rev
Log:
Add support for initial PROXY protocol support testing

Added:
    httpd/test/framework/trunk/t/htdocs/modules/remoteip/
    httpd/test/framework/trunk/t/htdocs/modules/remoteip/index.html
    httpd/test/framework/trunk/t/modules/remoteip.t
Modified:
    httpd/test/framework/trunk/t/conf/extra.conf.in

Modified: httpd/test/framework/trunk/t/conf/extra.conf.in
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/conf/extra.conf.in?rev=1801452&r1=1801451&r2=1801452&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/conf/extra.conf.in (original)
+++ httpd/test/framework/trunk/t/conf/extra.conf.in Mon Jul 10 12:08:45 2017
@@ -1186,3 +1186,13 @@ LimitRequestFields    32
   # If mod_ssl_ct is loaded, CTSCTStorage is needed to pass the configtest.
   CTSCTStorage .
 </IfModule>
+
+##
+## mod_remote_ip configuration
+##
+<IfModule mod_remoteip.c>
+   <VirtualHost remote_ip>
+      DocumentRoot @SERVERROOT@/htdocs/modules/remoteip
+      RemoteIPProxyProtocol On
+   </VirtualHost>
+</IfModule>

Added: httpd/test/framework/trunk/t/htdocs/modules/remoteip/index.html
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/htdocs/modules/remoteip/index.html?rev=1801452&view=auto
==============================================================================
--- httpd/test/framework/trunk/t/htdocs/modules/remoteip/index.html (added)
+++ httpd/test/framework/trunk/t/htdocs/modules/remoteip/index.html Mon Jul 10 12:08:45 2017
@@ -0,0 +1 @@
+PROXY-OK

Added: httpd/test/framework/trunk/t/modules/remoteip.t
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/modules/remoteip.t?rev=1801452&view=auto
==============================================================================
--- httpd/test/framework/trunk/t/modules/remoteip.t (added)
+++ httpd/test/framework/trunk/t/modules/remoteip.t Mon Jul 10 12:08:45 2017
@@ -0,0 +1,59 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest;
+use Apache::TestUtil;
+
+## 
+## mod_remoteip tests
+##
+Apache::TestRequest::module("remote_ip");
+plan tests => 6, need_module 'remoteip', have_min_apache_version('2.4.28');
+
+sub slurp
+{
+    my $s = shift;
+    my $r = "";
+    my $b;
+    while ($s->read($b, 10000) > 0) {
+        $r .= $b;
+    }
+    return $r;
+}
+
+my $sock = Apache::TestRequest::vhost_socket("remote_ip");
+ok $sock;
+
+# Test human readable format
+my $req = "PROXY TCP4 192.168.192.66 192.168.192.77 1111 2222\r\n";
+my $url = "GET /index.html HTTP/1.1\r\nConnection: close\r\n";
+$url .= "Host: dummy\r\n\r\n";
+
+$sock->print($req . $url);
+$sock->shutdown(1);
+
+my $response_data = slurp($sock);
+my $r = HTTP::Response->parse($response_data);
+chomp(my $content = $r->content);
+ok t_cmp($r->code, 200, "PROXY protocol human readable check");
+ok t_cmp($content, "PROXY-OK", "Context check");
+$sock->shutdown(2);
+
+$req = "PROXY FOO 192.168.192.66 192.168.192.77 1111 2222\r\n";
+$sock = Apache::TestRequest::vhost_socket("remote_ip");
+ok $sock;
+$sock->print($req . $url);
+$sock->shutdown(1);
+
+$response_data = slurp($sock);
+#print "--\n";
+#print "$response_data\n";
+#print "--\n";
+$r = HTTP::Response->parse($response_data);
+chomp($content = $r->content);
+ok t_cmp($r->code, undef, "broken PROXY protocol human readable check");
+ok t_cmp($content, "", "Context check");
+$sock->shutdown(2);
+
+# TODO: test binary format
\ No newline at end of file