File: 70-Lemonldap-NG-Handler-PSGI-AuthBasic.t

package info (click to toggle)
lemonldap-ng 2.21.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 28,024 kB
  • sloc: perl: 77,414; javascript: 25,284; xml: 6,473; makefile: 1,303; sh: 453; sql: 159; python: 53; php: 26
file content (68 lines) | stat: -rw-r--r-- 1,683 bytes parent folder | download | duplicates (4)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use Test::More;
use MIME::Base64;

BEGIN {
    require 't/test-psgi-lib.pm';
}

my $maintests = 3;

init(
    'Lemonldap::NG::Handler::Server',
    {
        # authentication    => 'Demo',
        # userDB            => 'Same',
        # restSessionServer => 1,
        logLevel     => 'error',
        vhostOptions => {
            'test1.example.com' => {
                vhostHttps           => 0,
                vhostPort            => 80,
                vhostMaintenance     => 0,
                vhostServiceTokenTTL => -1,
            },
        },
        exportedHeaders => {
            'test1.example.com' => {
                'Auth-User' => '$uid',
            },
        }
    }
);

ok(
    $res = $client->_get(
        '/', undef, 'test1.example.com', undef, VHOSTTYPE => 'AuthBasic',
    ),
    'Query'
);
ok( $res->[0] == 401, 'Code is 401' ) or explain( $res->[0], 302 );

# Check headers
%h = @{ $res->[1] };
ok(
    $h{'WWW-Authenticate'} =~ m%^Basic realm="LemonLDAP::NG"$%,
    'Header WWW-Authenticate is set to Basic realm="LemonLDAP::NG"'
) or explain( \%h, 'WWW-Authenticate => realm' );

# my $login = encode_base64("dwho:dwho");
# ok(
#     $res = $client->_get(
#         '/', undef, 'test1.example.com', undef,
#         VHOSTTYPE            => 'AuthBasic',
#         HTTP_X_FORWARDED_FOR => '127.0.0.1',
#         HTTP_AUTHORIZATION   => "Basic $login"
#     ),
#     'AuthBasic query'
# );
#
# print STDERR Data::Dumper::Dumper($res);
#
# # Check headers
# %h = @{ $res->[1] };
# ok( $h{'Auth-User'} eq 'dwho', 'Header Auth-User is set to "dwho"' )
#   or explain( \%h, 'Auth-User => "dwho"' );

count($maintests);
done_testing( count() );
clean();