Permalink
Browse files

Makes sure that user callbacks are called

Even for dumb mechanisms like LOGIN and PLAIN
  • Loading branch information...
1 parent 7ead99c commit c6462fde77d09652fc0836044241fa4f8f5c9375 @yannk yannk committed with Jun 1, 2010
Showing with 24 additions and 12 deletions.
  1. +2 −2 lib/Authen/SASL/Perl/LOGIN.pm
  2. +1 −1 lib/Authen/SASL/Perl/PLAIN.pm
  3. +14 −6 t/server/login.t
  4. +7 −3 t/server/plain.t
@@ -97,11 +97,11 @@ sub server_step {
my $result = shift;
unless ($result) {
$self->set_error($error);
- $user_cb->();
}
else {
- $self->set_success;
+ $self->set_success;
}
+ $user_cb->();
};
$checkpass->($self => $answers => $cb );
return;
@@ -61,11 +61,11 @@ sub server_start {
my $result = shift;
unless ($result) {
$self->set_error($error);
- $user_cb->();
}
else {
$self->set_success;
}
+ $user_cb->();
};
$checkpass->($self => { %parts } => $cb );
return;
View
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 20;
+use Test::More tests => 32;
use Authen::SASL qw(Perl);
use_ok('Authen::SASL::Perl::LOGIN');
@@ -40,9 +40,13 @@ sub is_failure {
my $creds = shift;
my @steps = @_;
## wouldn't really work in an async environemnt
- $server->server_start("");
+ my $cb;
+ $server->server_start("", sub { $cb = 1 });
+ ok $cb, "callback called";
for (@steps) {
- $server->server_step($_);
+ $cb = 0;
+ $server->server_step($_, sub { $cb = 1 });
+ ok $cb, "callback called";
}
ok !$server->is_success, "failure";
ok ($server->need_step or $server->error), "no success means that";
@@ -68,7 +72,11 @@ sub is_failure {
ok($ssasl = Authen::SASL->new( %params ), "new");
$server = $ssasl->server_new("ldap","localhost");
-$server->server_start("");
-$server->server_step("foo");
-$server->server_step("bar");
+my $cb;
+$server->server_start("", sub { $cb = 1 });
+ok $cb, "callback called"; $cb = 0;
+$server->server_step("foo", sub { $cb = 1 });
+ok $cb, "callback called"; $cb = 0;
+$server->server_step("bar", sub { $cb = 1 });
+ok $cb, "callback called";
ok $server->is_success, "success";
View
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 47;
+use Test::More tests => 67;
use Authen::SASL qw(Perl);
use_ok('Authen::SASL::Perl::PLAIN');
@@ -67,7 +67,9 @@ for my $authname ('', 'none') {
is_failure("$authname\0yann\0\0maelys", "double null");
is_failure("$authname\0yann\0maelys\0trailing", "trailing");
- $server->server_start("$authname\0yann\0maelys");
+ my $cb;
+ $server->server_start("$authname\0yann\0maelys", sub { $cb = 1 });
+ ok $cb, "callback called";
ok $server->is_success, "success finally";
}
@@ -97,7 +99,9 @@ ok $server->is_success, "success";
sub is_failure {
my $creds = shift;
my $msg = shift;
- $server->server_start($creds);
+ my $cb;
+ $server->server_start($creds, sub { $cb = 1 });
+ ok $cb, 'callback called';
ok !$server->is_success, $msg || "failure";
my $error = $server->error || "";
like $error, qr/match/i, "failure";

0 comments on commit c6462fd

Please sign in to comment.