Commit | Line | Data |
9918773a |
1 | use warnings; |
2 | use strict; |
3 | |
4 | use stemmaweb; |
5 | use LWP::Protocol::PSGI; |
6 | use Test::WWW::Mechanize; |
7 | |
8 | use Test::More; |
9 | use HTML::TreeBuilder; |
10 | use Data::Dumper; |
11 | |
fb45a11f |
12 | use FindBin; |
325d9f41 |
13 | use lib ("$FindBin::Bin/lib"); |
fb45a11f |
14 | |
325d9f41 |
15 | use stemmaweb::Test::DB; |
16 | |
17 | stemmaweb::Test::DB->new_db; |
fb45a11f |
18 | |
9918773a |
19 | LWP::Protocol::PSGI->register(stemmaweb->psgi_app); |
20 | |
21 | my $ua = Test::WWW::Mechanize->new; |
22 | |
23 | $ua->get_ok('http://localhost/login'); |
24 | my $response = $ua->submit_form( |
25 | fields => { |
26 | username => 'user@example.org', |
27 | password => 'UserPass' |
28 | }); |
29 | |
30 | $ua->content_contains('Stemmaweb - Logged in', 'Log in successful.'); |
31 | |
32 | my $content = $ua->get('/'); |
33 | $ua->content_contains('Hello! user@example.org', 'We are logged in.'); |
34 | |
08e5e776 |
35 | $ua->get('/logout'); |
36 | $ua->get('/login'); |
37 | |
38 | $ua->submit_form; |
39 | |
40 | $ua->content_contains('Your username is required.', 'Username is required to log in'); |
41 | $ua->content_contains('Your password is required.', 'Password is required to log in.'); |
42 | |
43 | $ua->submit_form( |
44 | fields => { |
45 | username => 'nonexistant', |
46 | password => 'nonexistant', |
47 | }); |
48 | |
49 | $ua->content_contains('Bad username or password.', 'Error is shown on incorrect details.'); |
50 | |
51 | |
9918773a |
52 | done_testing; |