httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoffrey Young <ge...@modperlcookbook.org>
Subject Re: [PATCH] vhost_socket tweak
Date Wed, 18 Feb 2004 14:05:47 GMT

>  sub vhost_socket {
> -    my $module = shift;
> +    my ($module, $nossl) = @_;
>      local $Apache::TestRequest::Module = $module if $module;
>  
>      my $hostport = hostport(Apache::Test::config());
> @@ -224,7 +224,7 @@
>      my($host, $port) = split ':', $hostport;
>      my(%args) = (PeerAddr => $host, PeerPort => $port);
>  
> -    if ($module and $module =~ /ssl/) {
> +    if (!$nossl and $module and $module =~ /ssl/) {
>          require Net::SSL;
>          local $ENV{https_proxy} ||= ""; #else uninitialized value in Net/SSL.pm
>          return Net::SSL->new(%args, Timeout => UA_TIMEOUT);

that all looks reasonable.

> This allows a fix for the ssl/http.t failure which has been around
> forever:

well, since I have never tried the SSL tests you're probably in a better
position to judge the validity of the tests than I am.  but a few comments
anyway :)

> -my $res = GET($rurl);
> -ok t_cmp(400,
> -         $res->code,
> -         "Expected bad request from 'GET $rurl'"
> -        );

that the appropriate status code is returned seems like a valid test that we
would want to keep around.  maybe keep this but issue another request to
test your below logic?

> -
> -ok t_cmp(qr{speaking plain HTTP to an SSL-enabled server port},
> -         $res->content,
> -         "that error document contains the proper hint"
> -        );

I gather that this is the source of the failure that you mention - that for
some reason $res->content isn't sufficient?  just out of curiosity, could
you explain the issue?  to me, the process looks equivalent, except that the
prior approach was standard.

oh, and you're invoking mod_dir to get to index.html, instead of asking for
it directly, so you'll probably need protection against users that don't
have mod_dir installed.  IIRC someone did report that once.

> +my $s = Apache::TestRequest::vhost_socket($ssl_module, 1);
> +
> +unless ($s) {
> +    warn "cannot connect to $hostport: $!";
> +    return undef;
> +}

you probably want to fail here instead of just returning undef.  something
like this might be better

  t_debug("could connect to $hostport? ", $! ? $! : 'yes');
  ok($s);

> +while (<$s>) {
> +    print "# read: $_";

I'd use t_debug here as well :)

> +    $res = 1 if /speaking plain HTTP to an SSL-enabled server port/;
> +}
> +
> +ok t_cmp(1,
> +         $res,
> +         "expected error document hint from HTTP request on SSL port"
> +         );
>  

there's no reason you need to use t_cmp to compare 1 to 1.  if you wanted,
you could do something like

  $res = $1 if /(speaking plain HTTP to an SSL-enabled server port)/;

then use that in the t_cmp, or just drop the t_cmp altogether and just use

  ok($res);

since the complete response is already present in debug mode.

anyway, just a few suggestions for what they are worth.  kudos for keeping
up with the test suite :)

--Geoff


Mime
View raw message