File: 060-www-authenticate.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 (85 lines) | stat: -rw-r--r-- 2,155 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/perl

use strict;
use warnings;

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

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

sub test_basic {
    my $www_authen = shift;

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

    is_deeply(
        $www_authen->params,
        { realm => 'WallyWorld' },
        '... got the parameters we expected'
    );

    is($www_authen->as_string, 'Basic realm="WallyWorld"', '... got the right stringification');
}

sub test_digest {
    my $www_authen = shift;

    is($www_authen->auth_type, 'Digest', '... got the right auth type');
    is($www_authen->realm, 'testrealm@host.com', '... got the right realm');

    is_deeply(
        $www_authen->params,
        {
            realm  => 'testrealm@host.com',
            qop    => "auth,auth-int",
            nonce  => "dcd98b7102dd2f0e8b11d0f600bfb0c093",
            opaque => "5ccc069c403ebaf9f0171e9517f40e41"
        },
        '... got the parameters we expected'
    );

    is(
        $www_authen->as_string,
        'Digest realm="testrealm@host.com", qop="auth,auth-int", nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", opaque="5ccc069c403ebaf9f0171e9517f40e41"',
        '... got the right stringification'
    );
}


test_basic(
    HTTP::Headers::ActionPack::WWWAuthenticate->new_from_string(
        'Basic realm="WallyWorld"'
    )
);

test_basic(
    HTTP::Headers::ActionPack::WWWAuthenticate->new(
        'Basic' => (
            realm => "WallyWorld"
        )
    )
);


test_digest(
    HTTP::Headers::ActionPack::WWWAuthenticate->new_from_string(
        'Digest realm="testrealm@host.com", qop="auth,auth-int", nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", opaque="5ccc069c403ebaf9f0171e9517f40e41"'
    )
);

test_digest(
    HTTP::Headers::ActionPack::WWWAuthenticate->new(
        'Digest' => (
            realm  => 'testrealm@host.com',
            qop    => "auth,auth-int",
            nonce  => "dcd98b7102dd2f0e8b11d0f600bfb0c093",
            opaque => "5ccc069c403ebaf9f0171e9517f40e41"
        )
    )
);

done_testing;