# 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 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.
+# 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, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# 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;
subtest 'token-based tests' => sub {
if ( can_load( modules => { 'Net::OAuth2::AuthorizationServer' => undef } ) ) {
- plan tests => 10;
+ plan tests => 12;
}
else {
plan skip_all => 'Net::OAuth2::AuthorizationServer not available';
my $patron = $builder->build_object({
class => 'Koha::Patrons',
- value => {
- flags => 16 # no permissions
- },
+ value => { flags => 1 },
});
t::lib::Mocks::mock_preference('RESTOAuth2ClientCredentials', 1);
my $stash;
- my $tx = $t->ua->build_tx(GET => '/api/v1/patrons');
+ my $tx = $t->ua->build_tx(GET => '/api/v1/acquisitions/orders');
$tx->req->headers->authorization("Bearer $access_token");
+ $tx->req->headers->header( 'x-koha-embed' => 'fund' );
$t->app->hook(after_dispatch => sub { $stash = shift->stash });
$t->request_ok($tx)->status_is(200);
is( ref($user), 'Koha::Patron', 'Stashed koha.user object type is Koha::Patron') and
is( $user->borrowernumber, $patron->borrowernumber, 'The stashed user is the right one' );
+ my $embed = $stash->{'koha.embed'};
+ ok( defined $embed, 'The embed hashref is generated and stashed' );
+ is_deeply( $embed, { fund => {} }, 'The embed data structure is correct' );
+
$schema->storage->txn_rollback;
};