I'm not getting the same behaviour on my box.
I notice that you're not checking the return values of htpasswd. The method can fail, so looking at the return values might give you a clue ;-)
The following test script runs fine on my box...
#! /usr/bin/perl
use strict;
use warnings;
use Apache::Htpasswd '1.5.4';
use Test::More tests => 13;
my $TEST_FILE = "test_htpasswd.txt";
die "$TEST_FILE file already exists\n" if -e $TEST_FILE;
# setup our test fixture
{
open(FILE, '>', $TEST_FILE) or die;
close(FILE) or die;
my $pwd = new Apache::Htpasswd($TEST_FILE);
foreach (1..6) {
$pwd->htpasswd("user$_", "pass$_")
or die "failed to add user$_ " . $pwd->error . "\n";
};
};
my $pwd = new Apache::Htpasswd($TEST_FILE);
foreach my $n (1..6) {
ok($pwd->htCheckPassword("user$n", "pass$n"), "user $n added");
};
ok($pwd->htpasswd('user3', 'newpwd3', 1), "password for user3 changed"
+)
or diag "error reported was " . $pwd->error;
foreach my $n (1..6) {
my $pass = ($n==3) ? "newpwd3" : "pass$n";
ok($pwd->htCheckPassword("user$n", $pass), "user $n still valid");
};
unlink $TEST_FILE or die "could not unlink $TEST_FILE\n";
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|