From d8a82d59b21fabcded52aca88433ee4556ed7805 Mon Sep 17 00:00:00 2001 From: Jozef Kutej Date: Mon, 1 Dec 2008 21:42:56 +0100 Subject: login test --- t/01-login.t | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 t/01-login.t 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; +} + -- cgit v1.2.3