/usr/share/php/tests/Horde_Auth/Horde/Auth/Unit/Sql/Locks.php is in php-horde-auth 2.1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | <?php
/**
* Prepare the test setup.
*/
require_once __DIR__ . '/Base.php';
/**
* @category Horde
* @package Auth
* @subpackage UnitTests
*/
class Horde_Auth_Unit_Sql_Locks extends Horde_Auth_Unit_Sql_Base
{
protected static $locksMigrator;
protected static $locks;
protected static $skip = '';
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
if (is_dir(__DIR__ .'/../../../../../../Lock/migration')) {
$lockMigrationsPath = __DIR__ .'/../../../../../../Lock/migration';
} elseif (is_dir(__DIR__ .'/../../../../../../deps/Lock/migration')) {
$lockMigrationsPath = __DIR__ .'/../../../../../../deps/Lock/migration';
// how would that work for any possible pear_dir ?
} else {
self::$skip = 'Could not determine path to Horde_Lock migration';
return;
}
self::$locksMigrator = new Horde_Db_Migration_Migrator(
self::$db,
null,//$logger,
array('migrationsPath' => $lockMigrationsPath,
'schemaTableName' => 'horde_lock_test_schema'));
self::$locksMigrator->up();
self::$locks = new Horde_Lock_Sql(array('db' => self::$db));
self::$auth = new Horde_Auth_Sql(array('db' => self::$db,
'encryption' => 'plain',
'lock_api' => self::$locks
));
}
public function setUp()
{
if (!class_exists('Horde_Db')) {
$this->markTestSkipped('The Horde_Db package is not installed!');
}
if (!class_exists('Horde_Lock')) {
$this->markTestSkipped('The Horde_Lock package is not installed!');
}
if (self::$skip) {
$this->markTestSkipped(self::$skip);
}
if (!self::$db) {
$this->markTestSkipped(self::$reason);
} else {
// portability: use DELETE because SQLite has no truncate
$sql = "DELETE FROM horde_locks";
self::$db->execute($sql);
}
}
public function testAuthenticate()
{
$this->assertTrue(self::$auth->authenticate('tux', array('password' => 'fish')));
}
public function testLockUserOnceWorks()
{
self::$auth->lockUser('konqui');
}
/**
* @expectedException Horde_Auth_Exception
*/
public function testLockUserTwiceFails()
{
self::$auth->lockUser('konqui');
self::$auth->lockUser('konqui');
}
public function testLockCapability()
{
$this->assertTrue(self::$auth->hasCapability('lock'));
}
public function testLockedUserReportsAsLocked()
{
self::$auth->lockUser('konqui');
$this->assertTrue(self::$auth->isLocked('konqui'));
}
public function testLockedUserCannotLogin()
{
self::$auth->lockUser('konqui');
$this->assertFalse(self::$auth->authenticate('konqui', array('password' => 'kde')));
}
public function testUnlockUnlockedDoesNotThrowException()
{
self::$auth->unlockUser('konqui');
self::$auth->unlockUser('konqui');
self::$auth->unlockUser('konqui');
}
}
|