Catalyst-Authentication-Credential-HTTP
view release on metacpan or search on metacpan
},
"test" : {
"recommends" : {
"CPAN::Meta" : "2.120900"
},
"requires" : {
"Catalyst::Controller" : "0",
"File::Spec" : "0",
"FindBin" : "0",
"HTTP::Headers" : "0",
"HTTP::Request" : "0",
"Module::Metadata" : "0",
"Test::Exception" : "0",
"Test::MockObject" : "0",
"Test::MockObject::Extends" : "0",
"Test::More" : "0",
"Test::Needs" : "0",
"lib" : "0",
"perl" : "5.006"
}
},
---
abstract: 'HTTP Basic and Digest authentication for Catalyst'
author:
- "×××× ×§××'×× (Yuval Kogman) <nothingmuch@woobling.org>"
build_requires:
Catalyst::Controller: '0'
File::Spec: '0'
FindBin: '0'
HTTP::Headers: '0'
HTTP::Request: '0'
Module::Metadata: '0'
Test::Exception: '0'
Test::MockObject: '0'
Test::MockObject::Extends: '0'
Test::More: '0'
Test::Needs: '0'
lib: '0'
perl: '5.006'
configure_requires:
Module::Build::Tiny: '0.034'
t/00-report-prereqs.dd view on Meta::CPAN
},
'test' => {
'recommends' => {
'CPAN::Meta' => '2.120900'
},
'requires' => {
'Catalyst::Controller' => '0',
'File::Spec' => '0',
'FindBin' => '0',
'HTTP::Headers' => '0',
'HTTP::Request' => '0',
'Module::Metadata' => '0',
'Test::Exception' => '0',
'Test::MockObject' => '0',
'Test::MockObject::Extends' => '0',
'Test::More' => '0',
'Test::Needs' => '0',
'lib' => '0',
'perl' => '5.006'
}
},
t/live_app.t view on Meta::CPAN
use strict;
use warnings;
use FindBin qw/$Bin/;
use lib "$Bin/lib";
use Test::More;
use Test::Needs { 'Test::WWW::Mechanize::Catalyst' => '0.51' };
use HTTP::Request;
my $mech = Test::WWW::Mechanize::Catalyst->new(catalyst_app => 'AuthTestApp');
$mech->get("http://localhost/moose");
is( $mech->status, 401, "status is 401" ) or die $mech->content;
$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" );
AuthTestApp->get_auth_realm('test')->credential->no_unprompted_authorization_required(1);
$mech = Test::WWW::Mechanize::Catalyst->new(catalyst_app => 'AuthTestApp');
$mech->get("http://localhost/moose");
isnt( $mech->status, 401, "status isnt 401" ) or die $mech->content;
AuthTestApp->get_auth_realm('test')->credential->no_unprompted_authorization_required(0);
AuthTestApp->get_auth_realm('test')->credential->require_ssl(1);
$mech = Test::WWW::Mechanize::Catalyst->new(catalyst_app => 'AuthTestApp');
$r = HTTP::Request->new( GET => "http://localhost/moose" );
$r->authorization_basic(qw/foo s3cr3t/);
$mech->request($r);
is( $mech->status, 401, "status is 401" );
done_testing;
t/live_app_digest.t view on Meta::CPAN
use Test::More;
use Test::Needs {
'Test::WWW::Mechanize::Catalyst' => '0.51',
'Catalyst::Plugin::Cache' => '0',
'Cache::FileCache' => undef,
};
plan tests => 12;
use Digest::MD5;
use HTTP::Request;
Test::WWW::Mechanize::Catalyst->import(qw/AuthDigestTestApp/);
sub do_test {
my $username = shift;
my $uri = shift;
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 {
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" . $uri );
$mech->request($r);
$r->headers->push_header( Authorization => $response );
$mech->request($r);
is( $mech->status, 200, "status is 200" );
$mech->content_contains( $username, "Mufasa output" );
}
do_test('Mufasa');
do_test('Mufasa2');
do_test('Mufasa', '/moose?moose_id=1'); # Digest auth includes the full URL path, so need to test query strings
t/live_app_digest_dotnet.t view on Meta::CPAN
use Test::More;
use Test::Needs {
'Test::WWW::Mechanize::Catalyst' => '0.51',
'Catalyst::Plugin::Cache' => '0',
'Cache::FileCache' => undef,
};
plan tests => 19;
use Digest::MD5;
use HTTP::Request;
sub do_test {
my ($username, $uri, $emulate_dotnet, $fail) = @_;
my $app = $fail ? 'AuthDigestTestApp' : 'AuthDigestDotnetTestApp';
my $mech = Test::WWW::Mechanize::Catalyst->new(catalyst_app => $app);
$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;
t/live_app_digest_dotnet.t view on Meta::CPAN
$ctx = Digest::MD5->new;
$ctx->add( join( ':', $method, $auth_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="$auth_uri", qop=$qop, nc=$nc, cnonce="$cnonce", response="$digest", opaque="$opaque"};
}
my $r = HTTP::Request->new( GET => "http://localhost" . $uri );
$mech->request($r);
$r->headers->push_header( Authorization => $response );
$mech->request($r);
if ($fail) {
is( $mech->status, 400, "status is 400" );
} else {
is( $mech->status, 200, "status is 200" );
$mech->content_contains( $username, "Mufasa output" );
}
}
( run in 0.633 second using v1.01-cache-2.11-cpan-de7293f3b23 )