ported Authentication::Store::Htpasswd to Authen::Htpasswd
[catagits/Catalyst-Authentication-Store-Htpasswd.git] / t / backend.t
CommitLineData
e8a7c384 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More 'no_plan';
7use Path::Class;
8
9use File::Temp qw/tempfile/;
10
11my $m; BEGIN { use_ok($m = "Catalyst::Plugin::Authentication::Store::Htpasswd::Backend") }
12
13(undef, my $tmp) = tempfile();
14
3e0bbcff 15my $passwd = Authen::Htpasswd->new($tmp);
e8a7c384 16
3e0bbcff 17$passwd->add_user("user", "s3cr3t");
e8a7c384 18
19
20can_ok($m, "new");
21isa_ok(my $o = $m->new( $passwd ), $m);
22
23can_ok($m, "file");
3e0bbcff 24isa_ok( $o->file, "Authen::Htpasswd");
e8a7c384 25
26
27can_ok( $m, "user_supports");
28ok( $m->user_supports(qw/password self_check/), "user_supports self check" );
29
30can_ok($m, "get_user");
31isa_ok( my $u = $o->get_user("user"), "Catalyst::Plugin::Authentication::Store::Htpasswd::User");
32isa_ok( $u, "Catalyst::Plugin::Authentication::User");
33
34can_ok( $u, "supports");
35ok( $u->supports(qw/password self_check/), "htpasswd users check their own passwords");
36
37can_ok( $u, "check_password");
38ok( $u->check_password( "s3cr3t" ), "password is s3cr3t");
39
40