summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJozef Kutej <jozef@kutej.net>2008-12-01 21:42:56 +0100
committerJozef Kutej <jozef@kutej.net>2008-12-01 21:42:56 +0100
commitd8a82d59b21fabcded52aca88433ee4556ed7805 (patch)
treef6940d968c23c3ca35ae9fc89be085c02ae1805f
parentMerge branch 'master' of git@git.useperl.at:PAUSE-OpenID (diff)
downloadSimple-OpenID-d8a82d59b21fabcded52aca88433ee4556ed7805.tar.gz
Simple-OpenID-d8a82d59b21fabcded52aca88433ee4556ed7805.tar.bz2
Simple-OpenID-d8a82d59b21fabcded52aca88433ee4556ed7805.zip
login test
-rw-r--r--t/01-login.t54
1 files changed, 54 insertions, 0 deletions
diff --git a/t/01-login.t b/t/01-login.t
new file mode 100644
index 0000000..d15cef2
--- /dev/null
+++ b/t/01-login.t
@@ -0,0 +1,54 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+#use Test::More 'no_plan';
+use Test::More tests => 4;
+use Test::WWW::Mechanize;
+#use WWW::Mechanize::Plugin::AutoWrite;
+
+use FindBin qw($Bin);
+use lib "$Bin/lib";
+
+my $url = $ENV{'PAUSE_OpenID_url'} || 'http://localhost:3000/openid/';
+
+exit main();
+
+sub main {
+ my $mech = Test::WWW::Mechanize->new;
+ #$mech->autowrite('/tmp/mech.html');
+ $mech->get_ok($url) or exit(1);
+
+ my $uid = 'nonexisting';
+ my $pass = 'nonexisting';
+
+ my $res = $mech->submit_form(
+ 'form_number' => 1,
+ 'fields' => {
+ 'user' => $uid,
+ 'pass' => $pass,
+ },
+ );
+ is($res->code, 404, 'check failed login');
+
+ $uid = $ENV{'PAUSE_OpenID_uid'};
+ $pass = $ENV{'PAUSE_OpenID_pass'};
+
+ SKIP: {
+ skip('set PAUSE_OpenID_uid and PAUSE_OpenID_pass to test the successful login', 2)
+ if ((not $uid) or (not $pass));
+
+ $mech->get_ok($url);
+ my $res = $mech->submit_form(
+ 'with_fields' => {
+ 'user' => $uid,
+ 'pass' => $pass,
+ },
+ );
+ is($res->code, 200, 'check passed login');
+ }
+
+ return 0;
+}
+