<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi,<br>
<br>
Is it possible to test Digest Authentication with Plack::Test
without starting a live server?<br>
<br>
With a live server I can do this:<br>
<br>
<code> my $browser = LWP::UserAgent->new();</code><code><br>
</code><code> $req = HTTP::Request->new( GET =>
'<a class="moz-txt-link-freetext" href="http://localhost:5000/">http://localhost:5000/</a>' );</code><code><br>
</code><code> $browser->credentials(</code><code><br>
</code><code> "localhost:5000",</code><code><br>
</code><code> "ZZZZZZ",</code><code><br>
</code><code> '<a class="moz-txt-link-abbreviated" href="mailto:arjan@xxxxxx.nl">arjan@xxxxxx.nl</a>' => 'xxxxxx'</code><code><br>
</code><code> );</code><code></code><code><br>
</code><code> $res = $browser->request( $req );</code><code><br>
</code><code> ok( $res->status_line eq '200 OK', 'success with
login with credentials' );</code><br>
<br>
And in my Dancer2 app I get:<br>
<br>
<code>get '/' => sub {</code><code><br>
</code><code> my $dsl = shift;</code><code><br>
</code><code> my $user = $dsl->app->request->user;</code><br>
<br>
Is it possible to do something like:<br>
<br>
my $test = Plack::Test->create($app);<br>
<br>
<code>my $req = GET '/mYtQ2EeQthcclMhsqDZTbVcggwX9kJDo';</code><code><br>
</code><code>$req->header( "Accept" =>
"application/json" );</code><code><br>
</code><code>$req->header( "Host" => "localhost"
);</code><code><br>
</code><code>$req->header( "Authorization" => 'Digest
username=<a class="moz-txt-link-rfc2396E" href="mailto:arjan@xxxxxx.nl">"arjan@xxxxxx.nl"</a>,</code><code><br>
</code><code> realm="ZZZZZZ",</code><code><br>
</code><code>
nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",</code><code><br>
</code><code> uri="/",</code><code><br>
</code><code> qop=auth,</code><code><br>
</code><code> nc=00000001,</code><code><br>
</code><code> cnonce="0a4f113b",</code><code><br>
</code><code>
response="6629fae49393a05397450978507c4ef1",</code><code><br>
</code><code>
opaque="5ccc069c403ebaf9f0171e9517f40e41"');</code><code><br>
</code><code>my $res = $test->request( $req );</code><br>
<br>
And get the user in Dancer2 in the same way:<br>
<br>
<code>get '/' => sub {</code><code><br>
</code><code> my $dsl = shift;</code><code><br>
</code><code> my $user = $dsl->app->request->user;</code><br>
<br>
Where does Dancer2 get the user that is returned with
$dsl->app->request->user? I had a hard time finding this in
Dancer2::Core::Request.pm, where it's in the documentation. <br>
<br>
Kind regards,<br>
Arjan.<br>
</body>
</html>