Bugzilla – Attachment 106035 Details for
Bug 24151
Add a pseudonymization process for patrons and transactions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24151: Add tests
Bug-24151-Add-tests.patch (text/plain), 4.14 KB, created by
Marcel de Rooy
on 2020-06-19 07:30:01 UTC
(
hide
)
Description:
Bug 24151: Add tests
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2020-06-19 07:30:01 UTC
Size:
4.14 KB
patch
obsolete
>From 5208aa176e86f424b7298effff8ef5b0539bfeed Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 26 Nov 2019 17:40:15 +0100 >Subject: [PATCH] Bug 24151: Add tests >Content-Type: text/plain; charset=utf-8 > >Sponsored-by: Association KohaLa - https://koha-fr.org/ > >Signed-off-by: Signed-off-by: Sonia Bouis <sonia.bouis@univ-lyon3.fr> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Koha/Pseudonymization.t | 79 ++++++++++++++++++++++++++++++++++ > 1 file changed, 79 insertions(+) > create mode 100644 t/db_dependent/Koha/Pseudonymization.t > >diff --git a/t/db_dependent/Koha/Pseudonymization.t b/t/db_dependent/Koha/Pseudonymization.t >new file mode 100644 >index 0000000000..99f6e2d40c >--- /dev/null >+++ b/t/db_dependent/Koha/Pseudonymization.t >@@ -0,0 +1,79 @@ >+#!/usr/bin/perl >+ >+# Copyright 2019 Koha Development team >+# >+# 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 C4::Circulation; >+ >+use Koha::Database; >+use Koha::DateUtils qw( dt_from_string ); >+use Koha::Patrons; >+use Koha::PseudonymizedTransactions; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'Koha::PseudonymizedTransactions tests' => sub { >+ >+ plan tests => 11; >+ >+ $schema->storage->txn_begin; >+ >+ t::lib::Mocks::mock_config( 'key', '$2a$08$9lmorEKnwQloheaCLFIfje' ); >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ t::lib::Mocks::mock_preference( 'Pseudonymization', 0 ); >+ my $item = $builder->build_sample_item; >+ t::lib::Mocks::mock_userenv({ branchcode => $item->homebranch }); >+ AddIssue( $patron->unblessed, $item->barcode, dt_from_string ); >+ AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string ); >+ my $pseudonymized= Koha::PseudonymizedTransactions->search( >+ { itemnumber => $item->itemnumber } )->next; >+ is( $pseudonymized, undef, >+ 'No pseudonymized transaction if Pseudonymization is off' ); >+ >+ t::lib::Mocks::mock_preference( 'Pseudonymization', 1 ); >+ t::lib::Mocks::mock_preference( 'PseudonymizationTransactionFields', 'datetime,transaction_branchcode,transaction_type,itemnumber,itemtype,holdingbranch,location,itemcallnumber,ccode' >+ ); >+ $item = $builder->build_sample_item; >+ t::lib::Mocks::mock_userenv({ branchcode => $item->homebranch }); >+ AddIssue( $patron->unblessed, $item->barcode, dt_from_string ); >+ AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string ); >+ my $statistic = Koha::Statistics->search( { itemnumber => $item->itemnumber } )->next; >+ $pseudonymized = Koha::PseudonymizedTransactions->search( { itemnumber => $item->itemnumber } )->next; >+ like( $pseudonymized->hashed_borrowernumber, >+ qr{^\$2a\$08\$}, "The hashed_borrowernumber must be a bcrypt hash" ); >+ is( $pseudonymized->datetime, $statistic->datetime ); >+ is( $pseudonymized->transaction_branchcode, $statistic->branch ); >+ is( $pseudonymized->transaction_type, $statistic->type ); >+ is( $pseudonymized->itemnumber, $item->itemnumber ); >+ is( $pseudonymized->itemtype, $item->effective_itemtype ); >+ is( $pseudonymized->holdingbranch, $item->holdingbranch ); >+ is( $pseudonymized->location, $item->location ); >+ is( $pseudonymized->itemcallnumber, $item->itemcallnumber ); >+ is( $pseudonymized->ccode, $item->ccode ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.11.0
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 24151
:
95959
|
95960
|
95961
|
95962
|
95963
|
95964
|
95965
|
95966
|
95967
|
95968
|
95969
|
95970
|
95971
|
95972
|
95973
|
95974
|
95975
|
95976
|
97240
|
97241
|
97242
|
97243
|
97244
|
97245
|
97246
|
97247
|
97248
|
97249
|
97250
|
97251
|
97252
|
101034
|
101035
|
101036
|
101037
|
101038
|
101039
|
101040
|
101041
|
101042
|
101043
|
101044
|
101045
|
101046
|
101047
|
101048
|
101049
|
105801
|
105802
|
105803
|
105804
|
105805
|
105806
|
105807
|
105808
|
105809
|
105810
|
105811
|
105812
|
105813
|
105814
|
105815
|
105816
|
106032
|
106033
|
106034
| 106035 |
106036
|
106037
|
106038
|
106039
|
106040
|
106041
|
106042
|
106043
|
106044
|
106045
|
106046
|
106047
|
106048
|
106049
|
106195
|
106255
|
107127
|
107225