summaryrefslogtreecommitdiff
path: root/t/01-login.t
blob: d15cef20692a79ad8171c029dd464997473b20ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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($urlor 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 $uidor (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;
}