Bug 35955: Add tests
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
108c955eac
commit
0631153f06
1 changed files with 29 additions and 1 deletions
|
@ -17,12 +17,13 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 1;
|
||||
use Test::More tests => 2;
|
||||
|
||||
use Template::Context;
|
||||
use Template::Stash;
|
||||
|
||||
use C4::Auth;
|
||||
use Koha::Cache::Memory::Lite;
|
||||
use Koha::Database;
|
||||
use Koha::Template::Plugin::Koha;
|
||||
|
||||
|
@ -47,3 +48,30 @@ subtest 'GenerateCSRF() tests' => sub {
|
|||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'GenerateCSRF - New CSRF token generated everytime we need one' => sub {
|
||||
plan tests => 2;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $session = C4::Auth::get_session('');
|
||||
|
||||
my $stash = Template::Stash->new( { sessionID => $session->id } );
|
||||
my $context = Template::Context->new( { STASH => $stash } );
|
||||
|
||||
my $plugin = Koha::Template::Plugin::Koha->new($context);
|
||||
|
||||
my $token = $plugin->GenerateCSRF;
|
||||
|
||||
is( $plugin->GenerateCSRF, $token, 'the token is cached and no new one generate' );
|
||||
|
||||
Koha::Cache::Memory::Lite->flush();
|
||||
|
||||
isnt(
|
||||
$plugin->GenerateCSRF, $token,
|
||||
'new token generated after the cache is flushed'
|
||||
);
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue