MOON
Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4
System: Linux vps.panamaemb.org.sg 3.10.0-1160.80.1.vz7.191.4 #1 SMP Thu Dec 15 20:31:06 MSK 2022 x86_64
User: panama (500)
PHP: 5.2.17
Disabled: NONE
Upload Files
File: //installd/perl588installer/libwww-perl-5.823/t/base/headers-auth.t
#!perl -w

use strict;
use Test;

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));

print $res->as_string;

my %auth = $res->www_authenticate;

ok(keys(%auth), 3);

ok($auth{basic}{realm}, "WallyWorld");
ok($auth{bar}{realm}, "WallyWorld2");

$a = $res->www_authenticate;
ok($a, 'Foo realm="WallyWorld", foo=bar, Bar realm="WallyWorld2", Basic Realm="WallyWorld", foo=bar, bar=baz');

$res->www_authenticate("Basic realm=foo1");
print $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'});
print $res->as_string;

$_ = $res->as_string;

ok(/WWW-Authenticate: Basic realm="foo3", foo=33/);
ok(/WWW-Authenticate: Digest nonce=bar, foo=foo/ ||
   /WWW-Authenticate: Digest foo=foo, nonce=bar/);