2017-02-18 00:22:50 +00:00
|
|
|
<?php
|
2017-11-17 01:23:18 +00:00
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
2017-02-18 00:22:50 +00:00
|
|
|
declare(strict_types=1);
|
2017-03-28 04:12:12 +00:00
|
|
|
namespace JKingWeb\Arsse\Test\User;
|
2017-08-29 14:50:31 +00:00
|
|
|
|
2017-03-28 04:12:12 +00:00
|
|
|
use JKingWeb\Arsse\User\Driver;
|
2017-02-18 00:22:50 +00:00
|
|
|
|
2017-02-26 17:09:44 +00:00
|
|
|
class DriverInternalMock extends Database implements Driver {
|
2017-02-27 16:44:20 +00:00
|
|
|
public $db = [];
|
2017-02-18 00:22:50 +00:00
|
|
|
protected $functions = [
|
|
|
|
"auth" => Driver::FUNC_INTERNAL,
|
|
|
|
"userList" => Driver::FUNC_INTERNAL,
|
|
|
|
"userExists" => Driver::FUNC_INTERNAL,
|
|
|
|
"userAdd" => Driver::FUNC_INTERNAL,
|
|
|
|
"userRemove" => Driver::FUNC_INTERNAL,
|
|
|
|
"userPasswordSet" => Driver::FUNC_INTERNAL,
|
|
|
|
"userPropertiesGet" => Driver::FUNC_INTERNAL,
|
|
|
|
"userPropertiesSet" => Driver::FUNC_INTERNAL,
|
|
|
|
"userRightsGet" => Driver::FUNC_INTERNAL,
|
|
|
|
"userRightsSet" => Driver::FUNC_INTERNAL,
|
|
|
|
];
|
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public static function driverName(): string {
|
2017-02-18 00:22:50 +00:00
|
|
|
return "Mock Internal Driver";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function driverFunctions(string $function = null) {
|
2017-08-29 14:50:31 +00:00
|
|
|
if ($function===null) {
|
|
|
|
return $this->functions;
|
|
|
|
}
|
|
|
|
if (array_key_exists($function, $this->functions)) {
|
2017-02-18 00:22:50 +00:00
|
|
|
return $this->functions[$function];
|
|
|
|
} else {
|
|
|
|
return Driver::FUNC_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-28 22:50:00 +00:00
|
|
|
public function __construct() {
|
2017-02-18 00:22:50 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public function auth(string $user, string $password): bool {
|
|
|
|
if (!$this->userExists($user)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if ($password==="" && $this->db[$user]['password']==="") {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (password_verify($password, $this->db[$user]['password'])) {
|
|
|
|
return true;
|
|
|
|
}
|
2017-02-19 05:22:16 +00:00
|
|
|
return false;
|
2017-02-18 00:22:50 +00:00
|
|
|
}
|
2017-08-29 14:50:31 +00:00
|
|
|
}
|