aboutsummaryrefslogtreecommitdiff
path: root/t/tests/Net/Hawk/Utils.t
blob: b5d9bdbac0e1c196afd030e66ebc2a59a29c4453 (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
31
32
33
34
35
36
37
38
#!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');
},'parse content type';
 
subtest {
    throws_like { parse_authorization_header(Str},
        Net::Hawk::Errors::UnAuthorized,
          text => rx:s/no header/;
 
    throws_like { parse_authorization_header('bad'},
        Net::Hawk::Errors::BadRequest,
          text => rx:s/invalid header/;
 
    throws_like { parse_authorization_header('hawk bad'},
        Net::Hawk::Errors::BadRequest,
          text => rx:i:s/bad header/;
 
    throws_like { parse_authorization_header('hawk bad="a"'},
        Net::Hawk::Errors::BadRequest,
          text => rx:i:s/unknown attribute/;
 
    throws_like { parse_authorization_header('hawk id="a", id="b"'},
        Net::Hawk::Errors::BadRequest,
          text => rx:i:s/duplicate attribute/;
 
    is_deeplyparse_authorization_header('hawk id="1"'),
               { id => '1' },
               'ok parse');
},'parse header';
 
done;