|
Lines 17-28
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 1; |
20 |
use Test::More tests => 2; |
| 21 |
|
21 |
|
| 22 |
use Template::Context; |
22 |
use Template::Context; |
| 23 |
use Template::Stash; |
23 |
use Template::Stash; |
| 24 |
|
24 |
|
| 25 |
use C4::Auth; |
25 |
use C4::Auth; |
|
|
26 |
use Koha::Cache::Memory::Lite; |
| 26 |
use Koha::Database; |
27 |
use Koha::Database; |
| 27 |
use Koha::Template::Plugin::Koha; |
28 |
use Koha::Template::Plugin::Koha; |
| 28 |
|
29 |
|
|
Lines 47-49
subtest 'GenerateCSRF() tests' => sub {
Link Here
|
| 47 |
|
48 |
|
| 48 |
$schema->storage->txn_rollback; |
49 |
$schema->storage->txn_rollback; |
| 49 |
}; |
50 |
}; |
| 50 |
- |
51 |
|
|
|
52 |
subtest 'GenerateCSRF - New CSRF token generated everytime we need one' => sub { |
| 53 |
plan tests => 2; |
| 54 |
|
| 55 |
$schema->storage->txn_begin; |
| 56 |
|
| 57 |
my $session = C4::Auth::get_session(''); |
| 58 |
|
| 59 |
my $stash = Template::Stash->new( { sessionID => $session->id } ); |
| 60 |
my $context = Template::Context->new( { STASH => $stash } ); |
| 61 |
|
| 62 |
my $plugin = Koha::Template::Plugin::Koha->new($context); |
| 63 |
|
| 64 |
my $token = $plugin->GenerateCSRF; |
| 65 |
|
| 66 |
is( $plugin->GenerateCSRF, $token, 'the token is cached and no new one generate' ); |
| 67 |
|
| 68 |
Koha::Cache::Memory::Lite->flush(); |
| 69 |
|
| 70 |
isnt( |
| 71 |
$plugin->GenerateCSRF, $token, |
| 72 |
'new token generated after the cache is flushed' |
| 73 |
); |
| 74 |
|
| 75 |
$schema->storage->txn_rollback; |
| 76 |
|
| 77 |
}; |