File: backend.t

package info (click to toggle)
libcatalyst-authentication-store-htpasswd-perl 1.006-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 332 kB
  • sloc: perl: 451; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,219 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 19;

use File::Temp qw/tempfile/;

my $m; BEGIN { use_ok($m = "Catalyst::Authentication::Store::Htpasswd") }

(undef, my $tmp) = tempfile();

my $passwd = Authen::Htpasswd->new($tmp);

$passwd->add_user("user", "s3cr3t");

can_ok($m, "new");
isa_ok(my $o = $m->new( { file => $passwd } ), $m);

can_ok($m, "file");
isa_ok( $o->file, "Authen::Htpasswd");

can_ok( $m, "user_supports");
ok( $m->user_supports(qw/password self_check/), "user_supports self check" );

can_ok($m, "find_user");
isa_ok( my $u = $o->find_user({ username => "user"}), "Catalyst::Authentication::Store::Htpasswd::User");
isa_ok( $u, "Catalyst::Authentication::User");

can_ok( $u, "supports");
ok( $u->supports(qw/password self_check/), "htpasswd users check their own passwords");

can_ok( $u, "check_password");
ok( $u->check_password( "s3cr3t" ), "password is s3cr3t");

ok( $m->user_supports(qw/session/), "user_supports session");

is( $u->_store, $o, "can get store");

can_ok( $m, "from_session" );
can_ok( $u, "for_session" );

my $recovered = $u->_store->from_session( undef, $u->for_session );

is( $recovered->username, $u->username, "recovery from session works");