Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php declare(strict_types=1); /** * Passbolt ~ Open source password manager for teams ..
Decoded Output download
<?php
declare(strict_types=1);
/**
* Passbolt ~ Open source password manager for teams
* Copyright (c) Passbolt SA (https://www.passbolt.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.passbolt.com Passbolt(tm)
* @since 2.5.0
*/
namespace Passbolt\WebInstaller\Test\TestCase\Controller;
use App\Test\Factory\OrganizationSettingFactory;
use App\Test\Factory\UserFactory;
use App\Utility\Filesystem\DirectoryUtility;
use Cake\Core\Configure;
use Cake\Datasource\ConnectionManager;
use Cake\Validation\Validation;
use Passbolt\WebInstaller\Form\DatabaseConfigurationForm;
use Passbolt\WebInstaller\Service\WebInstallerChangeConfigFolderPermissionService;
use Passbolt\WebInstaller\Test\Lib\WebInstallerIntegrationTestCase;
class InstallationControllerTest extends WebInstallerIntegrationTestCase
{
public function setUp(): void
{
parent::setUp();
$this->mockPassboltIsNotconfigured();
$this->initWebInstallerSession();
$this->backupConfiguration();
}
public function tearDown(): void
{
$this->restoreConfiguration();
parent::tearDown();
}
protected function getInstallSessionData()
{
$datasourceTest = $this->getTestDatasourceFromConfig();
$data = [
'initialized' => true,
'hasExistingAdmin' => false,
'database' => $datasourceTest,
'gpg' => [
'public_key_armored' => '-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFxZYsMBEADaHvuNsno1PDvagd+50n0j+EonuPuEsDzNaj4U1BXpoBwSHRkM
QPaTBnOajs60BrUAw70JLQr5ExyAR3/5OQhL3Haj/vnQvOvM97wED2Z3rA6jkQQ3
/AwkNZL8uaZLeMv+FAe2/Ik/G5z/vxMUZwtGsbh1lPMcDjZT/qYssww3HnDNEpnV
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qxHAzmIoqqTdX
J81AH1ZRqcRXBYeeBaDkJbFAfdPQ7kaqpb13sV+W9NCAbQ0Hzy8V7NyTDndwD4Vf
1YkCNgQYAQgAIBYhBLFrCglamvRtfX+qRAqEj77TNLPsBQJcWWLDAhsMAAoJEAqE
j77TNLPs7OIP/1hoksjbd1PlxDmdF1cTkISEuDD11/47FRICbx/8COWJSIqq8SbO
XK4Ff2ioDXBQSj4xroBkAkRSPlHQTnqhDc9bWxhWgOoPT8DTGA7O4zHHmvDWjjVw
9kkNW3BMdcAvr+x3+FM5B1H3zKXeFPblRLItaO3ajCb13mgKUq3YX4cbkF+RyU5d
2jJoDZaIzrYsH26/cOZfNDqzMjAdO7eA5POYUVNUQCy6/8BfI9KP1+HKgR6kVat3
JtjwyyNotUOQtxkKvmo4z3XRNW/UT57AsSX0+wM9g2IViC8zOCfSwzPldsnBp4X6
UC5WXR9960jyDsISfIg1XdEt96YbRctCM931atg6FVoHaBjoPXuWekoVlxHT9t/K
7TygHOb9qKeafEmQ4zi/l2UZ8maGkddSTDbUdzoZp0ofFE9+BhQSSXlRIDMh/0z8
M/cK9+1fxX9bawf5A6PW53rjWVZab49/gLpGYRI7j+GKsi7MDhDWh0Lm5Dt0rssh
OOyeYQVv8ovrYnMpV/ms+HGVbyX4Hn//KR0V72rd+TG5r236SlwRfFXEhUTm89IA
st3lhztahsDyWaZfpwNevoDzETA6ibxJ4aeDUMQ99OXf/V5vXA0300wqsBInri1f
UZNFZWTIXO4n0jwpTTOt6DvtqeRyjjw2nK3XUSiJu3izvn0791l4tofy
=GMak
-----END PGP PRIVATE KEY BLOCK-----',
'fingerprint' => 'B16B0A095A9AF46D7D7FAA440A848FBED334B3EC',
],
'email' => [
'sender_name' => 'Webinstaller test',
'sender_email' => '[email protected]',
'host' => 'unreachable_host.dev',
'tls' => 1,
'port' => 587,
'username' => 'webinstaller',
'password' => 'webinstaller',
],
'options' => [
'full_base_url' => 'http://127.0.0.1:8081',
'force_ssl' => 0,
],
'first_user' => [
'profile' => [
'first_name' => 'Web',
'last_name' => 'Installer',
],
'username' => '[email protected]',
'deleted' => 0,
'role_id' => '0d6990c8-4aaa-4456-a333-00e803ba0828',
],
];
return $data;
}
public function testWebInstallerInstallationViewSuccess()
{
$this->dropAllTables();
$config = $this->getInstallSessionData();
$this->initWebInstallerSession($config);
$this->get('/install/installation');
$data = $this->_getBodyAsString();
$this->assertResponseOk();
$this->assertStringContainsString('Installing', $data);
}
/**
* @group triggerFilesystemChanges
* @throws \PHPUnit\Exception
*/
public function testWebInstallerInstallationDoInstallSuccess()
{
$this->dropAllTables();
$this->skipTestIfNotWebInstallerFriendly();
Configure::write('passbolt.gpg.serverKey.fingerprint', null);
$connection = ConnectionManager::get('default');
$config = $this->getInstallSessionData();
$form = (new DatabaseConfigurationForm());
$this->assertTrue($form->execute($config['database']));
$config['database'] = $form->getData();
$this->initWebInstallerSession($config);
$tables = $connection->getSchemaCollection()->listTables();
$this->assertEmpty($tables);
$testConfigDir = TMP . 'test_config' . DS;
mkdir($testConfigDir);
$testConfigFile = $testConfigDir . 'test_file.txt';
file_put_contents($testConfigFile, 'blah');
$configFolderPermissionService = new WebInstallerChangeConfigFolderPermissionService($testConfigDir);
$this->mockService(WebInstallerChangeConfigFolderPermissionService::class, function () use ($configFolderPermissionService) {
return $configFolderPermissionService;
});
$this->get('/install/installation/do_install.json');
$tables = $connection->getSchemaCollection()->listTables();
$this->assertNotEmpty($tables);
$result = json_decode($this->_getBodyAsString(), true);
$this->assertTrue(isset($result['user_id']));
$this->assertTrue(isset($result['token']));
$this->assertTrue(Validation::uuid($result['user_id']));
$this->assertTrue(Validation::uuid($result['token']));
// Ensure that the SMTP Settings were saved in the DB
$this->assertSame(1, OrganizationSettingFactory::count());
$filePermission = substr(sprintf('%o', fileperms($testConfigFile)), -4);
$folderPermission = substr(sprintf('%o', fileperms($testConfigDir)), -4);
$this->assertEquals('0440', $filePermission);
$this->assertEquals('0550', $folderPermission);
chmod($testConfigFile, 0775);
chmod($testConfigDir, 0775);
DirectoryUtility::removeRecursively($testConfigDir);
}
/**
* @group triggerFilesystemChanges
*/
public function testWebInstallerInstallationDoInstall_SuccessWhenFirstUserIsEmpty()
{
$this->markTestSkipped();
$this->skipTestIfNotWebInstallerFriendly();
Configure::write('passbolt.gpg.serverKey.fingerprint', null);
$connection = ConnectionManager::get('default');
$config = $this->getInstallSessionData();
/**
* Set `first_user` key to empty so first user can't be created.
* This will help us test scenario in which session doesn't contain `user`.
*/
$config['first_user'] = [];
$this->initWebInstallerSession($config);
/** Make sure tables exist */
$tables = $connection->getSchemaCollection()->listTables();
$this->assertNotEmpty($tables);
/** Set test configuration */
$testConfigDir = TMP . 'test_config' . DS;
mkdir($testConfigDir, 0755);
$testConfigFile = $testConfigDir . 'test_file.txt';
file_put_contents($testConfigFile, 'blah');
$configFolderPermissionService = new WebInstallerChangeConfigFolderPermissionService($testConfigDir);
$this->mockService(WebInstallerChangeConfigFolderPermissionService::class, function () use ($configFolderPermissionService) {
return $configFolderPermissionService;
});
/** Create an admin user */
UserFactory::make()->admin()->persist();
$this->get('/install/installation/do_install.json');
// Ensure that the SMTP Settings were saved in the DB as well as the subscription
$this->assertSame(1, OrganizationSettingFactory::count());
/** Configuration assertions */
$filePermission = substr(sprintf('%o', fileperms($testConfigFile)), -4);
$folderPermission = substr(sprintf('%o', fileperms($testConfigDir)), -4);
$this->assertEquals('0440', $filePermission);
$this->assertEquals('0550', $folderPermission);
chmod($testConfigFile, 0775);
chmod($testConfigDir, 0775);
DirectoryUtility::removeRecursively($testConfigDir);
}
}
?>
Did this file decode correctly?
Original Code
<?php
declare(strict_types=1);
/**
* Passbolt ~ Open source password manager for teams
* Copyright (c) Passbolt SA (https://www.passbolt.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Passbolt SA (https://www.passbolt.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.passbolt.com Passbolt(tm)
* @since 2.5.0
*/
namespace Passbolt\WebInstaller\Test\TestCase\Controller;
use App\Test\Factory\OrganizationSettingFactory;
use App\Test\Factory\UserFactory;
use App\Utility\Filesystem\DirectoryUtility;
use Cake\Core\Configure;
use Cake\Datasource\ConnectionManager;
use Cake\Validation\Validation;
use Passbolt\WebInstaller\Form\DatabaseConfigurationForm;
use Passbolt\WebInstaller\Service\WebInstallerChangeConfigFolderPermissionService;
use Passbolt\WebInstaller\Test\Lib\WebInstallerIntegrationTestCase;
class InstallationControllerTest extends WebInstallerIntegrationTestCase
{
public function setUp(): void
{
parent::setUp();
$this->mockPassboltIsNotconfigured();
$this->initWebInstallerSession();
$this->backupConfiguration();
}
public function tearDown(): void
{
$this->restoreConfiguration();
parent::tearDown();
}
protected function getInstallSessionData()
{
$datasourceTest = $this->getTestDatasourceFromConfig();
$data = [
'initialized' => true,
'hasExistingAdmin' => false,
'database' => $datasourceTest,
'gpg' => [
'public_key_armored' => '-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFxZYsMBEADaHvuNsno1PDvagd+50n0j+EonuPuEsDzNaj4U1BXpoBwSHRkM
QPaTBnOajs60BrUAw70JLQr5ExyAR3/5OQhL3Haj/vnQvOvM97wED2Z3rA6jkQQ3
/AwkNZL8uaZLeMv+FAe2/Ik/G5z/vxMUZwtGsbh1lPMcDjZT/qYssww3HnDNEpnV
yvU6aiZ6B6kD2baR1S6GAK45D4hwLlukmnUBHhc1EfQxGYWFd876zwij8f6+7kjj
rMxpKh5s4OBJAHCKhdID7efHDGovSiBW4JjCLT73tDKa5tI4bxOOsOAtfUtWaHEY
pqVihhHORVFrXtvnYFvjK0a9xfS34uwIGRzXw8PFkzqtMpvYioDBDDsBEpUYTtA0
rgIxlX5FLl9bDdOpZHXms0MATDaOzePHHU3L6ivYG4zv9uHCOg8e8cQCVPfUDRcF
1QwGDxoN25ziLjcoV/w2EbN36vFs83C0W/YLrpzu6rNv5arT/HZqcphTcCW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LItaO3ajCb13mgKUq3YX4cbkF+RyU5d
2jJoDZaIzrYsH26/cOZfNDqzMjAdO7eA5POYUVNUQCy6/8BfI9KP1+HKgR6kVat3
JtjwyyNotUOQtxkKvmo4z3XRNW/UT57AsSX0+wM9g2IViC8zOCfSwzPldsnBp4X6
UC5WXR9960jyDsISfIg1XdEt96YbRctCM931atg6FVoHaBjoPXuWekoVlxHT9t/K
7TygHOb9qKeafEmQ4zi/l2UZ8maGkddSTDbUdzoZp0ofFE9+BhQSSXlRIDMh/0z8
M/cK9+1fxX9bawf5A6PW53rjWVZab49/gLpGYRI7j+GKsi7MDhDWh0Lm5Dt0rssh
OOyeYQVv8ovrYnMpV/ms+HGVbyX4Hn//KR0V72rd+TG5r236SlwRfFXEhUTm89IA
st3lhztahsDyWaZfpwNevoDzETA6ibxJ4aeDUMQ99OXf/V5vXA0300wqsBInri1f
UZNFZWTIXO4n0jwpTTOt6DvtqeRyjjw2nK3XUSiJu3izvn0791l4tofy
=GMak
-----END PGP PRIVATE KEY BLOCK-----',
'fingerprint' => 'B16B0A095A9AF46D7D7FAA440A848FBED334B3EC',
],
'email' => [
'sender_name' => 'Webinstaller test',
'sender_email' => '[email protected]',
'host' => 'unreachable_host.dev',
'tls' => 1,
'port' => 587,
'username' => 'webinstaller',
'password' => 'webinstaller',
],
'options' => [
'full_base_url' => 'http://127.0.0.1:8081',
'force_ssl' => 0,
],
'first_user' => [
'profile' => [
'first_name' => 'Web',
'last_name' => 'Installer',
],
'username' => '[email protected]',
'deleted' => 0,
'role_id' => '0d6990c8-4aaa-4456-a333-00e803ba0828',
],
];
return $data;
}
public function testWebInstallerInstallationViewSuccess()
{
$this->dropAllTables();
$config = $this->getInstallSessionData();
$this->initWebInstallerSession($config);
$this->get('/install/installation');
$data = $this->_getBodyAsString();
$this->assertResponseOk();
$this->assertStringContainsString('Installing', $data);
}
/**
* @group triggerFilesystemChanges
* @throws \PHPUnit\Exception
*/
public function testWebInstallerInstallationDoInstallSuccess()
{
$this->dropAllTables();
$this->skipTestIfNotWebInstallerFriendly();
Configure::write('passbolt.gpg.serverKey.fingerprint', null);
$connection = ConnectionManager::get('default');
$config = $this->getInstallSessionData();
$form = (new DatabaseConfigurationForm());
$this->assertTrue($form->execute($config['database']));
$config['database'] = $form->getData();
$this->initWebInstallerSession($config);
$tables = $connection->getSchemaCollection()->listTables();
$this->assertEmpty($tables);
$testConfigDir = TMP . 'test_config' . DS;
mkdir($testConfigDir);
$testConfigFile = $testConfigDir . 'test_file.txt';
file_put_contents($testConfigFile, 'blah');
$configFolderPermissionService = new WebInstallerChangeConfigFolderPermissionService($testConfigDir);
$this->mockService(WebInstallerChangeConfigFolderPermissionService::class, function () use ($configFolderPermissionService) {
return $configFolderPermissionService;
});
$this->get('/install/installation/do_install.json');
$tables = $connection->getSchemaCollection()->listTables();
$this->assertNotEmpty($tables);
$result = json_decode($this->_getBodyAsString(), true);
$this->assertTrue(isset($result['user_id']));
$this->assertTrue(isset($result['token']));
$this->assertTrue(Validation::uuid($result['user_id']));
$this->assertTrue(Validation::uuid($result['token']));
// Ensure that the SMTP Settings were saved in the DB
$this->assertSame(1, OrganizationSettingFactory::count());
$filePermission = substr(sprintf('%o', fileperms($testConfigFile)), -4);
$folderPermission = substr(sprintf('%o', fileperms($testConfigDir)), -4);
$this->assertEquals('0440', $filePermission);
$this->assertEquals('0550', $folderPermission);
chmod($testConfigFile, 0775);
chmod($testConfigDir, 0775);
DirectoryUtility::removeRecursively($testConfigDir);
}
/**
* @group triggerFilesystemChanges
*/
public function testWebInstallerInstallationDoInstall_SuccessWhenFirstUserIsEmpty()
{
$this->markTestSkipped();
$this->skipTestIfNotWebInstallerFriendly();
Configure::write('passbolt.gpg.serverKey.fingerprint', null);
$connection = ConnectionManager::get('default');
$config = $this->getInstallSessionData();
/**
* Set `first_user` key to empty so first user can't be created.
* This will help us test scenario in which session doesn't contain `user`.
*/
$config['first_user'] = [];
$this->initWebInstallerSession($config);
/** Make sure tables exist */
$tables = $connection->getSchemaCollection()->listTables();
$this->assertNotEmpty($tables);
/** Set test configuration */
$testConfigDir = TMP . 'test_config' . DS;
mkdir($testConfigDir, 0755);
$testConfigFile = $testConfigDir . 'test_file.txt';
file_put_contents($testConfigFile, 'blah');
$configFolderPermissionService = new WebInstallerChangeConfigFolderPermissionService($testConfigDir);
$this->mockService(WebInstallerChangeConfigFolderPermissionService::class, function () use ($configFolderPermissionService) {
return $configFolderPermissionService;
});
/** Create an admin user */
UserFactory::make()->admin()->persist();
$this->get('/install/installation/do_install.json');
// Ensure that the SMTP Settings were saved in the DB as well as the subscription
$this->assertSame(1, OrganizationSettingFactory::count());
/** Configuration assertions */
$filePermission = substr(sprintf('%o', fileperms($testConfigFile)), -4);
$folderPermission = substr(sprintf('%o', fileperms($testConfigDir)), -4);
$this->assertEquals('0440', $filePermission);
$this->assertEquals('0550', $folderPermission);
chmod($testConfigFile, 0775);
chmod($testConfigDir, 0775);
DirectoryUtility::removeRecursively($testConfigDir);
}
}
Function Calls
None |
Stats
MD5 | 2b7416d88adfa0f9f574b91e0b450615 |
Eval Count | 0 |
Decode Time | 86 ms |