File: 072-digest-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 (75 lines) | stat: -rw-r--r-- 2,419 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
#!/usr/bin/perl

use strict;
use warnings;

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

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

sub test_auth {
    my $auth = shift;

    is($auth->auth_type, 'Digest', '... got the right auth type');
    is($auth->username, 'jon.dough@mobile.biz', '... got the right username');
    is($auth->realm, 'RoamingUsers@mobile.biz', '... got the right realm');


    is_deeply(
        $auth->params,
        {
            username => 'jon.dough@mobile.biz',
            realm    => 'RoamingUsers@mobile.biz',
            nonce    => "CjPk9mRqNuT25eRkajM09uTl9nM09uTl9nMz5OX25PZz==",
            uri      => "sip:home.mobile.biz",
            qop      => 'auth-int',
            nc       => '00000001',
            cnonce   => "0a4f113b",
            response => "6629fae49393a05397450978507c4ef1",
            opaque   => "5ccc069c403ebaf9f0171e9517f40e41"
        },
        '... got the right params list'
    );

    is(
        $auth->as_string,
        q{Digest username="jon.dough@mobile.biz", realm="RoamingUsers@mobile.biz", nonce="CjPk9mRqNuT25eRkajM09uTl9nM09uTl9nMz5OX25PZz==", uri="sip:home.mobile.biz", qop="auth-int", nc="00000001", cnonce="0a4f113b", response="6629fae49393a05397450978507c4ef1", opaque="5ccc069c403ebaf9f0171e9517f40e41"},
          '... got the right stringification'
    );
}

test_auth(
    HTTP::Headers::ActionPack::Authorization::Digest->new_from_string(
        q{Digest
          username="jon.dough@mobile.biz",
          realm="RoamingUsers@mobile.biz",
          nonce="CjPk9mRqNuT25eRkajM09uTl9nM09uTl9nMz5OX25PZz==",
          uri="sip:home.mobile.biz",
          qop=auth-int,
          nc=00000001,
          cnonce="0a4f113b",
          response="6629fae49393a05397450978507c4ef1",
          opaque="5ccc069c403ebaf9f0171e9517f40e41"}
    )
);

test_auth(
    HTTP::Headers::ActionPack::Authorization::Digest->new(
        'Digest' => (
            username => 'jon.dough@mobile.biz',
            realm    => 'RoamingUsers@mobile.biz',
            nonce    => "CjPk9mRqNuT25eRkajM09uTl9nM09uTl9nMz5OX25PZz==",
            uri      => "sip:home.mobile.biz",
            qop      => 'auth-int',
            nc       => '00000001',
            cnonce   => "0a4f113b",
            response => "6629fae49393a05397450978507c4ef1",
            opaque   => "5ccc069c403ebaf9f0171e9517f40e41"
        )
    )
);

done_testing;