mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-14 04:16:54 +01:00
* [MOD] Unit testing. Work in progress
This commit is contained in:
@@ -68,8 +68,11 @@ trait DbTestUtilTrait
|
||||
*/
|
||||
private function createUser($user, $pass, $database)
|
||||
{
|
||||
$this->getConnection()
|
||||
->query(sprintf('GRANT ALL PRIVILEGES ON `%s`.* TO \'%s\'@\'%s\' IDENTIFIED BY \'%s\'', $database, $user, SELF_IP_ADDRESS, $pass));
|
||||
$query = 'GRANT ALL PRIVILEGES ON `%s`.* TO \'%s\'@\'%s\' IDENTIFIED BY \'%s\'';
|
||||
|
||||
$conn = $this->getConnection();
|
||||
$conn->query(sprintf($query, $database, $user, SELF_IP_ADDRESS, $pass));
|
||||
$conn->query(sprintf($query, $database, $user, SELF_HOSTNAME, $pass));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +84,7 @@ trait DbTestUtilTrait
|
||||
private function dropUser($user, $host)
|
||||
{
|
||||
$this->getConnection()
|
||||
->query(sprintf('DROP USER \'%s\'@\'%s\'', $user, $host));
|
||||
->query(sprintf('DROP USER IF EXISTS \'%s\'@\'%s\'', $user, $host));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,7 @@ use SP\Services\Install\InstallData;
|
||||
use SP\Services\Install\Installer;
|
||||
use SP\Storage\Database\DBUtil;
|
||||
use SP\Storage\Database\MySQLHandler;
|
||||
use SP\Util\Util;
|
||||
use function SP\Test\getResource;
|
||||
use function SP\Test\saveResource;
|
||||
use function SP\Test\setupContext;
|
||||
@@ -111,8 +112,12 @@ class InstallerTest extends TestCase
|
||||
$this->assertTrue(self::$dic->get(MasterPassService::class)->checkMasterPassword($params->getMasterPassword()));
|
||||
|
||||
$this->dropDatabase(self::DB_NAME);
|
||||
$this->dropUser($configData->getDbUser(), SELF_IP_ADDRESS);
|
||||
$this->dropUser($configData->getDbUser(), SELF_HOSTNAME);
|
||||
|
||||
$this->dropUser($configData->getDbUser(), $params->getDbAuthHost());
|
||||
|
||||
if ($params->getDbAuthHostDns()) {
|
||||
$this->dropUser($configData->getDbUser(), $params->getDbAuthHostDns());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,12 +264,15 @@ class InstallerTest extends TestCase
|
||||
*/
|
||||
public function testHostingMode()
|
||||
{
|
||||
$pass = Util::randomPassword();
|
||||
|
||||
$this->dropDatabase(self::DB_NAME);
|
||||
$this->createDatabase(self::DB_NAME);
|
||||
$this->createUser('syspass_user', '123456', self::DB_NAME);
|
||||
$this->createUser('syspass_user', $pass, self::DB_NAME);
|
||||
|
||||
$params = new InstallData();
|
||||
$params->setDbAdminUser('syspass_user');
|
||||
$params->setDbAdminPass('123456');
|
||||
$params->setDbAdminPass($pass);
|
||||
$params->setDbName(self::DB_NAME);
|
||||
$params->setDbHost(getenv('DB_SERVER'));
|
||||
$params->setAdminLogin('admin');
|
||||
@@ -290,6 +298,7 @@ class InstallerTest extends TestCase
|
||||
|
||||
$this->dropDatabase(self::DB_NAME);
|
||||
$this->dropUser('syspass_user', SELF_IP_ADDRESS);
|
||||
$this->dropUser('syspass_user', SELF_HOSTNAME);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
|
||||
@@ -56,21 +56,6 @@ class MySQLTest extends TestCase
|
||||
$this->assertFalse($mysql->checkDatabaseExist());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \SP\Storage\Database\DatabaseException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function testCheckDatabaseExist()
|
||||
{
|
||||
$this->createDatabase(self::DB_NAME);
|
||||
|
||||
$mysql = new MySQL($this->getParams(), new ConfigData());
|
||||
|
||||
$this->assertTrue($mysql->checkDatabaseExist());
|
||||
|
||||
$this->dropDatabase(self::DB_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InstallData
|
||||
*/
|
||||
@@ -91,6 +76,21 @@ class MySQLTest extends TestCase
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \SP\Storage\Database\DatabaseException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function testCheckDatabaseExist()
|
||||
{
|
||||
$this->createDatabase(self::DB_NAME);
|
||||
|
||||
$mysql = new MySQL($this->getParams(), new ConfigData());
|
||||
|
||||
$this->assertTrue($mysql->checkDatabaseExist());
|
||||
|
||||
$this->dropDatabase(self::DB_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
|
||||
@@ -151,10 +151,6 @@ class FileHandlerTest extends TestCase
|
||||
(new FileHandler(self::$validFile))
|
||||
->clearCache()
|
||||
->checkIsReadable();
|
||||
|
||||
(new FileHandler(self::$immutableFile))
|
||||
->clearCache()
|
||||
->checkIsReadable();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
<authBasicAutoLoginEnabled>1</authBasicAutoLoginEnabled>
|
||||
<authBasicDomain></authBasicDomain>
|
||||
<authBasicEnabled>1</authBasicEnabled>
|
||||
<backup_hash>7073a41c8032d93be23cda9eea07f9c3527f54da</backup_hash>
|
||||
<backup_hash>e4ec7e7979447922d90ef4280172177256c162b8</backup_hash>
|
||||
<checkUpdates>0</checkUpdates>
|
||||
<checknotices>0</checknotices>
|
||||
<configDate>1532375214</configDate>
|
||||
<configHash>a4658216020fa81739ab6f100a0d96170a0e5f90</configHash>
|
||||
<configDate>1532379104</configDate>
|
||||
<configHash>5819af570a83290a50935bb1e8397d24c74b87aa</configHash>
|
||||
<configSaver></configSaver>
|
||||
<configVersion></configVersion>
|
||||
<databaseVersion></databaseVersion>
|
||||
@@ -32,7 +32,7 @@
|
||||
<dokuwikiUrlBase></dokuwikiUrlBase>
|
||||
<dokuwikiUser></dokuwikiUser>
|
||||
<encryptSession>0</encryptSession>
|
||||
<export_hash>7768216134c3c60d24989d670ed6e26d3006347a</export_hash>
|
||||
<export_hash>25cdc5c691636d478367f88a5e9bb3fc043097d2</export_hash>
|
||||
<filesAllowedExts>
|
||||
<item type="filesAllowedExts">PDF</item>
|
||||
<item type="filesAllowedExts">JPG</item>
|
||||
|
||||
Reference in New Issue
Block a user