Skip to content
Browse files

Made Authen::SASL really optional

git-svn-id: http://code.sixapart.com/svn/djabberd/trunk@854 43dd9337-660f-0410-bd32-e7601923a1a1
  • Loading branch information...
1 parent ec48128 commit 11f062a619709d87ffd75879aec40c1f39f34956 @yannk yannk committed Feb 11, 2009
Showing with 47 additions and 25 deletions.
  1. +0 −1 Makefile.PL
  2. +23 −17 t/features-hook.t
  3. +13 −5 t/lib/djabberd-test.pl
  4. +11 −2 t/sasl-login.t
View
1 Makefile.PL
@@ -14,7 +14,6 @@ WriteMakefile(
'Net::SSLeay' => 0,
'Log::Log4perl' => 0,
'Digest::HMAC_SHA1' => 0,
- 'Authen::SASL' => 2.13
},
clean => { FILES => 't/log/*' },
AUTHOR => 'Brad Fitzpatrick <brad@danga.com>',
View
40 t/features-hook.t
@@ -4,6 +4,9 @@ use Test::More tests => 11;
use lib 't/lib';
require 'djabberd-test.pl';
+my $HAS_SASL;
+eval "use Authen::SASL 2.13";
+$HAS_SASL = 1 unless $@;
sub connect_and_get_features{
my $client = shift;
@@ -53,23 +56,26 @@ sub connect_and_get_features{
}
$server->kill;
- $server = Test::DJabberd::Server->new(id => 1);
- $server->start( ); # by default we have SASL plugin enabled
- my $client = Test::DJabberd::Client->new(server => $server, name => "client");
- {
- my $features = connect_and_get_features($client);
-
- like($features, qr{^<features xmlns='http://etherx.jabber.org/streams'>.*</features>$});
- like($features, qr{<auth xmlns='http://jabber.org/features/iq-auth'/>});
- like($features, qr{<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>.*</mechanisms>});
- like($features, qr{<optional/>}, "our test setup makes sasl optional, bc of history of djabberd");
- for my $mech (qw/PLAIN DIGEST-MD5 LOGIN/) {
- like($features, qr{<mechanism>$mech</mechanism>}, "supports $mech");
- }
-
- like($features, qr{<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>.*</mechanisms>});
- }
- $server->kill;
+ SKIP: {
+ skip "These tests require SASL", 8 unless $HAS_SASL;
+ $server = Test::DJabberd::Server->new(id => 1);
+ $server->start( ); # by default we have SASL plugin enabled
+ my $client = Test::DJabberd::Client->new(server => $server, name => "client");
+ {
+ my $features = connect_and_get_features($client);
+
+ like($features, qr{^<features xmlns='http://etherx.jabber.org/streams'>.*</features>$});
+ like($features, qr{<auth xmlns='http://jabber.org/features/iq-auth'/>});
+ like($features, qr{<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>.*</mechanisms>});
+ like($features, qr{<optional/>}, "our test setup makes sasl optional, bc of history of djabberd");
+ for my $mech (qw/PLAIN DIGEST-MD5 LOGIN/) {
+ like($features, qr{<mechanism>$mech</mechanism>}, "supports $mech");
+ }
+
+ like($features, qr{<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>.*</mechanisms>});
+ }
+ $server->kill;
+ };
}
View
18 t/lib/djabberd-test.pl
@@ -10,9 +10,15 @@ BEGIN
use DJabberd::TestSAXHandler;
use DJabberd::RosterStorage::InMemoryOnly;
use DJabberd::Util;
-use DJabberd::SASL::AuthenSASL;
use IO::Socket::UNIX;
+my $HAS_SASL;
+eval "use Authen::SASL 2.13";
+unless ($@) {
+ require DJabberd::SASL::AuthenSASL;
+ $HAS_SASL = 1;
+}
+
sub once_logged_in {
my $cb = shift;
my $sasl = shift;
@@ -249,6 +255,11 @@ sub roster {
sub standard_plugins {
my $self = shift;
+ my @sasl;
+ @sasl = ( DJabberd::SASL::AuthenSASL->new(
+ mechanisms => "LOGIN PLAIN DIGEST-MD5",
+ optional => "yes",
+ )) if $HAS_SASL;
return [
DJabberd::Authen::AllowedUsers->new(policy => "deny",
allowedusers => [qw(partya partyb)]),
@@ -257,10 +268,7 @@ sub standard_plugins {
($ENV{T_MUC_ENABLE} ? (DJabberd::Plugin::MUC->new(subdomain => 'conference')) : ()),
DJabberd::Delivery::Local->new,
DJabberd::Delivery::S2S->new,
- DJabberd::SASL::AuthenSASL->new(
- mechanisms => "LOGIN PLAIN DIGEST-MD5",
- optional => "yes",
- ),
+ @sasl
];
}
View
13 t/sasl-login.t
@@ -1,12 +1,21 @@
#!/usr/bin/perl
use strict;
use warnings;
-use Test::More tests => 46;
+use Test::More;
use lib 't/lib';
require 'djabberd-test.pl';
-use Authen::SASL 'Perl';
+BEGIN {
+ eval "use Authen::SASL 2.13";
+ if ($@) {
+ plan skip_all => 'Tests require Authen::SASL 2.13+';
+ }
+ else {
+ plan tests => 46;
+ eval "use Authen::SASL 'Perl';";
+ }
+}
my $login_and_be = sub {
my ($pa, $pb, $sasl, $res) = @_;

0 comments on commit 11f062a

Please sign in to comment.
Something went wrong with that request. Please try again.