1 |
#!/usr/bin/perl |
2 |
|
3 |
use warnings; |
4 |
use strict; |
5 |
|
6 |
use Test::More tests => 4; |
7 |
use Test::WWW::Mechanize; |
8 |
use File::Slurp; |
9 |
|
10 |
our $config; |
11 |
require 't/config.pl'; |
12 |
|
13 |
use WWW::Mechanize; |
14 |
|
15 |
my $mech = Test::WWW::Mechanize->new; |
16 |
|
17 |
my $save_count = 1; |
18 |
sub save { write_file "/tmp/login-$save_count.html", @_; $save_count++; } |
19 |
|
20 |
|
21 |
$mech->get_ok( 'https://localhost', 'opac' ); |
22 |
save $mech->content; |
23 |
|
24 |
$mech->follow_link_ok({ text_regex => qr/Log in to Your Account/i }, 'login form' ); |
25 |
save $mech->content; |
26 |
|
27 |
$mech->submit_form_ok({ |
28 |
form_number => 2, |
29 |
fields => { |
30 |
userid => $config->{bind_as}, |
31 |
password => $config->{password}, |
32 |
}, |
33 |
}, 'login'); |
34 |
save $mech->content; |
35 |
|
36 |
$mech->follow_link_ok({ url_regex => qr/logout/ }, 'logout' ); |