From d403562e3f7ac96df7cee2c1709ecd970b6c9761 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Sun, 19 Jul 2015 17:50:38 +0000 Subject: HTTP-Message-6.10 --- t/headers-auth.t | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 t/headers-auth.t (limited to 't/headers-auth.t') diff --git a/t/headers-auth.t b/t/headers-auth.t new file mode 100644 index 0000000..330d33c --- /dev/null +++ b/t/headers-auth.t @@ -0,0 +1,41 @@ +use strict; +use warnings; + +use Test::More; + +plan tests => 6; + +use HTTP::Response; +use HTTP::Headers::Auth; + +my $res = HTTP::Response->new(401); +$res->push_header(WWW_Authenticate => qq(Foo realm="WallyWorld", foo=bar, Bar realm="WallyWorld2")); +$res->push_header(WWW_Authenticate => qq(Basic Realm="WallyWorld", foo=bar, bar=baz)); + +note $res->as_string; + +my %auth = $res->www_authenticate; + +is(keys(%auth), 3); + +is($auth{basic}{realm}, "WallyWorld"); +is($auth{bar}{realm}, "WallyWorld2"); + +$a = $res->www_authenticate; +is($a, 'Foo realm="WallyWorld", foo=bar, Bar realm="WallyWorld2", Basic Realm="WallyWorld", foo=bar, bar=baz'); + +$res->www_authenticate("Basic realm=foo1"); +note $res->as_string; + +$res->www_authenticate(Basic => {realm => "foo2"}); +print $res->as_string; + +$res->www_authenticate(Basic => [realm => "foo3", foo=>33], + Digest => {nonce=>"bar", foo=>'foo'}); +note $res->as_string; + +my $string = $res->as_string; + +like($string, qr/WWW-Authenticate: Basic realm="foo3", foo=33/); +like($string, qr/WWW-Authenticate: Digest (nonce=bar, foo=foo|foo=foo, nonce=bar)/); + -- cgit v1.2.1