51a2d1120af631f91ec72300d14cb0570520d4bc
[dh-make-perl] / dev / arm / libwww-perl / libwww-perl-5.813 / t / base / headers-auth.t
1 print "1..4\n";
2
3 use HTTP::Response;
4 use HTTP::Headers::Auth;
5
6 $res = HTTP::Response->new(401);
7 $res->push_header(WWW_Authenticate => qq(Foo realm="WallyWorld", foo=bar, Bar realm="WallyWorld2"));
8 $res->push_header(WWW_Authenticate => qq(Basic Realm="WallyWorld", foo=bar, bar=baz));
9
10 print $res->as_string;
11
12 %auth = $res->www_authenticate;
13
14 print "not " unless keys(%auth) == 3;
15 print "ok 1\n";
16
17 print "not " unless $auth{basic}{realm} eq "WallyWorld" &&
18                     $auth{bar}{realm} eq "WallyWorld2";
19 print "ok 2\n";
20
21 $a = $res->www_authenticate;
22 print "not " unless $a eq 'Foo realm="WallyWorld", foo=bar, Bar realm="WallyWorld2", Basic Realm="WallyWorld", foo=bar, bar=baz';
23 print "ok 3\n";
24
25 $res->www_authenticate("Basic realm=foo1");
26 print $res->as_string;
27
28 $res->www_authenticate(Basic => {realm => foo2});
29 print $res->as_string;
30
31 $res->www_authenticate(Basic => [realm => foo3, foo=>33],
32                        Digest => {nonce=>"bar", foo=>'foo'});
33 print $res->as_string;
34
35 $_ = $res->as_string;
36
37 print "not " unless /WWW-Authenticate: Basic realm="foo3", foo=33/ &&
38                     (/WWW-Authenticate: Digest nonce=bar, foo=foo/ ||
39                      /WWW-Authenticate: Digest foo=foo, nonce=bar/);
40 print "ok 4\n";
41