Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ
2022-04-15 08:15:32 +02:00
parent 98768cfb57
commit 751dc7ea2a
15 changed files with 185 additions and 194 deletions

View File

@@ -8,19 +8,15 @@ use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Notification\IManager;
use OCP\User\Events;
class Application extends App implements IBootstrap { class Application extends App implements IBootstrap {
public function __construct() {
parent::__construct('user_external');
}
public function __construct() { public function register(IRegistrationContext $context): void {
parent::__construct('user_external'); }
}
public function register(IRegistrationContext $context): void { public function boot(IBootContext $context): void {
} }
}
public function boot(IBootContext $context): void {
}
}

View File

@@ -21,7 +21,7 @@ namespace OCA\UserExternal;
* @license http://www.gnu.org/licenses/agpl AGPL * @license http://www.gnu.org/licenses/agpl AGPL
* @link http://github.com/owncloud/apps * @link http://github.com/owncloud/apps
*/ */
abstract class Base extends \OC\User\Backend{ abstract class Base extends \OC\User\Backend {
protected $backend = ''; protected $backend = '';
/** /**
@@ -80,7 +80,6 @@ abstract class Base extends \OC\User\Backend{
* @return array with all displayNames (value) and the corresponding uids (key) * @return array with all displayNames (value) and the corresponding uids (key)
*/ */
public function getDisplayNames($search = '', $limit = null, $offset = null) { public function getDisplayNames($search = '', $limit = null, $offset = null) {
$connection = \OC::$server->getDatabaseConnection(); $connection = \OC::$server->getDatabaseConnection();
$query = $connection->getQueryBuilder(); $query = $connection->getQueryBuilder();
$query->select('uid', 'displayname') $query->select('uid', 'displayname')
@@ -106,10 +105,10 @@ abstract class Base extends \OC\User\Backend{
} }
/** /**
* Get a list of all users * Get a list of all users
* *
* @return array with all uids * @return array with all uids
*/ */
public function getUsers($search = '', $limit = null, $offset = null) { public function getUsers($search = '', $limit = null, $offset = null) {
$connection = \OC::$server->getDatabaseConnection(); $connection = \OC::$server->getDatabaseConnection();
$query = $connection->getQueryBuilder(); $query = $connection->getQueryBuilder();
@@ -231,5 +230,4 @@ abstract class Base extends \OC\User\Backend{
return $users > 0; return $users > 0;
} }
} }

View File

@@ -9,12 +9,11 @@
namespace OCA\UserExternal; namespace OCA\UserExternal;
class BasicAuth extends Base { class BasicAuth extends Base {
private $authUrl; private $authUrl;
public function __construct($authUrl) { public function __construct($authUrl) {
parent::__construct($authUrl); parent::__construct($authUrl);
$this->authUrl =$authUrl; $this->authUrl = $authUrl;
} }
/** /**
@@ -31,13 +30,13 @@ class BasicAuth extends Base {
* URL is indeed authenticating or not... * URL is indeed authenticating or not...
*/ */
$context = stream_context_create(array( $context = stream_context_create(array(
'http' => array( 'http' => array(
'method' => "GET", 'method' => "GET",
'follow_location' => 0 'follow_location' => 0
)) ))
); );
$canary = get_headers($this->authUrl, 1, $context); $canary = get_headers($this->authUrl, 1, $context);
if(!$canary) { if (!$canary) {
\OC::$server->getLogger()->error( \OC::$server->getLogger()->error(
'ERROR: Not possible to connect to BasicAuth Url: '.$this->authUrl, 'ERROR: Not possible to connect to BasicAuth Url: '.$this->authUrl,
['app' => 'user_external'] ['app' => 'user_external']
@@ -53,17 +52,17 @@ class BasicAuth extends Base {
} }
$context = stream_context_create(array( $context = stream_context_create(array(
'http' => array( 'http' => array(
'method' => "GET", 'method' => "GET",
'header' => "authorization: Basic " . base64_encode("$uid:$password"), 'header' => "authorization: Basic " . base64_encode("$uid:$password"),
'follow_location' => 0 'follow_location' => 0
)) ))
); );
$headers = get_headers($this->authUrl, 1, $context); $headers = get_headers($this->authUrl, 1, $context);
if(!$headers) { if (!$headers) {
\OC::$server->getLogger()->error( \OC::$server->getLogger()->error(
'ERROR: Not possible to connect to BasicAuth Url: '.$this->authUrl, 'ERROR: Not possible to connect to BasicAuth Url: '.$this->authUrl,
['app' => 'user_external'] ['app' => 'user_external']
); );
return false; return false;
@@ -84,7 +83,7 @@ class BasicAuth extends Base {
return $uid; return $uid;
case "3": case "3":
\OC::$server->getLogger()->error( \OC::$server->getLogger()->error(
'ERROR: Too many redirects from BasicAuth Url: '.$this->authUrl, 'ERROR: Too many redirects from BasicAuth Url: '.$this->authUrl,
['app' => 'user_external'] ['app' => 'user_external']
); );
return false; return false;

View File

@@ -17,7 +17,7 @@ namespace OCA\UserExternal;
* @license http://www.gnu.org/licenses/agpl AGPL * @license http://www.gnu.org/licenses/agpl AGPL
* @link http://github.com/owncloud/apps * @link http://github.com/owncloud/apps
*/ */
class FTP extends Base{ class FTP extends Base {
private $host; private $host;
private $secure; private $secure;
private $protocol; private $protocol;
@@ -28,12 +28,12 @@ class FTP extends Base{
* @param string $host Hostname or IP of FTP server * @param string $host Hostname or IP of FTP server
* @param boolean $secure TRUE to enable SSL * @param boolean $secure TRUE to enable SSL
*/ */
public function __construct($host,$secure=false) { public function __construct($host, $secure = false) {
$this->host=$host; $this->host = $host;
$this->secure=$secure; $this->secure = $secure;
$this->protocol='ftp'; $this->protocol = 'ftp';
if($this->secure) { if ($this->secure) {
$this->protocol.='s'; $this->protocol .= 's';
} }
parent::__construct($this->protocol . '://' . $this->host); parent::__construct($this->protocol . '://' . $this->host);
} }
@@ -56,11 +56,11 @@ class FTP extends Base{
} }
// opendir handles the as %-encoded string, but this is not true for usernames and passwords, encode them before passing them // opendir handles the as %-encoded string, but this is not true for usernames and passwords, encode them before passing them
$url = sprintf('%s://%s:%s@%s/', $this->protocol, urlencode($uid), urlencode($password), $this->host); $url = sprintf('%s://%s:%s@%s/', $this->protocol, urlencode($uid), urlencode($password), $this->host);
$result=@opendir($url); $result = @opendir($url);
if(is_resource($result)) { if (is_resource($result)) {
$this->storeUser($uid); $this->storeUser($uid);
return $uid; return $uid;
}else{ } else {
return false; return false;
} }
} }

View File

@@ -9,7 +9,6 @@
*/ */
namespace OCA\UserExternal; namespace OCA\UserExternal;
/** /**
* User authentication against an IMAP mail server * User authentication against an IMAP mail server
* *
@@ -59,14 +58,14 @@ class IMAP extends Base {
// Replace escaped @ symbol in uid (which is a mail address) // Replace escaped @ symbol in uid (which is a mail address)
// but only if there is no @ symbol and if there is a %40 inside the uid // but only if there is no @ symbol and if there is a %40 inside the uid
if (!(strpos($uid, '@') !== false) && (strpos($uid, '%40') !== false)) { if (!(strpos($uid, '@') !== false) && (strpos($uid, '%40') !== false)) {
$uid = str_replace("%40","@",$uid); $uid = str_replace("%40", "@", $uid);
} }
$pieces = explode('@', $uid); $pieces = explode('@', $uid);
if ($this->domain !== '') { if ($this->domain !== '') {
if (count($pieces) === 1) { if (count($pieces) === 1) {
$username = $uid . '@' . $this->domain; $username = $uid . '@' . $this->domain;
} else if(count($pieces) === 2 && $pieces[1] === $this->domain) { } elseif (count($pieces) === 2 && $pieces[1] === $this->domain) {
$username = $uid; $username = $uid;
if ($this->stripeDomain) { if ($this->stripeDomain) {
$uid = $pieces[0]; $uid = $pieces[0];
@@ -80,11 +79,11 @@ class IMAP extends Base {
} }
} else { } else {
$username = $uid; $username = $uid;
} }
$groups = []; $groups = [];
if ($this->groupDomain && $pieces[1]) { if ($this->groupDomain && $pieces[1]) {
$groups[] = $pieces[1]; $groups[] = $pieces[1];
} }
$protocol = ($this->sslmode === "ssl") ? "imaps" : "imap"; $protocol = ($this->sslmode === "ssl") ? "imaps" : "imap";
@@ -101,7 +100,7 @@ class IMAP extends Base {
$canconnect = curl_exec($ch); $canconnect = curl_exec($ch);
if($canconnect) { if ($canconnect) {
curl_close($ch); curl_close($ch);
$uid = mb_strtolower($uid); $uid = mb_strtolower($uid);
$this->storeUser($uid, $groups); $this->storeUser($uid, $groups);

View File

@@ -16,11 +16,11 @@ namespace OCA\UserExternal;
* @license http://www.gnu.org/licenses/agpl AGPL * @license http://www.gnu.org/licenses/agpl AGPL
* @link http://github.com/owncloud/apps * @link http://github.com/owncloud/apps
*/ */
class SMB extends Base{ class SMB extends Base {
private $host; private $host;
const SMBCLIENT = 'smbclient -L'; public const SMBCLIENT = 'smbclient -L';
const LOGINERROR = 'NT_STATUS_LOGON_FAILURE'; public const LOGINERROR = 'NT_STATUS_LOGON_FAILURE';
/** /**
* Create new samba authentication provider * Create new samba authentication provider
@@ -29,7 +29,7 @@ class SMB extends Base{
*/ */
public function __construct($host) { public function __construct($host) {
parent::__construct($host); parent::__construct($host);
$this->host=$host; $this->host = $host;
} }
/** /**
@@ -48,13 +48,13 @@ class SMB extends Base{
['app' => 'user_external'] ['app' => 'user_external']
); );
return false; return false;
} else if (strpos($lastline, self::LOGINERROR) !== false) { } elseif (strpos($lastline, self::LOGINERROR) !== false) {
//normal login error //normal login error
return false; return false;
} else if (strpos($lastline, 'NT_STATUS_BAD_NETWORK_NAME') !== false) { } elseif (strpos($lastline, 'NT_STATUS_BAD_NETWORK_NAME') !== false) {
//login on minor error //login on minor error
goto login; goto login;
} else if ($retval !== 0) { } elseif ($retval !== 0) {
//some other error //some other error
\OC::$server->getLogger()->error( \OC::$server->getLogger()->error(
'ERROR: smbclient error: ' . trim($lastline), 'ERROR: smbclient error: ' . trim($lastline),
@@ -78,13 +78,13 @@ class SMB extends Base{
public function checkPassword($uid, $password) { public function checkPassword($uid, $password) {
// Check with an invalid password, if the user authenticates then fail // Check with an invalid password, if the user authenticates then fail
$attemptWithInvalidPassword = $this->tryAuthentication($uid, base64_encode($password)); $attemptWithInvalidPassword = $this->tryAuthentication($uid, base64_encode($password));
if(is_string($attemptWithInvalidPassword)) { if (is_string($attemptWithInvalidPassword)) {
return false; return false;
} }
// Check with valid password // Check with valid password
$attemptWithValidPassword = $this->tryAuthentication($uid, $password); $attemptWithValidPassword = $this->tryAuthentication($uid, $password);
if(is_string($attemptWithValidPassword)) { if (is_string($attemptWithValidPassword)) {
$this->storeUser($uid); $this->storeUser($uid);
return $uid; return $uid;
} }

View File

@@ -23,10 +23,10 @@ class SSH extends Base {
private $port; private $port;
/** /**
* Create a new SSH authentication provider * Create a new SSH authentication provider
* *
* @param string $host Hostname or IP address of SSH servr * @param string $host Hostname or IP address of SSH servr
*/ */
public function __construct($host, $port = 22) { public function __construct($host, $port = 22) {
parent::__construct($host); parent::__construct($host);
$this->host = $host; $this->host = $host;
@@ -34,14 +34,14 @@ class SSH extends Base {
} }
/** /**
* Check if the password is correct without logging in * Check if the password is correct without logging in
* Requires the php-ssh2 pecl extension * Requires the php-ssh2 pecl extension
* *
* @param string $uid The username * @param string $uid The username
* @param string $password The password * @param string $password The password
* *
* @return true/false * @return true/false
*/ */
public function checkPassword($uid, $password) { public function checkPassword($uid, $password) {
if (!extension_loaded('ssh2')) { if (!extension_loaded('ssh2')) {
\OC::$server->getLogger()->error( \OC::$server->getLogger()->error(

View File

@@ -9,12 +9,11 @@
namespace OCA\UserExternal; namespace OCA\UserExternal;
class WebDavAuth extends Base { class WebDavAuth extends Base {
private $webDavAuthUrl; private $webDavAuthUrl;
public function __construct($webDavAuthUrl) { public function __construct($webDavAuthUrl) {
parent::__construct($webDavAuthUrl); parent::__construct($webDavAuthUrl);
$this->webDavAuthUrl =$webDavAuthUrl; $this->webDavAuthUrl = $webDavAuthUrl;
} }
/** /**
@@ -27,21 +26,20 @@ class WebDavAuth extends Base {
*/ */
public function checkPassword($uid, $password) { public function checkPassword($uid, $password) {
$arr = explode('://', $this->webDavAuthUrl, 2); $arr = explode('://', $this->webDavAuthUrl, 2);
if( ! isset($arr) OR count($arr) !== 2) { if (! isset($arr) or count($arr) !== 2) {
\OC::$server->getLogger()->error('ERROR: Invalid WebdavUrl: "'.$this->webDavAuthUrl.'" ', ['app' => 'user_external']); \OC::$server->getLogger()->error('ERROR: Invalid WebdavUrl: "'.$this->webDavAuthUrl.'" ', ['app' => 'user_external']);
return false; return false;
} }
list($protocol, $path) = $arr; list($protocol, $path) = $arr;
$url= $protocol.'://'.urlencode($uid).':'.urlencode($password).'@'.$path; $url = $protocol.'://'.urlencode($uid).':'.urlencode($password).'@'.$path;
$headers = get_headers($url); $headers = get_headers($url);
if($headers === false) { if ($headers === false) {
\OC::$server->getLogger()->error('ERROR: Not possible to connect to WebDAV Url: "'.$protocol.'://'.$path.'" ', ['app' => 'user_external']); \OC::$server->getLogger()->error('ERROR: Not possible to connect to WebDAV Url: "'.$protocol.'://'.$path.'" ', ['app' => 'user_external']);
return false; return false;
} }
$returnCode= substr($headers[0], 9, 3); $returnCode = substr($headers[0], 9, 3);
if(substr($returnCode, 0, 1) === '2') { if (substr($returnCode, 0, 1) === '2') {
$this->storeUser($uid); $this->storeUser($uid);
return $uid; return $uid;
} else { } else {

View File

@@ -34,89 +34,89 @@ class XMPP extends Base {
} }
public function hmacSha1($key, $data) { public function hmacSha1($key, $data) {
if (strlen($key) > 64) { if (strlen($key) > 64) {
$key = str_pad(sha1($key, true), 64, chr(0)); $key = str_pad(sha1($key, true), 64, chr(0));
} }
if (strlen($key) < 64) { if (strlen($key) < 64) {
$key = str_pad($key, 64, chr(0)); $key = str_pad($key, 64, chr(0));
} }
$oPad = str_repeat(chr(0x5C), 64); $oPad = str_repeat(chr(0x5C), 64);
$iPad = str_repeat(chr(0x36), 64); $iPad = str_repeat(chr(0x36), 64);
for ($i = 0; $i < strlen($key); $i++) { for ($i = 0; $i < strlen($key); $i++) {
$oPad[$i] = $oPad[$i] ^ $key[$i]; $oPad[$i] = $oPad[$i] ^ $key[$i];
$iPad[$i] = $iPad[$i] ^ $key[$i]; $iPad[$i] = $iPad[$i] ^ $key[$i];
} }
return sha1($oPad.sha1($iPad.$data, true)); return sha1($oPad.sha1($iPad.$data, true));
} }
public function validateHashedPassword($user, $uid, $submittedPassword){ public function validateHashedPassword($user, $uid, $submittedPassword) {
foreach ($user as $key){ foreach ($user as $key) {
if($key[3] === "salt") { if ($key[3] === "salt") {
$internalSalt = $key['value']; $internalSalt = $key['value'];
} }
if($key[3] === "server_key") { if ($key[3] === "server_key") {
$internalServerKey = $key['value']; $internalServerKey = $key['value'];
} }
if($key[3] === "stored_key") { if ($key[3] === "stored_key") {
$internalStoredKey = $key['value']; $internalStoredKey = $key['value'];
} }
} }
unset($user); unset($user);
$internalIteration = '4096'; $internalIteration = '4096';
$newSaltedPassword = hash_pbkdf2('sha1', $submittedPassword, $internalSalt, $internalIteration, 0, true); $newSaltedPassword = hash_pbkdf2('sha1', $submittedPassword, $internalSalt, $internalIteration, 0, true);
$newServerKey = $this->hmacSha1($newSaltedPassword, 'Server Key'); $newServerKey = $this->hmacSha1($newSaltedPassword, 'Server Key');
$newClientKey = $this->hmacSha1($newSaltedPassword, 'Client Key'); $newClientKey = $this->hmacSha1($newSaltedPassword, 'Client Key');
$newStoredKey = sha1(hex2bin($newClientKey)); $newStoredKey = sha1(hex2bin($newClientKey));
if ($newServerKey === $internalServerKey if ($newServerKey === $internalServerKey
&& $newStoredKey === $internalStoredKey) { && $newStoredKey === $internalStoredKey) {
$uid = mb_strtolower($uid); $uid = mb_strtolower($uid);
$this->storeUser($uid); $this->storeUser($uid);
return $uid; return $uid;
} else { } else {
return false; return false;
} }
} }
public function validatePlainPassword($user, $uid, $submittedPassword) { public function validatePlainPassword($user, $uid, $submittedPassword) {
foreach ($user as $key) { foreach ($user as $key) {
if($key[3] === "password") { if ($key[3] === "password") {
$internalPlainPassword = $key['value']; $internalPlainPassword = $key['value'];
} }
} }
unset($user); unset($user);
if ($submittedPassword === $internalPlainPassword) { if ($submittedPassword === $internalPlainPassword) {
$uid = mb_strtolower($uid); $uid = mb_strtolower($uid);
$this->storeUser($uid); $this->storeUser($uid);
return $uid; return $uid;
} else { } else {
return false; return false;
} }
} }
public function checkPassword($uid, $password){ public function checkPassword($uid, $password) {
$pdo = new \PDO("mysql:host=$this->host;dbname=$this->xmppDb", $this->xmppDbUser, $this->xmppDbPassword); $pdo = new \PDO("mysql:host=$this->host;dbname=$this->xmppDb", $this->xmppDbUser, $this->xmppDbPassword);
if(isset($uid) if (isset($uid)
&& isset($password)) { && isset($password)) {
if(!filter_var($uid, FILTER_VALIDATE_EMAIL) if (!filter_var($uid, FILTER_VALIDATE_EMAIL)
|| !strpos($uid, $this->xmppDomain) || !strpos($uid, $this->xmppDomain)
|| substr($uid, -strlen($this->xmppDomain)) !== $this->xmppDomain || substr($uid, -strlen($this->xmppDomain)) !== $this->xmppDomain
) { ) {
return false; return false;
} }
$user = explode("@", $uid); $user = explode("@", $uid);
$userName = strtolower($user[0]); $userName = strtolower($user[0]);
$submittedPassword = $password; $submittedPassword = $password;
$statement = $pdo->prepare("SELECT * FROM prosody WHERE user = :user AND host = :xmppDomain AND store = 'accounts'"); $statement = $pdo->prepare("SELECT * FROM prosody WHERE user = :user AND host = :xmppDomain AND store = 'accounts'");
$result = $statement->execute(array( $result = $statement->execute(array(
'user' => $userName, 'user' => $userName,
'xmppDomain' => $this->xmppDomain 'xmppDomain' => $this->xmppDomain
)); ));
$user = $statement->fetchAll(); $user = $statement->fetchAll();
if(empty($user)) { if (empty($user)) {
return false; return false;
} }
if ($this->passwordHashed === true) { if ($this->passwordHashed === true) {

View File

@@ -16,20 +16,20 @@ class Test_User_BasicAuth extends \Test\TestCase {
return include(__DIR__.'/config.php'); return include(__DIR__.'/config.php');
} }
function skip() { public function skip() {
$config=$this->getConfig(); $config = $this->getConfig();
$this->skipUnless($config['basic_auth']['run']); $this->skipUnless($config['basic_auth']['run']);
} }
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$config=$this->getConfig(); $config = $this->getConfig();
$this->instance=new OC_User_BasicAuth($config['basic_auth']['url']); $this->instance = new OC_User_BasicAuth($config['basic_auth']['url']);
} }
function testLogin() { public function testLogin() {
$config=$this->getConfig(); $config = $this->getConfig();
$this->assertEquals($config['basic_auth']['user'],$this->instance->checkPassword($config['basic_auth']['user'],$config['basic_auth']['password'])); $this->assertEquals($config['basic_auth']['user'], $this->instance->checkPassword($config['basic_auth']['user'], $config['basic_auth']['password']));
$this->assertFalse($this->instance->checkPassword($config['basic_auth']['user'],$config['basic_auth']['password'].'foo')); $this->assertFalse($this->instance->checkPassword($config['basic_auth']['user'], $config['basic_auth']['password'].'foo'));
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
if (!defined('PHPUNIT_RUN')) { if (!defined('PHPUNIT_RUN')) {
define('PHPUNIT_RUN', 1); define('PHPUNIT_RUN', 1);
} }
@@ -9,7 +10,7 @@ if (!class_exists('\PHPUnit\Framework\TestCase')) {
\OC_App::loadApp('user_external'); \OC_App::loadApp('user_external');
$dummyClass = \OC::$SERVERROOT . '/tests/lib/Util/User/Dummy.php'; $dummyClass = \OC::$SERVERROOT . '/tests/lib/Util/User/Dummy.php';
if(file_exists($dummyClass)) { if (file_exists($dummyClass)) {
require_once($dummyClass); require_once($dummyClass);
} }
OC_Hook::clear(); OC_Hook::clear();

View File

@@ -8,28 +8,28 @@
OC_App::loadApp('user_external'); OC_App::loadApp('user_external');
return array( return array(
'imap'=>array( 'imap' => array(
'run'=>false, 'run' => false,
'mailbox'=>'{imap.gmail.com:993/imap/ssl}INBOX', //see http://php.net/manual/en/function.imap-open.php 'mailbox' => '{imap.gmail.com:993/imap/ssl}INBOX', //see http://php.net/manual/en/function.imap-open.php
'user'=>'foo',//valid username/password combination 'user' => 'foo',//valid username/password combination
'password'=>'bar', 'password' => 'bar',
), ),
'smb'=>array( 'smb' => array(
'run'=>false, 'run' => false,
'host'=>'localhost', 'host' => 'localhost',
'user'=>'test',//valid username/password combination 'user' => 'test',//valid username/password combination
'password'=>'test', 'password' => 'test',
), ),
'ftp'=>array( 'ftp' => array(
'run'=>false, 'run' => false,
'host'=>'localhost', 'host' => 'localhost',
'user'=>'test',//valid username/password combination 'user' => 'test',//valid username/password combination
'password'=>'test', 'password' => 'test',
), ),
'basic_auth'=>array( 'basic_auth' => array(
'run'=>false, 'run' => false,
'url'=>'localhost/basic_auth', 'url' => 'localhost/basic_auth',
'user'=>'test',//valid username/password combination 'user' => 'test',//valid username/password combination
'password'=>'test', 'password' => 'test',
), ),
); );

View File

@@ -16,20 +16,20 @@ class Test_User_FTP extends \Test\TestCase {
return include(__DIR__.'/config.php'); return include(__DIR__.'/config.php');
} }
function skip() { public function skip() {
$config=$this->getConfig(); $config = $this->getConfig();
$this->skipUnless($config['ftp']['run']); $this->skipUnless($config['ftp']['run']);
} }
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$config=$this->getConfig(); $config = $this->getConfig();
$this->instance=new OC_User_FTP($config['ftp']['host']); $this->instance = new OC_User_FTP($config['ftp']['host']);
} }
function testLogin() { public function testLogin() {
$config=$this->getConfig(); $config = $this->getConfig();
$this->assertEquals($config['ftp']['user'],$this->instance->checkPassword($config['ftp']['user'],$config['ftp']['password'])); $this->assertEquals($config['ftp']['user'], $this->instance->checkPassword($config['ftp']['user'], $config['ftp']['password']));
$this->assertFalse($this->instance->checkPassword($config['ftp']['user'],$config['ftp']['password'].'foo')); $this->assertFalse($this->instance->checkPassword($config['ftp']['user'], $config['ftp']['password'].'foo'));
} }
} }

View File

@@ -16,21 +16,21 @@ class Test_User_Imap extends \Test\TestCase {
return include(__DIR__.'/config.php'); return include(__DIR__.'/config.php');
} }
function skip() { public function skip() {
$config=$this->getConfig(); $config = $this->getConfig();
$this->skipUnless($config['imap']['run']); $this->skipUnless($config['imap']['run']);
} }
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$config=$this->getConfig(); $config = $this->getConfig();
$this->instance=new OC_User_IMAP($config['imap']['mailbox']); $this->instance = new OC_User_IMAP($config['imap']['mailbox']);
} }
function testLogin() { public function testLogin() {
$config=$this->getConfig(); $config = $this->getConfig();
$this->assertEquals($config['imap']['user'],$this->instance->checkPassword($config['imap']['user'],$config['imap']['password'])); $this->assertEquals($config['imap']['user'], $this->instance->checkPassword($config['imap']['user'], $config['imap']['password']));
$this->assertFalse($this->instance->checkPassword($config['imap']['user'],$config['imap']['password'].'foo')); $this->assertFalse($this->instance->checkPassword($config['imap']['user'], $config['imap']['password'].'foo'));
} }
} }

View File

@@ -16,21 +16,21 @@ class Test_User_SMB extends \Test\TestCase {
return include(__DIR__.'/config.php'); return include(__DIR__.'/config.php');
} }
function skip() { public function skip() {
$config=$this->getConfig(); $config = $this->getConfig();
$this->skipUnless($config['smb']['run']); $this->skipUnless($config['smb']['run']);
} }
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$config=$this->getConfig(); $config = $this->getConfig();
$this->instance=new OC_User_SMB($config['smb']['host']); $this->instance = new OC_User_SMB($config['smb']['host']);
} }
function testLogin() { public function testLogin() {
$config=$this->getConfig(); $config = $this->getConfig();
$this->assertEquals($config['smb']['user'],$this->instance->checkPassword($config['smb']['user'],$config['smb']['password'])); $this->assertEquals($config['smb']['user'], $this->instance->checkPassword($config['smb']['user'], $config['smb']['password']));
$this->assertFalse($this->instance->checkPassword($config['smb']['user'],$config['smb']['password'].'foo')); $this->assertFalse($this->instance->checkPassword($config['smb']['user'], $config['smb']['password'].'foo'));
} }
} }