summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorDustin Sallings <dustin@spy.net>2009-10-23 23:23:44 -0700
committerTrond Norbye <Trond.Norbye@sun.com>2009-10-25 21:19:25 +0100
commit3705435b522c70aa31cf5636dfa01b33e85629a3 (patch)
treecdcad0f69345402c17ef0ed753e4221ba82a934c /t
parentdd11bde873f965fc85363afd6eac39635e3a3b2c (diff)
downloadmemcached-3705435b522c70aa31cf5636dfa01b33e85629a3.tar.gz
Enforce some hard limits on SASL mechanism length.
Diffstat (limited to 't')
-rwxr-xr-xt/binary-sasl.t10
1 files changed, 7 insertions, 3 deletions
diff --git a/t/binary-sasl.t b/t/binary-sasl.t
index 4c43e94..9536ee7 100755
--- a/t/binary-sasl.t
+++ b/t/binary-sasl.t
@@ -12,7 +12,7 @@ my $supports_sasl = supports_sasl();
use Test::More;
if (supports_sasl()) {
- plan tests => 19;
+ plan tests => 20;
} else {
plan tests => 1;
eval {
@@ -161,6 +161,9 @@ system("echo testpass | saslpasswd2 -a memcached -c -p testuser");
$mc = MC::Client->new;
+# Attempt a bad auth mech.
+is ($mc->authenticate('testuser', 'testpass', "X" x 40), 0x4, "bad mech");
+
# Attempt bad authentication.
is ($mc->authenticate('testuser', 'wrongpassword'), 0x20, "bad auth");
@@ -221,9 +224,10 @@ sub new {
}
sub authenticate {
- my ($self, $user, $pass)= @_;
+ my ($self, $user, $pass, $mech)= @_;
+ $mech ||= 'PLAIN';
my $buf = sprintf("%c%s%c%s", 0, $user, 0, $pass);
- my ($status, $rv, undef) = $self->_do_command(::CMD_SASL_AUTH, "PLAIN", $buf, '');
+ my ($status, $rv, undef) = $self->_do_command(::CMD_SASL_AUTH, $mech, $buf, '');
return $status;
}
sub list_mechs {