5 use lib ("$FindBin::Bin/lib");
7 use stemmaweb::Test::Common;
10 use LWP::Protocol::PSGI;
11 use Test::WWW::Mechanize;
14 use HTML::TreeBuilder;
17 use stemmaweb::Test::DB;
19 my $dir = stemmaweb::Test::DB->new_db;
21 my $scope = $dir->new_scope;
23 LWP::Protocol::PSGI->register(stemmaweb->psgi_app);
25 my $ua = Test::WWW::Mechanize->new;
27 $ua->get_ok('http://localhost/login');
29 # Trying a user that already exists
31 local *Catalyst::Authentication::Credential::OpenID::authenticate = sub {
32 my ( $self, $c, $realm, $authinfo ) = @_;
34 return $realm->find_user({ url => 'http://localhost/' }, $c);
40 openid_identifier => 'http://localhost',
44 $ua->content_contains('You have logged in.', 'Openid login works');
48 $ua->content_contains('Hello! http://localhost/!', 'We are logged in.');
52 # Trying a user that doesn't already exist
54 local *Catalyst::Authentication::Credential::OpenID::authenticate = sub {
55 my ( $self, $c, $realm, $authinfo ) = @_;
57 return $realm->find_user({ url => 'http://example.org/' }, $c);
61 ok !$dir->find_user({ url => 'http://example.org/' }), 'No such user, yet.';
63 $ua->get_ok('http://localhost/login');
68 openid_identifier => 'http://example.org',
72 $ua->content_contains('You have logged in.', 'Openid login works');
76 $ua->content_contains('Hello! http://example.org/!', 'We are logged in.');
78 ok $dir->find_user({ url => 'http://example.org/' }), 'User now exists.';
82 $ua->get_ok('http://localhost/login');
87 openid_identifier => 'http://example.org',
91 $ua->content_contains('You have logged in.', 'We can now log in to our created user');
95 $ua->content_contains('Hello! http://example.org/!', 'We are logged in.');