Catalyst-Plugin-Authentication-Credential-HTTP

 view release on metacpan or  search on metacpan

t/live_app.t  view on Meta::CPAN

use FindBin;
use lib "$FindBin::Bin/lib";
use Test::More;
BEGIN {
    eval { require Test::WWW::Mechanize::Catalyst }
      or plan skip_all =>
      "Test::WWW::Mechanize::Catalyst is needed for this test";
    plan tests => 5;
    use_ok 'AuthTestApp' or die;
}
use HTTP::Request;
use Test::WWW::Mechanize::Catalyst qw/AuthTestApp/;
my $mech = Test::WWW::Mechanize::Catalyst->new;
$mech->get("http://localhost/moose");
is( $mech->status, 401, "status is 401" );
$mech->content_lacks( "foo", "no output" );
my $r = HTTP::Request->new( GET => "http://localhost/moose" );
$r->authorization_basic(qw/foo s3cr3t/);
$mech->request($r);
is( $mech->status, 200, "status is 200" );
$mech->content_contains( "foo", "foo output" );

t/live_app_digest.t  view on Meta::CPAN

      "Test::WWW::Mechanize::Catalyst is needed for this test";
    eval { require Catalyst::Plugin::Cache }
      or plan skip_all =>
      "Catalyst::Plugin::Cache is needed for this test";
        eval { require Cache::FileCache }
      or plan skip_all =>
      "Cache::FileCache is needed for this test";
    plan tests => 5;
    use_ok 'AuthDigestTestApp' or die;
}
use HTTP::Request;
use Test::WWW::Mechanize::Catalyst qw/AuthDigestTestApp/;
my $mech = Test::WWW::Mechanize::Catalyst->new;
$mech->get("http://localhost/moose");
is( $mech->status, 401, "status is 401" );
my $www_auth = $mech->res->headers->header('WWW-Authenticate');
my %www_auth_params = map {
    my @key_val = split /=/, $_, 2;
    $key_val[0] = lc $key_val[0];
    $key_val[1] =~ s{"}{}g;    # remove the quotes
    @key_val;

t/live_app_digest.t  view on Meta::CPAN

    $ctx = Digest::MD5->new;
    $ctx->add( join( ':', $method, $uri ) );
    my $A2_digest = $ctx->hexdigest;
    my $digest = Digest::MD5::md5_hex(
        join( ':',
            $A1_digest, $nonce, $qop ? ( $nc, $cnonce, $qop ) : (), $A2_digest )
    );

    $response = qq{Digest username="$username", realm="$realm", nonce="$nonce", uri="$uri", qop=$qop, nc=$nc, cnonce="$cnonce", response="$digest", opaque="$opaque"};
}
my $r = HTTP::Request->new( GET => "http://localhost/moose" );
$mech->request($r);
$r->headers->push_header( Authorization => $response );
$mech->request($r);
is( $mech->status, 200, "status is 200" );
$mech->content_contains( "Mufasa", "Mufasa output" );



( run in 0.282 second using v1.01-cache-2.11-cpan-de7293f3b23 )