mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Throw an exception if attempting to use authentication without SASL support installed
This commit is contained in:
parent
f093a31740
commit
bdd00c2307
2 changed files with 32 additions and 0 deletions
|
@ -96,6 +96,11 @@ class MemcachedEngine extends CacheEngine {
|
|||
}
|
||||
|
||||
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']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,6 +133,33 @@ class MemcachedEngineTest extends CakeTestCase {
|
|||
$this->assertTrue($MemcachedCompressed->getMemcached()->getOption(Memcached::OPT_COMPRESSION));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue