Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Throw an exception if attempting to use authentication without SASL s…

…upport installed
  • Loading branch information...
commit bdd00c230702e5074fd3fb0a792fac4e66132beb 1 parent f093a31
@kamisama kamisama authored
View
5 lib/Cake/Cache/Engine/MemcachedEngine.php
@@ -96,6 +96,11 @@ public function init($settings = array()) {
}
if ($this->settings['login'] !== null && $this->settings['password'] !== null) {
+ if (!method_exists($this->_Memcached, 'setSaslAuthData')) {
+ throw new CacheException(
+ __d('cake_dev', 'Memcached extension is not build with SASL support')
+ );
+ }
$this->_Memcached->setSaslAuthData($this->settings['login'], $this->settings['password']);
}
}
View
27 lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php
@@ -134,6 +134,33 @@ public function testCompressionSetting() {
}
/**
+ * test using authentication without memcached installed with SASL support
+ * throw an exception
+ *
+ * @return void
+ */
+ public function testSaslAuthException() {
+ $Memcached = new TestMemcachedEngine();
+ $settings = array(
+ 'engine' => 'Memcached',
+ 'servers' => array('127.0.0.1:11211'),
+ 'persistent' => false,
+ 'login' => 'test',
+ 'password' => 'password'
+ );
+
+ $this->skipIf(
+ method_exists($Memcached->getMemcached(), 'setSaslAuthData'),
+ 'Memcached extension is installed with SASL support'
+ );
+
+ $this->setExpectedException(
+ 'CacheException', 'Memcached extension is not build with SASL support'
+ );
+ $Memcached->init($settings);
+ }
+
+/**
* testSettings method
*
* @return void
Please sign in to comment.
Something went wrong with that request. Please try again.