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 3.11.0
*/
namespace Passbolt\SmtpSettings\Test\TestCase\Command;
use App\Test\Lib\Utility\EmailTestTrait;
use App\Utility\Application\FeaturePluginAwareTrait;
use App\View\Helper\AvatarHelper;
use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
use Cake\Core\Configure;
use Cake\Event\EventList;
use Cake\Event\EventManager;
use Cake\Mailer\Mailer;
use Cake\TestSuite\TestCase;
use CakephpTestSuiteLight\Fixture\TruncateDirtyTables;
use Passbolt\EmailDigest\Test\Factory\EmailQueueFactory;
use Passbolt\EmailNotificationSettings\Utility\EmailNotificationSettings;
use Passbolt\SmtpSettings\Test\Lib\SmtpSettingsTestTrait;
/**
* @uses \Passbolt\EmailDigest\Command\PreviewCommand
*/
class SmtpSettingsEmailDigestPreviewCommandTest extends TestCase
{
use ConsoleIntegrationTestTrait;
use EmailTestTrait;
use FeaturePluginAwareTrait;
use SmtpSettingsTestTrait;
use TruncateDirtyTables;
/**
* setUp method
*
* @return void
*/
public function setUp(): void
{
parent::setUp();
$this->useCommandRunner();
$this->clearPlugins();
$this->loadPlugins(['Passbolt/EmailDigest' => []]);
EmailNotificationSettings::flushCache();
EventManager::instance()->setEventList(new EventList());
$this->enableFeaturePlugin('SmtpSettings');
}
/**
* Basic Preview test.
*/
public function testSmtpSettingsEmailDigestPreviewCommand_Without_Body_On_DB_Settings(): void
{
$senderEmail = '[email protected]';
$senderName = 'phpunit';
$data = $this->getSmtpSettingsData();
$data['sender_email'] = $senderEmail;
$data['sender_name'] = $senderName;
$this->encryptAndPersistSmtpSettings($data);
$nMails = 2;
EmailQueueFactory::make($nMails)->persist();
$mails = EmailQueueFactory::find()->orderAsc('created');
$this->exec('passbolt email_digest preview');
$this->assertExitSuccess();
foreach ($mails as $mail) {
$this->assertOutputContains("From: {$senderName} <{$senderEmail}>");
$this->assertOutputContains("Return-Path: {$senderName} <{$senderEmail}>");
$this->assertOutputContains('To: ' . $mail->get('email'));
$this->assertOutputContains('Subject: ' . $mail->get('subject'));
}
}
/**
* Basic Preview test.
*/
public function testSmtpSettingsEmailDigestPreviewCommand_Without_Body_On_File_Plugin_Disabled(): void
{
$this->disableFeaturePlugin('SmtpSettings');
$dataInDB = $this->getSmtpSettingsData();
$dataInDB['sender_email'] = '[email protected]';
$dataInDB['sender_name'] = 'phpunit';
$this->encryptAndPersistSmtpSettings($dataInDB);
$sender = Mailer::getConfig('default')['from'];
$senderEmail = array_keys($sender)[0];
$senderName = $sender[$senderEmail];
$nMails = 2;
EmailQueueFactory::make($nMails)->persist();
$mails = EmailQueueFactory::find()->orderAsc('created');
$this->exec('passbolt email_digest preview');
$this->assertExitSuccess();
foreach ($mails as $mail) {
$this->assertOutputContains("From: $senderName <$senderEmail>");
$this->assertOutputContains("Return-Path: $senderName <$senderEmail>");
$this->assertOutputContains('To: ' . $mail->get('email'));
$this->assertOutputContains('Subject: ' . $mail->get('subject'));
}
$this->enableFeaturePlugin('SmtpSettings');
}
/**
* Basic Preview test.
*
* @covers \App\Service\Avatars\AvatarsConfigurationService::loadConfiguration
*/
public function testSmtpSettingsEmailDigestPreviewCommand_With_Body(): void
{
// Ensure that avatar image configs are null and
// will be correctly loaded by the command.
Configure::delete('FileStorage');
$senderEmail = '[email protected]';
$senderName = 'phpunit';
$data = $this->getSmtpSettingsData();
$data['sender_email'] = $senderEmail;
$data['sender_name'] = $senderName;
$this->encryptAndPersistSmtpSettings($data);
$email = EmailQueueFactory::make(['from_email' => '[email protected]'])->persist();
$this->exec('passbolt email_digest preview --body');
$this->assertExitSuccess();
$this->assertOutputContains('Sending email to: ' . $email->get('email'));
$this->assertOutputContains(AvatarHelper::getAvatarFallBackUrl());
}
}
?>
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 3.11.0
*/
namespace Passbolt\SmtpSettings\Test\TestCase\Command;
use App\Test\Lib\Utility\EmailTestTrait;
use App\Utility\Application\FeaturePluginAwareTrait;
use App\View\Helper\AvatarHelper;
use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
use Cake\Core\Configure;
use Cake\Event\EventList;
use Cake\Event\EventManager;
use Cake\Mailer\Mailer;
use Cake\TestSuite\TestCase;
use CakephpTestSuiteLight\Fixture\TruncateDirtyTables;
use Passbolt\EmailDigest\Test\Factory\EmailQueueFactory;
use Passbolt\EmailNotificationSettings\Utility\EmailNotificationSettings;
use Passbolt\SmtpSettings\Test\Lib\SmtpSettingsTestTrait;
/**
* @uses \Passbolt\EmailDigest\Command\PreviewCommand
*/
class SmtpSettingsEmailDigestPreviewCommandTest extends TestCase
{
use ConsoleIntegrationTestTrait;
use EmailTestTrait;
use FeaturePluginAwareTrait;
use SmtpSettingsTestTrait;
use TruncateDirtyTables;
/**
* setUp method
*
* @return void
*/
public function setUp(): void
{
parent::setUp();
$this->useCommandRunner();
$this->clearPlugins();
$this->loadPlugins(['Passbolt/EmailDigest' => []]);
EmailNotificationSettings::flushCache();
EventManager::instance()->setEventList(new EventList());
$this->enableFeaturePlugin('SmtpSettings');
}
/**
* Basic Preview test.
*/
public function testSmtpSettingsEmailDigestPreviewCommand_Without_Body_On_DB_Settings(): void
{
$senderEmail = '[email protected]';
$senderName = 'phpunit';
$data = $this->getSmtpSettingsData();
$data['sender_email'] = $senderEmail;
$data['sender_name'] = $senderName;
$this->encryptAndPersistSmtpSettings($data);
$nMails = 2;
EmailQueueFactory::make($nMails)->persist();
$mails = EmailQueueFactory::find()->orderAsc('created');
$this->exec('passbolt email_digest preview');
$this->assertExitSuccess();
foreach ($mails as $mail) {
$this->assertOutputContains("From: {$senderName} <{$senderEmail}>");
$this->assertOutputContains("Return-Path: {$senderName} <{$senderEmail}>");
$this->assertOutputContains('To: ' . $mail->get('email'));
$this->assertOutputContains('Subject: ' . $mail->get('subject'));
}
}
/**
* Basic Preview test.
*/
public function testSmtpSettingsEmailDigestPreviewCommand_Without_Body_On_File_Plugin_Disabled(): void
{
$this->disableFeaturePlugin('SmtpSettings');
$dataInDB = $this->getSmtpSettingsData();
$dataInDB['sender_email'] = '[email protected]';
$dataInDB['sender_name'] = 'phpunit';
$this->encryptAndPersistSmtpSettings($dataInDB);
$sender = Mailer::getConfig('default')['from'];
$senderEmail = array_keys($sender)[0];
$senderName = $sender[$senderEmail];
$nMails = 2;
EmailQueueFactory::make($nMails)->persist();
$mails = EmailQueueFactory::find()->orderAsc('created');
$this->exec('passbolt email_digest preview');
$this->assertExitSuccess();
foreach ($mails as $mail) {
$this->assertOutputContains("From: $senderName <$senderEmail>");
$this->assertOutputContains("Return-Path: $senderName <$senderEmail>");
$this->assertOutputContains('To: ' . $mail->get('email'));
$this->assertOutputContains('Subject: ' . $mail->get('subject'));
}
$this->enableFeaturePlugin('SmtpSettings');
}
/**
* Basic Preview test.
*
* @covers \App\Service\Avatars\AvatarsConfigurationService::loadConfiguration
*/
public function testSmtpSettingsEmailDigestPreviewCommand_With_Body(): void
{
// Ensure that avatar image configs are null and
// will be correctly loaded by the command.
Configure::delete('FileStorage');
$senderEmail = '[email protected]';
$senderName = 'phpunit';
$data = $this->getSmtpSettingsData();
$data['sender_email'] = $senderEmail;
$data['sender_name'] = $senderName;
$this->encryptAndPersistSmtpSettings($data);
$email = EmailQueueFactory::make(['from_email' => '[email protected]'])->persist();
$this->exec('passbolt email_digest preview --body');
$this->assertExitSuccess();
$this->assertOutputContains('Sending email to: ' . $email->get('email'));
$this->assertOutputContains(AvatarHelper::getAvatarFallBackUrl());
}
}
Function Calls
None |
Stats
MD5 | 19a3e93fe0df9c5c5f877f22430fc921 |
Eval Count | 0 |
Decode Time | 80 ms |