Bugzilla – Attachment 162486 Details for
Bug 35955
New CSRF token generated everytime we need one
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35955: Add tests
Bug-35955-Add-tests.patch (text/plain), 1.71 KB, created by
Jonathan Druart
on 2024-02-27 07:57:07 UTC
(
hide
)
Description:
Bug 35955: Add tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-02-27 07:57:07 UTC
Size:
1.71 KB
patch
obsolete
>From 6aadc675290512c3481354001332b60753dadd35 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 27 Feb 2024 08:56:24 +0100 >Subject: [PATCH] Bug 35955: Add tests > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/Koha/Template/Plugin/Koha.t | 30 +++++++++++++++++++++- > 1 file changed, 29 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Template/Plugin/Koha.t b/t/db_dependent/Koha/Template/Plugin/Koha.t >index 98318bdd534..ff50b3580e0 100755 >--- a/t/db_dependent/Koha/Template/Plugin/Koha.t >+++ b/t/db_dependent/Koha/Template/Plugin/Koha.t >@@ -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; >+ >+}; >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35955
:
162485
|
162486
|
162511
|
162512