File: 07callback.t

package info (click to toggle)
libauthen-simple-perl 0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 228 kB
  • sloc: perl: 1,816; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 767 bytes parent folder | download | duplicates (5)
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
#!perl

use strict;
use lib 't/lib';

use MyAdapter;
use MyCache;
use MyLog;

use Test::More tests => 7;

my $credentials  = {
    user => 'password'
};

my $adapter = MyAdapter->new(
    credentials => $credentials,
    log         => MyLog->new
);

ok( $adapter );

$adapter->callback( sub { undef } );

ok( $adapter->authenticate( 'user', 'password' ) );
like( $adapter->log->messages->[-1], qr/Successfully authenticated user 'user'/ );

$adapter->callback( sub { 1 } );

ok( $adapter->authenticate( 'user', 'password' ) );
like( $adapter->log->messages->[-1], qr/Callback returned a true value/ );

$adapter->callback( sub { 0 } );

ok( !$adapter->authenticate( 'user', 'password' ) );
like( $adapter->log->messages->[-1], qr/Callback returned a false value/ );