ported Authentication::Store::Htpasswd to Authen::Htpasswd
[catagits/Catalyst-Authentication-Store-Htpasswd.git] / t / backend_md5.t
CommitLineData
e517ed3d 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
7
8BEGIN {
9 eval { require Crypt::PasswdMD5 };
10 plan skip_all => "This test requires Crypt::PasswdMD5 to be installed" if $@;
11 plan tests => 12;
12}
13
14use Path::Class;
15
16use File::Temp qw/tempfile/;
17
18my $m; BEGIN { use_ok($m = "Catalyst::Plugin::Authentication::Store::Htpasswd::Backend") }
19
20(undef, my $tmp) = tempfile();
21
3e0bbcff 22my $passwd = Authen::Htpasswd->new($tmp, { encrypt_hash => 'md5' });
e517ed3d 23
3e0bbcff 24$passwd->add_user("user", "s3cr3t");
e517ed3d 25
26
27can_ok($m, "new");
28isa_ok(my $o = $m->new( $passwd ), $m);
29
30can_ok($m, "file");
3e0bbcff 31isa_ok( $o->file, "Authen::Htpasswd");
e517ed3d 32
33
34can_ok( $m, "user_supports");
35ok( $m->user_supports(qw/password self_check/), "user_supports self check" );
36
37can_ok($m, "get_user");
38isa_ok( my $u = $o->get_user("user"), "Catalyst::Plugin::Authentication::Store::Htpasswd::User");
39isa_ok( $u, "Catalyst::Plugin::Authentication::User");
40
41can_ok( $u, "check_password");
42ok( $u->check_password( "s3cr3t" ), "password is s3cr3t");
43
44
45