You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ic...@apache.org on 2015/10/19 16:28:03 UTC
svn commit: r1709420 - in /httpd/test/framework/trunk/t: conf/extra.conf.in
conf/http2.conf.in modules/http2.t
Author: icing
Date: Mon Oct 19 14:28:02 2015
New Revision: 1709420
URL: http://svn.apache.org/viewvc?rev=1709420&view=rev
Log:
moved http2 test setups into own vhosts, serialized http2 test execution for easier debugging
Added:
httpd/test/framework/trunk/t/conf/http2.conf.in
Modified:
httpd/test/framework/trunk/t/conf/extra.conf.in
httpd/test/framework/trunk/t/modules/http2.t
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=1709420&r1=1709419&r2=1709420&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/conf/extra.conf.in (original)
+++ httpd/test/framework/trunk/t/conf/extra.conf.in Mon Oct 19 14:28:02 2015
@@ -974,36 +974,3 @@ LimitRequestFields 32
</IfDefine>
-##
-## mod_http2 test config
-##
-
-<IfDefine APACHE2>
- <IfModule http2_module>
- Protocols h2 h2c http/1.1
- LogLevel http2:debug
- H2Direct on
- <IfVersion > 2.4.17>
- # new config directives
- H2ModernTLSOnly off
- </IfVersion>
- </IfModule>
-
- <IfModule @CGI_MODULE@>
- <Directory @SERVERROOT@/htdocs/modules/h2>
- Options +ExecCGI
- AddHandler cgi-script .pl
-
- </Directory>
- </IfModule>
- <Location /modules/h2/hello.pl>
- <IfModule @ssl_module@>
- SSLOptions +StdEnvVars
- </ifModule>
- </Location>
- <IfModule mod_rewrite.c>
- RewriteEngine on
- RewriteRule ^/modules/h2/latest.tar.gz$ /modules/h2/xxx-1.0.2a.tar.gz [R=302,NC]
- </IfModule>
-</IfDefine>
-
Added: httpd/test/framework/trunk/t/conf/http2.conf.in
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/conf/http2.conf.in?rev=1709420&view=auto
==============================================================================
--- httpd/test/framework/trunk/t/conf/http2.conf.in (added)
+++ httpd/test/framework/trunk/t/conf/http2.conf.in Mon Oct 19 14:28:02 2015
@@ -0,0 +1,89 @@
+##
+## mod_http2 test config
+##
+
+<IfDefine APACHE2>
+ <IfModule http2_module>
+
+ LogLevel http2:debug
+ H2Direct on
+
+ <VirtualHost h2c>
+ Protocols h2c http/1.1
+
+ <IfModule @CGI_MODULE@>
+ <Directory @SERVERROOT@/htdocs/modules/h2>
+ Options +ExecCGI
+ AddHandler cgi-script .pl
+
+ </Directory>
+ </IfModule>
+
+ <Location /modules/h2/hello.pl>
+ </Location>
+ <IfModule mod_rewrite.c>
+ RewriteEngine on
+ RewriteRule ^/modules/h2/latest.tar.gz$ /modules/h2/xxx-1.0.2a.tar.gz [R=302,NC]
+ </IfModule>
+
+ </VirtualHost>
+
+ <IfModule @ssl_module@>
+
+ <VirtualHost noh2.example.org:h2>
+ Protocols http/1.1
+ H2Direct off
+ </VirtualHost>
+
+ <VirtualHost test.example.org:h2>
+ </VirtualHost>
+
+ <VirtualHost test2.example.org:h2>
+ </VirtualHost>
+
+ <VirtualHost test-ser.example.org:h2>
+ </VirtualHost>
+
+ <VirtualHost _default_:h2>
+ Protocols h2 http/1.1
+
+ SSLEngine on
+ SSLCACertificateFile @SSLCA@/asf/certs/ca.crt
+ SSLCACertificatePath @ServerRoot@/conf/ssl
+ SSLCARevocationFile @SSLCA@/asf/crl/ca-bundle.crl
+ SSLCARevocationCheck chain
+
+ # taken from https://wiki.mozilla.org/Security/Server_Side_TLS#Recommended_configurations
+ #
+ SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
+ SSLProtocol All -SSLv2 -SSLv3
+ SSLOptions +StdEnvVars
+
+ <IfVersion > 2.4.17>
+ # new config directive
+ # need this off as long as we ran on platform openssl
+ H2ModernTLSOnly off
+ </IfVersion>
+
+ <IfModule @CGI_MODULE@>
+ <Directory @SERVERROOT@/htdocs/modules/h2>
+ Options +ExecCGI
+ AddHandler cgi-script .pl
+ </Directory>
+ </IfModule>
+
+ <Location /modules/h2/hello.pl>
+ </Location>
+ <IfModule mod_rewrite.c>
+ RewriteEngine on
+ RewriteRule ^/modules/h2/latest.tar.gz$ /modules/h2/xxx-1.0.2a.tar.gz [R=302,NC]
+ </IfModule>
+
+ </VirtualHost>
+
+ </ifModule>
+
+ </IfModule>
+
+</IfDefine>
+
Modified: httpd/test/framework/trunk/t/modules/http2.t
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/modules/http2.t?rev=1709420&r1=1709419&r2=1709420&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/modules/http2.t (original)
+++ httpd/test/framework/trunk/t/modules/http2.t Mon Oct 19 14:28:02 2015
@@ -6,20 +6,26 @@ use Apache::TestRequest;
use Apache::TestUtil;
use Apache::TestConfig ();
-my $num_suite = 26;
+my $num_suite = 24;
+my $vhost_suite = 3;
+
my $total_tests = 2 * $num_suite;
+my $alpn_available = exists &Net::SSLeay::CTX_set_alpn_protos;
+if ($alpn_available) {
+ $total_tests += $vhost_suite;
+}
+
plan tests => $total_tests, need_module 'http2', need_module 'Protocol::HTTP2::Client', need_min_apache_version('2.4.17');
Apache::TestRequest::module("http2");
my $config = Apache::Test::config();
-my $host = $config->{vars}->{servername};
-my $port = $config->{vars}->{port};
+my $host = $config->{vhosts}->{h2c}->{servername};
+my $port = $config->{vhosts}->{h2c}->{port};
-my $ssl_module = $config->{vars}->{ssl_module_name};
-my $shost = $config->{vhosts}->{$ssl_module}->{servername};
-my $sport = $config->{vhosts}->{$ssl_module}->{port};
+my $shost = $config->{vhosts}->{h2}->{servername};
+my $sport = $config->{vhosts}->{h2}->{port};
my $serverdir = $config->{vars}->{t_dir};
my $htdocs = $serverdir . "/htdocs";
@@ -32,8 +38,6 @@ use AnyEvent::TLS;
Net::SSLeay::initialize();
-my $alpn_available = exists &Net::SSLeay::CTX_set_alpn_protos;
-
sub connect_and_do {
my %args = (
@_
@@ -112,6 +116,11 @@ sub connect_and_do {
}
+################################################################################
+#
+# Add a request to the client, will be started whenever a STREAM to
+# the server is available.
+#
sub add_request {
my ($scheme, $client, $host, $port);
my %args = (
@@ -152,6 +161,65 @@ sub add_request {
);
}
+################################################################################
+#
+# Add a list of request that will be processed in order. Only when the previous
+# request is done, will a new one be started.
+#
+sub add_sequential {
+ my ($scheme, $client, $host, $port);
+ my %args = ( @_ );
+ my $ctx = $args{ctx};
+ my $requests = $args{requests};
+
+ $client = $args{ctx}->{client};
+ $scheme = $args{ctx}->{scheme};
+ $host = $args{ctx}->{host};
+ $port = $args{ctx}->{port};
+
+ my $request = shift @$requests;
+
+ if ($request) {
+ my %r = (
+ method => 'GET',
+ headers => [],
+ rc => 200,
+ on_done => sub {
+ my %args = ( @_ );
+ my $ctx = $args{ctx};
+ my $req = $args{request};
+ my $resp = $args{response};
+ my $hr = $resp->{headers};
+ my %headers = @$hr;
+ ok t_cmp($headers{':status'}, $req->{rc},
+ "$req->{method} $ctx->{scheme}://$ctx->{host}:$ctx->{port}$req->{path}");
+ },
+ %$request
+ );
+
+ print "test case: $r{descr}: $r{method} $ctx->{scheme}://$ctx->{host}:$ctx->{port}$r{path}\n";
+ $client->request(
+ ':scheme' => $scheme,
+ ':authority' => $r{authority} || $host . ':' . $port,
+ ':path' => $r{path},
+ ':method' => $r{method},
+ headers => $r{headers},
+ on_done => sub {
+ my ($headers, $data) = @_;
+ $r{on_done}(
+ ctx => ${ctx},
+ request => \%r,
+ response => { headers => \@$headers, data => $data }
+ );
+ add_sequential(
+ ctx => $ctx,
+ requests => $requests
+ );
+ }
+ );
+ }
+}
+
sub cmp_content_length {
my %args = ( @_ );
my $ctx = $args{ctx};
@@ -159,9 +227,8 @@ sub cmp_content_length {
my $resp = $args{response};
my $hr = $resp->{headers};
my %headers = @$hr;
- ok t_cmp($headers{':status'}, $req->{rc},
- "$req->{method} $ctx->{scheme}://$ctx->{host}:$ctx->{port}$req->{path}");
- ok t_cmp(length $resp->{data}, $req->{content_length}, "content-length of $req->{path}");
+ ok t_cmp($headers{':status'}, $req->{rc}, "response status");
+ ok t_cmp(length $resp->{data}, $req->{content_length}, "content-length");
}
sub cmp_content {
@@ -171,9 +238,8 @@ sub cmp_content {
my $resp = $args{response};
my $hr = $resp->{headers};
my %headers = @$hr;
- ok t_cmp($headers{':status'}, $req->{rc},
- "$req->{method} $ctx->{scheme}://$ctx->{host}:$ctx->{port}$req->{path}");
- ok t_cmp($resp->{data}, $req->{content}, "content of $req->{path}");
+ ok t_cmp($headers{':status'}, $req->{rc}, "response status");
+ ok t_cmp($resp->{data}, $req->{content}, "content comparision");
}
sub cmp_file_response {
@@ -183,8 +249,7 @@ sub cmp_file_response {
my $resp = $args{response};
my $hr = $resp->{headers};
my %headers = @$hr;
- ok t_cmp($headers{':status'}, $req->{rc},
- "$req->{method} $ctx->{scheme}://$ctx->{host}:$ctx->{port}$req->{path}");
+ ok t_cmp($headers{':status'}, $req->{rc}, "response status");
open(FILE, "<$htdocs$req->{path}") or die "cannot open $req->{path}";
undef $/;
my $content = <FILE>;
@@ -199,16 +264,19 @@ sub check_redir {
my $resp = $args{response};
my $hr = $resp->{headers};
my %headers = @$hr;
- ok t_cmp($headers{':status'}, 302,
- "$req->{method} $ctx->{scheme}://$ctx->{host}:$ctx->{port}$req->{path}");
+ ok t_cmp($headers{':status'}, 302, "response status");
ok t_cmp(
- $headers{location},
+ $headers{location},
"$ctx->{scheme}://$ctx->{host}:$ctx->{port}$req->{redir_path}",
- "location header check"
+ "location header"
);
}
-sub do_suite {
+################################################################################
+#
+# Perform common tests to h2c + h2 hosts
+#
+sub do_common {
my %args = (
scheme => 'http',
host => 'localhost',
@@ -219,50 +287,40 @@ sub do_suite {
$args{client} = Protocol::HTTP2::Client->new( upgrade => 0 );
- print "connect to $args{scheme}:$args{host}:$args{port}\n";
-
- add_request(
- ctx => \%args,
- path => '/'
- );
- add_request(
- ctx => \%args,
- rc => 404,
- path => '/not_here'
- );
- add_request(
- ctx => \%args,
- rc => $true_tls? 421 : 404,
- path => '/misdirected',
- header => [ 'host' => 'xxx.yyy.zzz' ]
- );
- add_request(
- ctx => \%args,
- rc => $true_tls? 421 : 404,
- path => '/misdirected',
- authority => 'xxx.yyy.zzz:1234'
- );
- add_request(
- ctx => \%args,
- path => '/modules/h2/index.html',
- on_done => \&cmp_file_response
- );
- add_request(
- ctx => \%args,
- path => '/modules/h2/003/003_img.jpg',
- on_done => \&cmp_file_response
- );
+ my $r = [
+ {
+ descr => 'TC0001, expecting 200',
+ path => '/'
+ },
+ {
+ descr => 'TC0002, expecting 404',
+ rc => 404,
+ path => '/not_here'
+ },
+ {
+ descr => 'TC0005, cmp index.html file',
+ path => '/modules/h2/index.html',
+ on_done => \&cmp_file_response
+ },
+ {
+ descr => 'TC0006, cmp image file',
+ path => '/modules/h2/003/003_img.jpg',
+ on_done => \&cmp_file_response
+ },
+ ];
+
if (have_module 'mod_rewrite') {
- add_request(
- ctx => \%args,
- path => '/modules/h2/latest.tar.gz',
- redir_path => "/modules/h2/xxx-1.0.2a.tar.gz",
- on_done => \&check_redir
- );
+ push $r, {
+ descr => 'TC0007, rewrite handling',
+ path => '/modules/h2/latest.tar.gz',
+ redir_path => "/modules/h2/xxx-1.0.2a.tar.gz",
+ on_done => \&check_redir
+ }
}
else {
skip "skipping test as mod_rewrite not available" foreach(1..2);
}
+
if (have_cgi) {
my $sni_host = $true_tls? 'localhost' : '';
my $content = <<EOF;
@@ -271,76 +329,120 @@ sub do_suite {
TLS_SNI="$sni_host"
</body></html>
EOF
- add_request(
- ctx => \%args,
+
+ push $r, {
+ descr => 'TC0008, hello.pl with ssl vars',
path => '/modules/h2/hello.pl',
content => $content,
on_done => \&cmp_content,
- );
+ };
$content = <<EOF;
<html><body>
<p>No query was specified.</p>
</body></html>
EOF
- add_request(
- ctx => \%args,
+ push $r, {
+ descr => 'TC0009, necho.pl without arguments',
path => '/modules/h2/necho.pl',
content => $content,
rc => 400,
on_done => \&cmp_content,
- );
- add_request(
- ctx => \%args,
+ };
+ push $r, {
+ descr => 'TC0010, necho.pl 2x10',
path => '/modules/h2/necho.pl?count=2&text=0123456789',
content => "01234567890123456789",
on_done => \&cmp_content,
- );
- add_request(
- ctx => \%args,
+ };
+ push $r, {
+ descr => 'TC0011, necho.pl 10x10',
path => '/modules/h2/necho.pl?count=10&text=0123456789',
content_length => 100,
on_done => \&cmp_content_length,
- );
- add_request(
- ctx => \%args,
+ };
+ push $r, {
+ descr => 'TC0012, necho.pl 100x10',
path => '/modules/h2/necho.pl?count=100&text=0123456789',
content_length => 1000,
on_done => \&cmp_content_length,
- );
- add_request(
- ctx => \%args,
+ };
+ push $r, {
+ descr => 'TC0013, necho.pl 1000x10',
path => '/modules/h2/necho.pl?count=1000&text=0123456789',
content_length => 10000,
on_done => \&cmp_content_length,
- );
- add_request(
- ctx => \%args,
+ };
+ push $r, {
+ descr => 'TC0014, necho.pl 10000x10',
path => '/modules/h2/necho.pl?count=10000&text=0123456789',
content_length => 100000,
on_done => \&cmp_content_length,
- );
- add_request(
- ctx => \%args,
+ };
+ push $r, {
+ descr => 'TC0015, necho.pl 100000x10',
path => '/modules/h2/necho.pl?count=100000&text=0123456789',
content_length => 1000000,
on_done => \&cmp_content_length,
- );
+ };
}
else {
skip "skipping test as mod_cgi not available" foreach(1..1);
}
+ add_sequential(
+ ctx => \%args,
+ requests => $r
+ );
connect_and_do( ctx => \%args );
}
-do_suite( 'scheme' => 'http', 'host' => $host, 'port' => $port );
-
-
-if ($alpn_available||1) {
- do_suite( 'scheme' => 'https', 'host' => $shost, 'port' => $sport );
+################################################################################
+#
+# Perform tests for virtual host setups, requires a client with SNI+ALPN
+#
+sub do_vhosts {
+ my %args = (
+ scheme => 'http',
+ host => 'localhost',
+ port => 80,
+ @_
+ );
+ $args{client} = Protocol::HTTP2::Client->new( upgrade => 0 );
+
+ my $r = [
+ {
+ descr => 'VHOST000, expecting 200',
+ path => '/'
+ },
+ {
+ descr => 'VHOST001, expect 404 or 421 (using Host:)',
+ rc => 421,
+ path => '/misdirected',
+ header => [ 'host' => 'test.example.org' ]
+ },
+ {
+ descr => 'VHOST002, expect 404 or 421 (using :authority)',
+ rc => 421,
+ path => '/misdirected',
+ authority => 'test.example.org:1234'
+ },
+ ];
+
+ add_sequential(
+ ctx => \%args,
+ requests => $r
+ );
+ connect_and_do( ctx => \%args );
}
-else {
- skip "skipping https tests as ALPN is not available" foreach(1..$num_suite);
+
+################################################################################
+#
+# Bring it on
+#
+do_common( 'scheme' => 'http', 'host' => $host, 'port' => $port );
+do_common( 'scheme' => 'https', 'host' => $shost, 'port' => $sport );
+if ($alpn_available) {
+ do_vhosts( 'scheme' => 'https', 'host' => $shost, 'port' => $sport );
}