[Jifty-commit] r7010 - in plugins/Jifty-Plugin-OpenID: lib/Jifty/Plugin/OpenID t/TestApp/lib/TestApp
Jifty commits
jifty-commit at lists.jifty.org
Tue May 12 05:38:34 EDT 2009
Author: c9s
Date: Tue May 12 05:38:34 2009
New Revision: 7010
Added:
plugins/Jifty-Plugin-OpenID/t/TestApp/t/00-openid-test.t
Modified:
plugins/Jifty-Plugin-OpenID/lib/Jifty/Plugin/OpenID/View.pm
plugins/Jifty-Plugin-OpenID/t/TestApp/lib/TestApp/View.pm
Log:
provide openid test
Modified: plugins/Jifty-Plugin-OpenID/lib/Jifty/Plugin/OpenID/View.pm
==============================================================================
--- plugins/Jifty-Plugin-OpenID/lib/Jifty/Plugin/OpenID/View.pm (original)
+++ plugins/Jifty-Plugin-OpenID/lib/Jifty/Plugin/OpenID/View.pm Tue May 12 05:38:34 2009
@@ -60,7 +60,7 @@
)
);
};
- Jifty->web->form->start( call => $next );
+ Jifty->web->form->start( call => $next , name => 'openid-user-create' );
render_action($action);
form_submit( label => _('Continue'), submit => $action );
Jifty->web->form->end;
Modified: plugins/Jifty-Plugin-OpenID/t/TestApp/lib/TestApp/View.pm
==============================================================================
--- plugins/Jifty-Plugin-OpenID/t/TestApp/lib/TestApp/View.pm (original)
+++ plugins/Jifty-Plugin-OpenID/t/TestApp/lib/TestApp/View.pm Tue May 12 05:38:34 2009
@@ -6,6 +6,7 @@
template '/' => page {
+ with ( name => 'openid-form' ),
form {
my $openid = new_action( class => 'AuthenticateOpenID',
moniker => 'authenticateopenid' );
Added: plugins/Jifty-Plugin-OpenID/t/TestApp/t/00-openid-test.t
==============================================================================
--- (empty file)
+++ plugins/Jifty-Plugin-OpenID/t/TestApp/t/00-openid-test.t Tue May 12 05:38:34 2009
@@ -0,0 +1,61 @@
+#!/usr/bin/env perl
+use Jifty::Test tests => 12;
+use strict;
+use warnings;
+use Jifty::Test::WWW::Mechanize;
+
+
+
+use Test::OpenID::Server;
+my $test_openid_server = Test::OpenID::Server->new;
+my $test_openid_url = $test_openid_server->started_ok("server started ok");
+
+diag $test_openid_url;
+
+my $openid = "$test_openid_url/c9s";
+
+
+my $server = Jifty::Test->make_server;
+isa_ok( $server, 'Jifty::Server' );
+my $URL = $server->started_ok;
+my $mech = Jifty::Test::WWW::Mechanize->new;
+$mech->get_ok( $URL . '/' , "get mainpage" );
+$mech->content_contains( 'Login with OpenID' );
+$mech->content_contains( 'OpenID URL' );
+$mech->content_contains( 'For example:' );
+
+$mech->submit_form(
+ form_name => 'openid-form',
+ fields => {
+ 'J:A:F-openid-authenticateopenid' => $openid,
+ },
+ # button => 'Login with OpenID'
+);
+
+$mech->content_contains( 'Set your username' );
+
+
+# match this name="J:A:F-name-auto-86d3fcd1a158d85fd2e6165fc00113c7-1"
+my $content = $mech->content();
+my ($field_name) = ($content =~ m[name="(J:A:F-name-auto-\w+-\d)"]gsm);
+
+diag $field_name;
+
+$mech->submit_form(
+ form_name => 'openid-user-create',
+ fields => {
+ $field_name => 'c9s'
+ },
+ # button => 'Continue'
+);
+
+
+$mech->content_contains( 'Welcome' );
+
+
+my $u = TestApp::Model::User->new;
+$u->load_by_cols( name => 'c9s' );
+
+ok( $u->id , 'found user' );
+is( $u->name , 'c9s' , 'found openid register user' );
+is( $u->openid , $openid , 'match openid' );
More information about the Jifty-commit
mailing list