Merge the branch which gives ->req->remote_user without the deprecation code which...
[catagits/Catalyst-Runtime.git] / t / aggregate / live_engine_request_remote_user.t
diff --git a/t/aggregate/live_engine_request_remote_user.t b/t/aggregate/live_engine_request_remote_user.t
new file mode 100644 (file)
index 0000000..10b071b
--- /dev/null
@@ -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' );
+}