Commit | Line | Data |
790f9ddb |
1 | #!/usr/bin/perl |
790f9ddb |
2 | use strict; |
3 | use warnings; |
d5ba435e |
4 | use FindBin; |
5 | use lib "$FindBin::Bin/lib"; |
ed61ff6d |
6 | use Test::More; |
ed61ff6d |
7 | BEGIN { |
8 | eval { require Test::WWW::Mechanize::Catalyst } |
9 | or plan skip_all => |
10 | "Test::WWW::Mechanize::Catalyst is needed for this test"; |
d5ba435e |
11 | plan tests => 5; |
12 | use_ok 'AuthTestApp' or die; |
ed61ff6d |
13 | } |
790f9ddb |
14 | use HTTP::Request; |
790f9ddb |
15 | use Test::WWW::Mechanize::Catalyst qw/AuthTestApp/; |
790f9ddb |
16 | my $mech = Test::WWW::Mechanize::Catalyst->new; |
790f9ddb |
17 | $mech->get("http://localhost/moose"); |
ed61ff6d |
18 | is( $mech->status, 401, "status is 401" ); |
ed61ff6d |
19 | $mech->content_lacks( "foo", "no output" ); |
790f9ddb |
20 | my $r = HTTP::Request->new( GET => "http://localhost/moose" ); |
21 | $r->authorization_basic(qw/foo s3cr3t/); |
ed61ff6d |
22 | $mech->request($r); |
23 | is( $mech->status, 200, "status is 200" ); |
24 | $mech->content_contains( "foo", "foo output" ); |
d5ba435e |
25 | |