summaryrefslogtreecommitdiff
path: root/t/Webmail.t
blob: 970b7bf753b59761597c1bffa7dcd316fbfc04a4 (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
use v5.24;
use warnings;
use utf8;

use Test::More;
use Test::Mojo;


use constant DEFAULT_LANGUAGE => 'en';
my $user = 'mockmaildir@example.org';
my $pw   = '12345';


my $t = Test::Mojo->new('JWebmail', {
    model      => { read  => { virtual_user => $ENV{USER}, mailbox_path => 't/testdata', authenticator => 'script/testauthenticator.pl' },
                    write => { sendmail => 'cat' }},
    i18n       => { default_language => DEFAULT_LANGUAGE },
    admin_mail => 'test@example.org',
});

$t->get_ok('/')->status_is(200);

subtest login => sub {
    $t->post_ok('/', form => {userid => $user, password => 'x'})->status_is(400);
    $t->post_ok('/', form => {userid => $user, password => 'abcde'})->status_is(401);
    $t->post_ok('/', form => {userid => $user, password => $pw})->status_is(303);
};


subtest lang => sub {
    $t->get_ok('/about')->status_is(200)->attr_is('html', 'lang', DEFAULT_LANGUAGE);
    $t->get_ok('/en/about')->status_is(200)->attr_is('html', 'lang', 'en');
    $t->get_ok('/de/about')->status_is(200)->attr_is('html', 'lang', 'de');
};


done_testing;