[Catalyst-commits] r10218 - in Catalyst-Runtime/5.80/trunk: . lib lib/Catalyst lib/Catalyst/Engine t/aggregate t/lib/DeprecatedTestApp/C

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Thu May 21 13:44:58 GMT 2009


Author: t0m
Date: 2009-05-21 13:44:58 +0000 (Thu, 21 May 2009)
New Revision: 10218

Added:
   Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_request_remote_user.t
Modified:
   Catalyst-Runtime/5.80/trunk/Changes
   Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
   Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/CGI.pm
   Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm
   Catalyst-Runtime/5.80/trunk/t/lib/DeprecatedTestApp/C/Root.pm
Log:
Merge the branch which gives ->req->remote_user without the deprecation code which is horrrible

Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes	2009-05-21 13:39:48 UTC (rev 10217)
+++ Catalyst-Runtime/5.80/trunk/Changes	2009-05-21 13:44:58 UTC (rev 10218)
@@ -1,5 +1,7 @@
 # This file documents the revision history for Perl extension Catalyst.
 
+        - Add $c->req->remote_user to disambiguate from $c->req->user (dwc)
+
 5.80004 2009-05-18 17:03:23
         - Rename the actions attribute in Catalyt::Controller to
           _controller_actions to avoid name clashes with application

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/CGI.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/CGI.pm	2009-05-21 13:39:48 UTC (rev 10217)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/CGI.pm	2009-05-21 13:44:58 UTC (rev 10218)
@@ -72,7 +72,8 @@
 
     $request->hostname( $ENV{REMOTE_HOST} ) if exists $ENV{REMOTE_HOST};
     $request->protocol( $ENV{SERVER_PROTOCOL} );
-    $request->user( $ENV{REMOTE_USER} );
+    $request->user( $ENV{REMOTE_USER} );  # XXX: Deprecated. See Catalyst::Request for removal information
+    $request->remote_user( $ENV{REMOTE_USER} );
     $request->method( $ENV{REQUEST_METHOD} );
 
     if ( $ENV{HTTPS} && uc( $ENV{HTTPS} ) eq 'ON' ) {

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm	2009-05-21 13:39:48 UTC (rev 10217)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm	2009-05-21 13:44:58 UTC (rev 10218)
@@ -26,7 +26,7 @@
 has secure => (is => 'rw', default => 0);
 has captures => (is => 'rw', default => sub { [] });
 has uri => (is => 'rw', predicate => 'has_uri');
-has user => (is => 'rw');
+has remote_user => (is => 'rw');
 has headers => (
   is      => 'rw',
   isa     => 'HTTP::Headers',
@@ -126,6 +126,10 @@
 
 has _path => ( is => 'rw', predicate => '_has_path', clearer => '_clear_path' );
 
+# XXX: Deprecated in docs ages ago (2006), deprecated with warning in 5.8000 due
+# to confusion between Engines and Plugin::Authentication. Remove in 5.8100?
+has user => (is => 'rw');
+
 sub args            { shift->arguments(@_) }
 sub body_params     { shift->body_parameters(@_) }
 sub input           { shift->body(@_) }
@@ -587,9 +591,13 @@
 
 =head2 $req->user
 
-Returns the currently logged in user. Deprecated. The method recommended for
-newer plugins is $c->user.
+Returns the currently logged in user. B<Highly deprecated>, do not call,
+this will be removed in version 5.81.
 
+=head2 $req->remote_user
+
+Returns the value of the C<REMOTE_USER> environment variable.
+
 =head2 $req->user_agent
 
 Shortcut to $req->headers->user_agent. Returns the user agent (browser)

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm	2009-05-21 13:39:48 UTC (rev 10217)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm	2009-05-21 13:44:58 UTC (rev 10218)
@@ -2712,6 +2712,8 @@
 
 Drew Taylor
 
+dwc: Daniel Westermann-Clark <danieltwc at cpan.org>
+
 esskar: Sascha Kiefer
 
 fireartist: Carl Franks <cfranks at cpan.org>

Added: Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_request_remote_user.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_request_remote_user.t	                        (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_request_remote_user.t	2009-05-21 13:44:58 UTC (rev 10218)
@@ -0,0 +1,42 @@
+#!perl
+
+# This tests to make sure the REMOTE_USER environment variable is properly passed through by the engine.
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+
+use Test::More tests => 7;
+use Catalyst::Test 'TestApp';
+
+use Catalyst::Request;
+use HTTP::Request::Common;
+
+{
+    my $creq;
+
+    local $ENV{REMOTE_USER} = 'dwc';
+    my $request = GET(
+        'http://localhost/dump/request',
+    );
+
+    ok( my $response = request($request), 'Request' );
+    ok( $response->is_success, 'Response Successful 2xx' );
+    is( $response->content_type, 'text/plain', 'Response Content-Type' );
+    like( $response->content, qr/'Catalyst::Request'/,
+        'Content is a serialized Catalyst::Request' );
+
+    {
+        no strict 'refs';
+        ok(
+            eval '$creq = ' . $response->content,
+            'Unserialize Catalyst::Request'
+        );
+    }
+
+    isa_ok( $creq, 'Catalyst::Request' );
+    
+    is( $creq->remote_user, 'dwc', '$c->req->remote_user ok' );
+}

Modified: Catalyst-Runtime/5.80/trunk/t/lib/DeprecatedTestApp/C/Root.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/DeprecatedTestApp/C/Root.pm	2009-05-21 13:39:48 UTC (rev 10217)
+++ Catalyst-Runtime/5.80/trunk/t/lib/DeprecatedTestApp/C/Root.pm	2009-05-21 13:44:58 UTC (rev 10218)
@@ -10,4 +10,9 @@
     $c->res->body('root index');
 }
 
+sub req_user : Local {
+    my ( $self, $c ) = @_;
+    $c->res->body('REMOTE_USER = ' . $c->req->user);
+}
+
 1;




More information about the Catalyst-commits mailing list