BUG: t/base/headers-auth.t assumes an ordering of hash keys
Albert Dvornik (bert@genscan.com)
02 Oct 1998 13:21:18 -0400
[Sorry if this has already been reported, but I glanced over the
HyperMail archive and didn't come up with anything relevant.]
I've just installed libwww-perl-5.36 with Perl 5.005_52, and noticed a
small problem during `make test'.
The base/headers-auth test seems to contain a minor bug. After
calling www_authenticate with a hash ref containing the authentication
data, it checks the as_string value to make sure it matches what it
expects. However, it fails to account for the fact that the keys in a
hash don't have a well-defined ordering.
If you believe that the header values should be deterministically
ordered (within each header), you should impose an ordering on the
hash keys by replacing code like
@param = %$p;
by something along the lines of
@param = map ($_, $p{$_}), sort keys %$p;
(The particular example I'm referring to is from HTTP/Headers/Auth.pm,
but there may well be similar fragments elsewhere.)
If you believe (as I do) that the random ordering is fine, then the
test should be fixed by the patch below or a reasonable facsimile.
--Albert Dvornik
<bert@genscan.com>
--- t/base/headers-auth.t.orig Fri Oct 2 13:03:03 1998
+++ t/base/headers-auth.t Fri Oct 2 13:17:25 1998
@@ -35,6 +35,7 @@
$_ = $res->as_string;
print "not " unless /WWW-Authenticate: Basic realm="foo3", foo=33/ &&
- /WWW-Authenticate: Digest nonce=bar, foo=foo/;
+ (/WWW-Authenticate: Digest nonce=bar, foo=foo/ ||
+ /WWW-Authenticate: Digest foo=foo, nonce=bar/);
print "ok 4\n";