Bug 20568: (QA follow-up) Test client_id and secret are not overwritten
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 18 Apr 2018 16:56:00 +0000 (13:56 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 9 May 2018 15:55:59 +0000 (12:55 -0300)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/Koha/ApiKeys.t

index 08f7ee9..7becc0d 100755 (executable)
@@ -35,7 +35,7 @@ my $uuid_gen_secret_counter    = 0;
 
 subtest 'store() tests' => sub {
 
-    plan tests => 9;
+    plan tests => 13;
 
     $schema->storage->txn_begin;
 
@@ -65,6 +65,16 @@ subtest 'store() tests' => sub {
     is( $api_key->description, $description, 'Description is correctly stored' );
     is( $api_key->active,      1,            'Key is active by default' );
 
+    # revoke, to call store
+    my $original_api_key = $api_key->unblessed;
+    $api_key->active(0)->store;
+    $api_key->discard_changes;
+
+    is( $api_key->client_id, $original_api_key->{client_id}, '->store() preserves the client_id' );
+    is( $api_key->secret, $original_api_key->{secret}, '->store() preserves the secret' );
+    is( $api_key->patron_id, $original_api_key->{patron_id}, '->store() preserves the patron_id' );
+    is( $api_key->active, 0, '->store() preserves the active value' );
+
     my $patron_to_delete = $builder->build_object( { class => 'Koha::Patrons' } );
     my $deleted_id = $patron_to_delete->id;
     $patron_to_delete->delete;