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 # NOTE: this test uses Text::Tradition::Directory
22 # to check user accounts really have been created.
23 # It'll need to be changed once that is replaced...
25 my $scope = $dir->new_scope;
27 LWP::Protocol::PSGI->register(stemmaweb->psgi_app);
29 my $ua = Test::WWW::Mechanize->new;
31 $ua->get_ok('http://localhost/login');
33 # Trying a user that already exists
35 local *Catalyst::Authentication::Credential::OpenID::authenticate = sub {
36 my ( $self, $c, $realm, $authinfo ) = @_;
38 return $realm->find_user({ url => 'http://localhost/' }, $c);
44 openid_identifier => 'http://localhost',
48 $ua->content_contains('You have logged in.', 'Openid login works');
52 $ua->content_contains('Hello! http://localhost/!', 'We are logged in.');
56 # Trying a user that doesn't already exist
58 local *Catalyst::Authentication::Credential::OpenID::authenticate = sub {
59 my ( $self, $c, $realm, $authinfo ) = @_;
61 return $realm->find_user({ url => 'http://example.org/' }, $c);
65 ok !$dir->find_user({ url => 'http://example.org/' }), 'No such user, yet.';
67 $ua->get_ok('http://localhost/login');
72 openid_identifier => 'http://example.org',
76 $ua->content_contains('You have logged in.', 'Openid login works');
80 $ua->content_contains('Hello! http://example.org/!', 'We are logged in.');
82 ok $dir->find_user({ url => 'http://example.org/' }), 'User now exists.';
86 $ua->get_ok('http://localhost/login');
91 openid_identifier => 'http://example.org',
95 $ua->content_contains('You have logged in.', 'We can now log in to our created user');
99 $ua->content_contains('Hello! http://example.org/!', 'We are logged in.');