[Jifty-commit] r2946 - in jifty/trunk: lib/Jifty/Plugin/Authentication/Password/Action t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth t/TestApp-Plugin-PasswordAuth/t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sun Mar 11 20:35:48 EDT 2007


Author: jesse
Date: Sun Mar 11 20:35:48 2007
New Revision: 2946

Added:
   jifty/trunk/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth/Bootstrap.pm
   jifty/trunk/t/TestApp-Plugin-PasswordAuth/t/01-tokengen.t
Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Action/GeneratePasswordToken.pm

Log:
 r53344 at pinglin:  jesse | 2007-03-11 20:34:45 -0400
 * A sample inherited action 


Modified: jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Action/GeneratePasswordToken.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Action/GeneratePasswordToken.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Action/GeneratePasswordToken.pm	Sun Mar 11 20:35:48 2007
@@ -7,7 +7,7 @@
 
 =cut
 
-package Jifty::Plugin::Authentication::PasswordAction::GeneratePasswordToken;
+package Jifty::Plugin::Authentication::Password::Action::GeneratePasswordToken;
 use base qw/Jifty::Action/;
 
 =head2 arguments

Added: jifty/trunk/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth/Bootstrap.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth/Bootstrap.pm	Sun Mar 11 20:35:48 2007
@@ -0,0 +1,21 @@
+use warnings;
+use strict;
+package TestApp::Plugin::PasswordAuth::Bootstrap;
+
+
+ use base 'Jifty::Bootstrap';
+ 
+sub run {
+    my $curuser = TestApp::Plugin::PasswordAuth::CurrentUser->new( _bootstrap => 1 );
+    my $user = TestApp::Plugin::PasswordAuth::Model::User->new( current_user => $curuser );
+    my ($val,$msg) = $user->create( username => 'gooduser at example.com',
+                                            color => 'gray',
+                                                                   swallow_type => 'african',
+                                                                                          password => 'secret'
+
+);
+
+
+}
+
+1;

Added: jifty/trunk/t/TestApp-Plugin-PasswordAuth/t/01-tokengen.t
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-Plugin-PasswordAuth/t/01-tokengen.t	Sun Mar 11 20:35:48 2007
@@ -0,0 +1,46 @@
+#!/usr/bin/env perl
+
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+This is a template for your own tests. Copy it and modify it.
+
+=cut
+
+
+use lib 't/lib';
+use Jifty::SubTest;
+
+use Jifty::Test tests => 6;
+use Jifty::Test::WWW::Mechanize;
+
+my $server  = Jifty::Test->make_server;
+
+isa_ok($server, 'Jifty::Server');
+
+my $URL     = $server->started_ok;
+my $mech    = Jifty::Test::WWW::Mechanize->new();
+ok(1, "Loaded the test script");
+
+# {{{ Get token for logging in with a JS-based md5-hashed password
+my $service='/__jifty/webservices/yaml';
+my $service_request ="$URL$service?J:A-moniker=GeneratePasswordToken&J:A:F-username-moniker=gooduser\@example.com"; 
+$mech->get_ok($service_request, "Token-generating webservice $service_request exists");
+
+# XXX needs to be more precise in checking for the token, but this works
+# as long as we're using time() for the token
+$mech->content_like(qr/\d+/);
+
+use Jifty::YAML;
+my $data = Jifty::YAML::Load($mech->content);
+
+my $token = $data->{'moniker'}->{'_content'}->{'token'};
+my $salt = $data->{'moniker'}->{'_content'}->{'salt'};
+like($salt, qr/^[0-9A-F]{8}$/i, 'Got a salt');
+
+1;
+
+
+


More information about the Jifty-commit mailing list