6 eval { require Test::WWW::Mechanize::Catalyst }
8 "Test::WWW::Mechanize::Catalyst is needed for this test";
19 __PACKAGE__->config(authentication => {
20 default_realm => 'test_proxy',
30 password_type => 'clear',
31 password_field => 'password'
38 foo => { password => 'proxypass' }
42 class => 'HTTP::Proxy',
43 url => 'http://localhost/moose',
50 my ( $self, $c ) = @_;
51 $c->authenticate({}, 'test');
52 $c->res->body( 'test realm:' . $c->user->id );
55 my ( $self, $c ) = @_;
56 $c->authenticate({}, 'test_proxy');
57 $c->res->body( 'test_proxy realm:' . $c->user->id );
60 foo => { password => "s3cr3t", },
64 use Test::WWW::Mechanize::Catalyst qw/AuthTestApp/;
66 no warnings qw/once redefine/;
67 *Catalyst::Authentication::Credential::HTTP::Proxy::User::new = sub { Test::WWW::Mechanize::Catalyst->new };
71 skip 'Catalyst engine is not reenterant, this will not work', 5;
74 my $mech = Test::WWW::Mechanize::Catalyst->new;
76 # $mech->get("http://localhost/moose");
77 is( $mech->status, 401, "status is 401" ) or die $mech->content;
78 $mech->content_lacks( "foo", "no output" );
82 my $r = HTTP::Request->new( GET => "http://localhost/moose" );
83 $r->authorization_basic(qw/foo s3cr3t/);
85 is( $mech->status, 200, "status is 200" );
86 $mech->content_contains( "test realm:foo", "test realm:foo output" );
89 { # HTTP with other auth
90 my $r = HTTP::Request->new( GET => "http://localhost/moose" );
91 $r->authorization_basic(qw/foo proxypass/);
93 is( $mech->status, 401, "status is 401" ) or die $mech->content;
99 skip 'Catalyst engine is not reenterant, this will not work', 4;
102 my $mech = Test::WWW::Mechanize::Catalyst->new;
104 # $mech->get("http://localhost/yak");
105 is( $mech->status, 401, "status is 401" ) or die $mech->content;
106 $mech->content_lacks( "foo", "no output" );
109 { # Proxy with other auth
110 my $r = HTTP::Request->new( GET => "http://localhost/yak" );
111 $r->authorization_basic(qw/foo s3cr3t/);
112 # $mech->request($r);
113 is( $mech->status, 401, "status is 401" ) or die $mech->content;
116 { # HTTP with other auth
117 my $r = HTTP::Request->new( GET => "http://localhost/yak" );
118 $r->authorization_basic(qw/foo proxypass/);
119 # $mech->request($r);
120 is( $mech->status, 200, "status is 200" );
121 $mech->content_contains( "test_proxy realm:foo", "test_proxy realm:foo output" );