Bugzilla – Attachment 125128 Details for
Bug 28772
Any user that can work with reports can see API keys of any other user
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28772: [19.11.x] Fix Koha/Object.t
Bug-28772-1911x-Fix-KohaObjectt.patch (text/plain), 4.19 KB, created by
Jonathan Druart
on 2021-09-22 08:24:10 UTC
(
hide
)
Description:
Bug 28772: [19.11.x] Fix Koha/Object.t
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-09-22 08:24:10 UTC
Size:
4.19 KB
patch
obsolete
>From bb1bca64b4398637fd1c1b7c1a231afa547a0314 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 21 Sep 2021 10:59:22 +0200 >Subject: [PATCH] Bug 28772: [19.11.x] Fix Koha/Object.t > >Koha::ApiKeys is no longer the simple object we need to test >Koha::Object->store, let use Koha::Library::Groups >--- > t/db_dependent/Koha/Object.t | 51 ++++++++++++++++++++---------------- > 1 file changed, 28 insertions(+), 23 deletions(-) > >diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t >index a6595b76aab..d6e50d41972 100755 >--- a/t/db_dependent/Koha/Object.t >+++ b/t/db_dependent/Koha/Object.t >@@ -30,7 +30,7 @@ use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); > use Koha::Libraries; > use Koha::Patrons; >-use Koha::ApiKeys; >+use Koha::Library::Groups; > > use Scalar::Util qw( isvstring ); > use Try::Tiny; >@@ -563,22 +563,27 @@ subtest 'store() tests' => sub { > > plan tests => 16; > >- # Using Koha::ApiKey to test Koha::Object>-store >+ # Using Koha::Library::Groups to test Koha::Object>-store > # Simple object with foreign keys and unique key > > $schema->storage->txn_begin; > >- # Create a patron to make sure its ID doesn't exist on the DB >- my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >- my $patron_id = $patron->id; >- $patron->delete; >+ # Create a library to make sure its ID doesn't exist on the DB >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $branchcode = $library->branchcode; >+ $library->delete; > >- my $api_key = Koha::ApiKey->new({ patron_id => $patron_id, secret => 'a secret', description => 'a description' }); >+ my $library_group = Koha::Library::Group->new( >+ { >+ branchcode => $library->branchcode, >+ title => 'a title', >+ } >+ ); > > my $print_error = $schema->storage->dbh->{PrintError}; > $schema->storage->dbh->{PrintError} = 0; > throws_ok >- { $api_key->store } >+ { $library_group->store } > 'Koha::Exceptions::Object::FKConstraint', > 'Exception is thrown correctly'; > is( >@@ -588,21 +593,21 @@ subtest 'store() tests' => sub { > ); > is( > $@->broken_fk, >- 'patron_id', >+ 'branchcode', > 'Exception field is correct' > ); > >- $patron = $builder->build_object({ class => 'Koha::Patrons' }); >- $api_key = $builder->build_object({ class => 'Koha::ApiKeys' }); >+ $library_group = $builder->build_object({ class => 'Koha::Library::Groups' }); > >- my $new_api_key = Koha::ApiKey->new({ >- patron_id => $patron_id, >- secret => $api_key->secret, >- description => 'a description', >- }); >+ my $new_library_group = Koha::Library::Group->new( >+ { >+ branchcode => $library_group->branchcode, >+ title => $library_group->title, >+ } >+ ); > > throws_ok >- { $new_api_key->store } >+ { $new_library_group->store } > 'Koha::Exceptions::Object::DuplicateID', > 'Exception is thrown correctly'; > >@@ -614,18 +619,18 @@ subtest 'store() tests' => sub { > > like( > $@->duplicate_id, >- qr/(api_keys\.)?secret/, >+ qr/(library_groups\.)?title/, > 'Exception field is correct (note that MySQL 8 is displaying the tablename)' > ); > > $schema->storage->dbh->{PrintError} = $print_error; > > # Successful test >- $api_key->set({ secret => 'Manuel' }); >- my $ret = $api_key->store; >- is( ref($ret), 'Koha::ApiKey', 'store() returns the object on success' ); >+ $library_group->set({ title => 'Manuel' }); >+ my $ret = $library_group->store; >+ is( ref($ret), 'Koha::Library::Group', 'store() returns the object on success' ); > >- my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ $library = $builder->build_object( { class => 'Koha::Libraries' } ); > my $patron_category = $builder->build_object( > { > class => 'Koha::Patron::Categories', >@@ -633,7 +638,7 @@ subtest 'store() tests' => sub { > } > ); > >- $patron = eval { >+ my $patron = eval { > Koha::Patron->new( > { > categorycode => $patron_category->categorycode, >-- >2.25.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 28772
:
124195
|
124247
|
124248
|
124249
|
124250
|
124251
|
124487
|
124488
|
124489
|
124490
|
124491
|
124691
|
124692
|
124693
|
124694
|
124695
|
124696
|
124697
|
124698
|
124699
|
124700
|
124701
|
124702
|
124703
|
124704
|
124705
|
124727
|
125088
|
125112
|
125116
|
125118
| 125128