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',
39 my ( $self, $c ) = @_;
40 $c->res->body( $c->user->id );
43 foo => { password => "s3cr3t", },
47 use Test::WWW::Mechanize::Catalyst qw/AuthTestApp/;
48 my $mech = Test::WWW::Mechanize::Catalyst->new;
49 $mech->get("http://localhost/moose");
50 is( $mech->status, 401, "status is 401" ) or die $mech->content;
51 $mech->content_lacks( "foo", "no output" );
52 my $r = HTTP::Request->new( GET => "http://localhost/moose" );
53 $r->authorization_basic(qw/foo s3cr3t/);
55 is( $mech->status, 200, "status is 200" );
56 $mech->content_contains( "foo", "foo output" );