Bug 30524: (QA follow-up) Unit tests for GenerateCSRF()
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 60d11ae7251a227fab3977ecd61cb01d0f062f79)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit d4187c77eb3b39977b759af7df7641e70cd96358)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
(cherry picked from commit 26ab7e0b20)
This commit is contained in:
parent
e038ec2709
commit
6729dc0dde
|
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
||||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 1;
|
||||
|
||||
use Template::Context;
|
||||
use Template::Stash;
|
||||
|
||||
use C4::Auth;
|
||||
use Koha::Database;
|
||||
use Koha::Template::Plugin::Koha;
|
||||
|
||||
my $schema = Koha::Database->new->schema;
|
||||
|
||||
subtest 'GenerateCSRF() tests' => sub {
|
||||
|
||||
plan tests => 1;
|
||||
|
||||
$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();
|
||||
|
||||
ok( Koha::Token->new->check_csrf( { session_id => $session->id, token => $token } ) );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
Loading…
Reference in New Issue