File: callback.t

package info (click to toggle)
libauthen-sasl-perl 2.1900-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 328 kB
  • sloc: perl: 2,249; makefile: 7
file content (38 lines) | stat: -rw-r--r-- 662 bytes parent folder | download | duplicates (8)
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
#!perl

use Test::More tests => 7;

use Authen::SASL qw(Perl);

my $sasl = Authen::SASL->new(
  mechanism => 'PLAIN',
  callback => {
    user => 'gbarr',
    pass => \&cb_pass,
    authname => [ \&cb_authname, 1 ],
  },
);
ok($sasl, 'new');

is($sasl->mechanism,	'PLAIN',	'sasl mechanism');

my $conn = $sasl->client_new("ldap","localhost");

is($conn->mechanism,	'PLAIN',	'conn mechanism');

my $test = 4;

is($conn->client_start,	"none\0gbarr\0fred", "client_start");

is($conn->client_step("xyz"), undef, "client_step");

sub cb_pass {
  ok(1,'pass callback');
  'fred';
}

sub cb_authname {
  ok((@_ == 2 and $_[1] == 1), 'authname callback');
  'none';
}