perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pgollu...@apache.org
Subject svn commit: r420254 - /perl/modperl/trunk/t/protocol/pseudo_http.t
Date Sun, 09 Jul 2006 07:46:01 GMT
Author: pgollucci
Date: Sun Jul  9 00:46:00 2006
New Revision: 420254

URL: http://svn.apache.org/viewvc?rev=420254&view=rev
Log:
The problem here was that the .t file was never sending the initial
handshake ('HELO') to the server to start the conversation.

This also now works on 2.1+ and has been regression tested on 
the following combinations (FreeBSD 6-1-STABLE):

r420253-5.8.8-2.0.49-prefork....ok
r420253-5.8.8-2.0.50-prefork....ok
r420253-5.8.8-2.0.51-prefork....ok
r420253-5.8.8-2.0.52-prefork....ok
r420253-5.8.8-2.0.53-prefork....ok
r420253-5.8.8-2.0.54-prefork....ok
r420253-5.8.8-2.0.55-prefork....ok
r420253-5.8.8-2.0.58-prefork....ok
r420253-5.8.8-2.2.0-prefork.....ok
r420253-5.8.8-2.2.2-prefork.....ok


Modified:
    perl/modperl/trunk/t/protocol/pseudo_http.t

Modified: perl/modperl/trunk/t/protocol/pseudo_http.t
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/t/protocol/pseudo_http.t?rev=420254&r1=420253&r2=420254&view=diff
==============================================================================
--- perl/modperl/trunk/t/protocol/pseudo_http.t (original)
+++ perl/modperl/trunk/t/protocol/pseudo_http.t Sun Jul  9 00:46:00 2006
@@ -21,9 +21,6 @@
 # blocking socket bug fixed in 2.0.52
 my $ok = $^O !~ /^(Open|Net)BSD$/i || need_min_apache_version('2.0.52');
 
-# but not in 2.1?  hmph.
-$ok = skip_reason('skipping on httpd 2.1') if have_min_apache_version('2.1');
-
 plan tests => 13, need need_auth, need_access, $ok;
 
 {
@@ -32,39 +29,117 @@
     my $socket = Apache::TestRequest::vhost_socket($module);
     ok $socket;
 
-    expect_reply($socket, "HELO",      "HELO",    "greeting");
-    expect_reply($socket, "Login:",    $login,    "login");
-    expect_reply($socket, "Password:", $passgood, "good password");
-    expect($socket, "Welcome to TestProtocol::pseudo_http", "banner");
-    expect_reply($socket, "Available commands: date quit", "date", "date");
-    expect_reply($socket, qr/The time is:/,        "quit", "quit");
-    expect($socket, "Goodbye", "end of transmission");
+    ####################################################################
+    # ACTION     SEND     RECEIVE
+    #
+    # greeting   HELO
+    #                     HELO
+    #                     Login:
+    #
+    # login      $login
+    #                     Password
+    #
+    # good pass  $passgood
+    # banner              Welcome to TestProtocol::pseudo_http
+    #                     Available commands: date quit
+    # date       date
+    #                     The time is: Sat Jul  8 23:51:47 2006
+    #
+    # eot        quit
+    #                     Goodbye
+
+    {
+        my $response = "";
+        $response = Send($socket, 'HELO');
+        ok t_cmp($response, 'HELO', 'greeting 1');
+        $response = getline($socket);
+        ok t_cmp($response, 'Login:', 'greeeting 2')
+    }
+
+    {
+        my $response = Send($socket, $login);
+        ok t_cmp($response, 'Password:', 'login');
+    }
+
+    {
+        my $response = "";
+        $response = Send($socket, $passgood);
+        ok t_cmp($response, 'Welcome to TestProtocol::pseudo_http', 'good pass');
+        $response = getline($socket);
+        ok t_cmp($response, 'Available commands: date quit', 'banner');
+    }
+
+    {
+        my $response = Send($socket, 'date');
+        ok t_cmp($response, qr/The time is:/, 'date');
+    }
+
+    {
+        my $response = Send($socket, 'quit');
+        ok t_cmp($response, 'Goodbye', 'eot');
+    }
 }
 
 {
-    # this time sending wrong credentials and hoping that the server
-    # won't let us in
+    # supply correct credential when prompted for such and ask the
+    # server get the secret datetime information
     my $socket = Apache::TestRequest::vhost_socket($module);
     ok $socket;
 
-    expect_reply($socket, "HELO",      "HELO",   "greeting");
-    expect_reply($socket, "Login:",    $login,   "login");
-    t_client_log_error_is_expected();
-    expect_reply($socket, "Password:", $passbad, "wrong password");
-    expect($socket, "Access Denied", "end of transmission");
+    ####################################################################
+    # ACTION     SEND     RECEIVE
+    #
+    # greeting   HELO
+    #                     HELO
+    #                     Login:
+    #
+    # login      $login
+    #                     Password
+    #
+    # bad pass   $passbad
+    #                     Access Denied
+    #
+    # eot        quit
+    #                     Goodbye
+
+    {
+        my $response = "";
+        $response = Send($socket, 'HELO');
+        ok t_cmp($response, 'HELO', 'greeting 1');
+        $response = getline($socket);
+        ok t_cmp($response, 'Login:', 'greeeting 2')
+    }
+
+    {
+        my $response = Send($socket, $login);
+        ok t_cmp($response, 'Password:', 'login');
+    }
+
+    {
+        my $response = "";
+        $response = Send($socket, $passbad);
+        ok t_cmp($response, 'Access Denied', 'eot');
+    }
 }
 
-sub expect {
-    my ($socket, $expect, $action) = @_;
+## send() is reserved
+sub Send {
+    my ($socket, $str) = @_;
+
+    t_debug("send: $str");
+    print $socket $str;
+
     chomp(my $recv = <$socket> || '');
-    ok t_cmp($recv, $expect, $action);
+    t_debug("recv: $recv");
+
+    return $recv;
 }
 
-sub expect_reply {
-    my ($socket, $expect, $reply, $action) = @_;
+sub getline {
+    my ($socket) = @_;
+
     chomp(my $recv = <$socket> || '');
-    ok t_cmp($recv, $expect, $action);
-    t_debug("send: $reply");
-    print $socket $reply;
-}
+    t_debug("getline: $recv");
 
+    return $recv;
+}



Mime
View raw message