aboutsummaryrefslogtreecommitdiff
path: root/t/tests/Net/Hawk/Utils.t
blob: 126450ee08e20815d93f1901d27a115ff175cb1f (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
#!perl6 
use v6;
use Test;
use Net::Hawk::Utils;
 
subtest {
    is(parse_content_type(Str),'','undef -> empty string');
    is(parse_content_type('text/plain'),'text/plain','simple');
    is(parse_content_type('text/plain; charset=utf-8'),'text/plain','ignore options');
};
 
subtest {
    throws_like { parse_authorization_header(Str},
        Net::Hawk::Errors::UnAuthorized,
          text => 'no header';
 
    throws_like { parse_authorization_header('bad'},
        Net::Hawk::Errors::BadRequest,
          text => 'invalid header syntax';
 
    throws_like { parse_authorization_header('hawk: bad'},
        Net::Hawk::Errors::BadRequest,
          text => 'Bad header format';
 
    is_deeplyparse_authorization_header('hawk: id="1"'),
               { id => '1' },
               'ok parse');
};
 
done;