Bugzilla – Attachment 95962 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), 3.58 KB, created by
Jonathan Druart
on 2019-12-03 18:11:17 UTC
(
hide
)
Description:
Bug 24151: Add tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2019-12-03 18:11:17 UTC
Size:
3.58 KB
patch
obsolete
>From 44efba88019a5a1f69a43c9fda115e42d728caf8 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 > >Sponsored-by: Association KohaLa - https://koha-fr.org/ >--- > t/db_dependent/Koha/Pseudonymization.t | 71 ++++++++++++++++++++++++++++++++++ > 1 file changed, 71 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..7c8140cee4 >--- /dev/null >+++ b/t/db_dependent/Koha/Pseudonymization.t >@@ -0,0 +1,71 @@ >+#!/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 Koha::Database; >+use Koha::Patrons; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'Koha::Anonymized::Patrons tests' => sub { >+ >+ plan tests => 9; >+ >+ $schema->storage->txn_begin; >+ >+ t::lib::Mocks::mock_config( 'key', '$2a$08$9lmorEKnwQloheaCLFIfje' ); >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $patron_info = $patron->unblessed; >+ delete $patron_info->{borrowernumber}; >+ $patron->delete; >+ >+ t::lib::Mocks::mock_preference( 'Pseudonymization', 0 ); >+ $patron = Koha::Patron->new($patron_info)->store; >+ my $anonymized = Koha::Anonymized::Patrons->find_from_borrowernumber( $patron->borrowernumber ); >+ is( $anonymized, undef, 'No anonymized patron if Pseudonymization is off' ); >+ $patron->delete; >+ >+ t::lib::Mocks::mock_preference( 'Pseudonymization', 1 ); >+ t::lib::Mocks::mock_preference( 'PseudonymizationPatronFields', 'branchcode,categorycode,sort1' ); >+ $patron = Koha::Patron->new($patron_info)->store; >+ $anonymized = Koha::Anonymized::Patrons->find_from_borrowernumber( $patron->borrowernumber ); >+ like( $anonymized->hashed_borrowernumber, qr{^\$2a\$08\$}, "The hashed_borrowernumber must be a bcrypt hash" ); >+ is( $anonymized->branchcode, $patron_info->{branchcode}, "branchcode should be copied" ); >+ is( $anonymized->categorycode, $patron_info->{categorycode}, "categorycode should be copied" ); >+ is( $anonymized->sort1, $patron_info->{sort1}, "sort1 should be copied" ); >+ is( $anonymized->country, undef, "country should not be copied" ); >+ is( $anonymized->sort2, undef, "sort2 should not be copied" ); >+ >+ my $hashed_borrowernumber = $anonymized->hashed_borrowernumber; >+ $patron->sort1("another sort1")->store; >+ $anonymized = Koha::Anonymized::Patrons->find_from_borrowernumber( $patron->borrowernumber ); >+ is( $anonymized->hashed_borrowernumber, $hashed_borrowernumber, "On update original hash should be preserved" ); >+ is( $patron->sort1, "another sort1", "correctly updated" ); >+ $patron->delete; >+ >+ $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