Create fake session to write csp nonces to it
`Csp::createnonces()` writes to a window aware session and hence a fake base session is created in `BaseTestCase::setUp()` method
This commit is contained in:
parent
282b4d564a
commit
33b6c01fe2
|
@ -75,6 +75,7 @@ class Test extends Cli
|
|||
|
||||
// Conflicts with `Tests\Icinga\Module\...\Lib`. But it seems it's not needed anyway...
|
||||
//$this->getLoader()->registerNamespace('Tests', $this->getBaseDir('test/php/library'));
|
||||
$this->getLoader()->registerNamespace('Tests\\Icinga\\Lib', $this->getBaseDir('test/php/Lib'));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,10 @@
|
|||
namespace Icinga\Test {
|
||||
|
||||
use Exception;
|
||||
use Icinga\Util\Csp;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Web\Response;
|
||||
use Icinga\Web\Session;
|
||||
use ipl\I18n\NoopTranslator;
|
||||
use ipl\I18n\StaticTranslator;
|
||||
use RuntimeException;
|
||||
|
@ -14,6 +16,7 @@ namespace Icinga\Test {
|
|||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Data\Db\DbConnection;
|
||||
use Tests\Icinga\Lib\FakeSession;
|
||||
|
||||
/**
|
||||
* Class BaseTestCase
|
||||
|
@ -108,6 +111,8 @@ namespace Icinga\Test {
|
|||
parent::setUp();
|
||||
$this->setupRequestMock();
|
||||
$this->setupResponseMock();
|
||||
Session::create(new FakeSession());
|
||||
Csp::createNonce();
|
||||
|
||||
StaticTranslator::$instance = new NoopTranslator();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Icinga\Lib;
|
||||
|
||||
use Icinga\Web\Session\Session;
|
||||
|
||||
class FakeSession extends Session
|
||||
{
|
||||
public function read()
|
||||
{
|
||||
}
|
||||
|
||||
public function exists()
|
||||
{
|
||||
}
|
||||
|
||||
public function purge()
|
||||
{
|
||||
}
|
||||
|
||||
public function refreshId()
|
||||
{
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return '1234567890';
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue