[Jifty-commit] r1434 - in wifty: trunk/t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat Jul 1 16:37:28 EDT 2006


Author: nelhage
Date: Sat Jul  1 16:37:28 2006
New Revision: 1434

Added:
   wifty/trunk/t/02-login.t   (contents, props changed)
Modified:
   wifty/   (props changed)
   wifty/trunk/t/0-test-database.t

Log:
 r13518 at phanatique:  nelhage | 2006-06-30 19:13:41 +0200
 Fixing t/0-test-database and adding login tests


Modified: wifty/trunk/t/0-test-database.t
==============================================================================
--- wifty/trunk/t/0-test-database.t	(original)
+++ wifty/trunk/t/0-test-database.t	Sat Jul  1 16:37:28 2006
@@ -8,7 +8,7 @@
 
 =cut
 
-use Wifty::Test test => 12;
+use Wifty::Test tests => 12;
 
 my $admin = Wifty::CurrentUser->superuser;
 

Added: wifty/trunk/t/02-login.t
==============================================================================
--- (empty file)
+++ wifty/trunk/t/02-login.t	Sat Jul  1 16:37:28 2006
@@ -0,0 +1,55 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+=head1 DESCRIPTION
+
+Test that we can log in to Wifty
+
+=cut
+
+use constant PER_TRIAL => 3;
+
+use Wifty::Test tests => 5 + PER_TRIAL * 4;
+use Jifty::Test::WWW::Mechanize;
+
+my $server = Wifty::Test->make_server;
+
+my $URL = $server->started_ok;
+
+ok($URL, "Started a test server");
+
+my $mech = Jifty::Test::WWW::Mechanize->new();
+
+$mech->get_ok($URL, "Got the homepage");
+ok($mech->find_link(text_regex => qr/currently signed in/), 'Got the signin link');
+$mech->follow_link_ok(text_regex => qr/currently signed in/);
+
+sub try_login {
+    my $mech = shift;
+    my $user = shift;
+    my $pass = shift;
+    
+    {
+        local $Test::Builder::Level = $Test::Builder::Level;
+        $Test::Builder::Level++;
+        $mech->fill_in_action_ok('loginbox', email => $user, password => $pass);
+        $mech->submit_html_ok();
+    }
+}
+
+# Try logging in with a bad user
+try_login($mech, 'baduser at localhost', 'notmypassword');
+$mech->content_contains('No account has that email address', "Login failed with bad username");
+
+# With a blank password
+try_login($mech, 'someuser at localost', '');
+$mech->content_contains('need to fill in this field','Login fails with no password');
+
+# With the wrong password
+try_login($mech, 'someuser at localhost', 'badmemory');
+$mech->content_contains('may have mistyped','Login fails with wrong password');
+
+# Try a correct login
+try_login($mech, 'someuser at localhost', 'sekrit');
+$mech->content_contains('Welcome back','Logged in');


More information about the Jifty-commit mailing list