File: 071-basic-authorization.t

package info (click to toggle)
libhttp-headers-actionpack-perl 0.09-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 364 kB
  • sloc: perl: 2,614; makefile: 2
file content (52 lines) | stat: -rw-r--r-- 1,093 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;
use Test::Fatal;

BEGIN {
    use_ok('HTTP::Headers::ActionPack::Authorization::Basic');
}

sub test_auth {
    my $auth = shift;

    is($auth->auth_type, 'Basic', '... got the right auth type');

    is($auth->username, 'Aladdin', '... got the expected username');
    is($auth->password, 'open sesame', '... got the expected password');

    is($auth->as_string, 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==', '... got the right stringification')
}

test_auth(
    HTTP::Headers::ActionPack::Authorization::Basic->new_from_string(
        'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
    )
);

test_auth(
    HTTP::Headers::ActionPack::Authorization::Basic->new(
        'Basic' => {
            username => 'Aladdin',
            password => 'open sesame'
        }
    )
);

test_auth(
    HTTP::Headers::ActionPack::Authorization::Basic->new(
        'Basic' => [ 'Aladdin', 'open sesame' ]
    )
);

test_auth(
    HTTP::Headers::ActionPack::Authorization::Basic->new(
        'Basic' => 'QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
    )
);


done_testing;