Update of /cvsroot/perl-ldap/sasl/t
In directory usw-pr-cvs1:/tmp/cvs-serv24316/t
Added Files:
anon.t callback.t cram_md5.t external.t plain.t
Log Message:
Add some tests
--- NEW FILE: anon.t ---
use Authen::SASL;
@Authen::SASL::Plugins = qw(Authen::SASL::Perl);
print "1..5\n";
my $sasl = Authen::SASL->new(
mechanism => 'ANONYMOUS',
callback => {
user => 'gbarr',
pass => 'fred',
authname => 'none'
},
) or print "not ";
print "ok 1\n";
$sasl->mechanism eq 'ANONYMOUS'
or print "not ";
print "ok 2\n";
my $conn = $sasl->client_new("ldap","localhost");
$conn->mechanism eq 'ANONYMOUS' or print "not ";
print "ok 3\n";
$conn->client_start eq 'none' or print "not ";
print "ok 4\n";
$conn->client_step("xyz") eq 'none' or print "not ";
print "ok 5\n";
--- NEW FILE: callback.t ---
use Authen::SASL;
@Authen::SASL::Plugins = qw(Authen::SASL::Perl);
print "1..7\n";
my $sasl = Authen::SASL->new(
mechanism => 'PLAIN',
callback => {
user => 'gbarr',
pass => \&pass,
authname => [ \&authname, 1 ],
},
) or print "not ";
print "ok 1\n";
$sasl->mechanism eq 'PLAIN'
or print "not ";
print "ok 2\n";
my $conn = $sasl->client_new("ldap","localhost");
$conn->mechanism eq 'PLAIN' or print "not ";
print "ok 3\n";
my $test = 4;
$conn->client_start eq "gbarr\0none\0fred" or print "not ";
print "ok 6\n";
print "not " if defined $conn->client_step("xyz") ;
print "ok 7\n";
sub pass {
print "#pass\n";
print "ok ",$test++,"\n";
'fred';
}
sub authname {
print "#authname\n";
print "not " unless @_ == 2 and $_[1] == 1;
print "ok ",$test++,"\n";
'none';
}
--- NEW FILE: cram_md5.t ---
use Authen::SASL;
@Authen::SASL::Plugins = qw(Authen::SASL::Perl);
print "1..5\n";
my $sasl = Authen::SASL->new(
mechanism => 'CRAM-MD5',
callback => {
user => 'gbarr',
pass => 'fred',
authname => 'none'
},
) or print "not ";
print "ok 1\n";
$sasl->mechanism eq 'CRAM-MD5'
or print "not ";
print "ok 2\n";
my $conn = $sasl->client_new("ldap","localhost", "noplaintext noanonymous");
$conn->mechanism eq 'CRAM-MD5' or print "not ";
print "ok 3\n";
$conn->client_start eq '' or print "not ";
print "ok 4\n";
$conn->client_step("xyz") eq 'gbarr 36c931fe47f3fe9c7adbf810b3c7c4ad' or print "not ";
print "ok 5\n";
--- NEW FILE: external.t ---
use Authen::SASL;
@Authen::SASL::Plugins = qw(Authen::SASL::Perl);
print "1..5\n";
my $sasl = Authen::SASL->new(
mechanism => 'EXTERNAL',
callback => {
user => 'gbarr',
pass => 'fred',
authname => 'none'
},
) or print "not ";
print "ok 1\n";
$sasl->mechanism eq 'EXTERNAL'
or print "not ";
print "ok 2\n";
my $conn = $sasl->client_new("ldap","localhost", "noplaintext");
$conn->mechanism eq 'EXTERNAL' or print "not ";
print "ok 3\n";
$conn->client_start eq '' or print "not ";
print "ok 4\n";
$conn->client_step("xyz") eq 'gbarr' or print "not ";
print "ok 5\n";
--- NEW FILE: plain.t ---
use Authen::SASL;
@Authen::SASL::Plugins = qw(Authen::SASL::Perl);
print "1..5\n";
my $sasl = Authen::SASL->new(
mechanism => 'PLAIN',
callback => {
user => 'gbarr',
pass => 'fred',
authname => 'none'
},
) or print "not ";
print "ok 1\n";
$sasl->mechanism eq 'PLAIN'
or print "not ";
print "ok 2\n";
my $conn = $sasl->client_new("ldap","localhost");
$conn->mechanism eq 'PLAIN' or print "not ";
print "ok 3\n";
$conn->client_start eq "gbarr\0none\0fred" or print "not ";
print "ok 4\n";
print "not " if defined $conn->client_step("xyz") ;
print "ok 5\n";
|