Lines 44-50
t::lib::Mocks::mock_preference( 'SessionStorage', 'tmp' );
Link Here
|
44 |
subtest 'token-based tests' => sub { |
44 |
subtest 'token-based tests' => sub { |
45 |
|
45 |
|
46 |
if ( can_load( modules => { 'Net::OAuth2::AuthorizationServer' => undef } ) ) { |
46 |
if ( can_load( modules => { 'Net::OAuth2::AuthorizationServer' => undef } ) ) { |
47 |
plan tests => 10; |
47 |
plan tests => 12; |
48 |
} |
48 |
} |
49 |
else { |
49 |
else { |
50 |
plan skip_all => 'Net::OAuth2::AuthorizationServer not available'; |
50 |
plan skip_all => 'Net::OAuth2::AuthorizationServer not available'; |
Lines 54-62
subtest 'token-based tests' => sub {
Link Here
|
54 |
|
54 |
|
55 |
my $patron = $builder->build_object({ |
55 |
my $patron = $builder->build_object({ |
56 |
class => 'Koha::Patrons', |
56 |
class => 'Koha::Patrons', |
57 |
value => { |
57 |
value => { flags => 1 }, |
58 |
flags => 16 # no permissions |
|
|
59 |
}, |
60 |
}); |
58 |
}); |
61 |
|
59 |
|
62 |
t::lib::Mocks::mock_preference('RESTOAuth2ClientCredentials', 1); |
60 |
t::lib::Mocks::mock_preference('RESTOAuth2ClientCredentials', 1); |
Lines 81-88
subtest 'token-based tests' => sub {
Link Here
|
81 |
|
79 |
|
82 |
my $stash; |
80 |
my $stash; |
83 |
|
81 |
|
84 |
my $tx = $t->ua->build_tx(GET => '/api/v1/patrons'); |
82 |
my $tx = $t->ua->build_tx(GET => '/api/v1/acquisitions/orders'); |
85 |
$tx->req->headers->authorization("Bearer $access_token"); |
83 |
$tx->req->headers->authorization("Bearer $access_token"); |
|
|
84 |
$tx->req->headers->header( 'x-koha-embed' => 'fund' ); |
86 |
|
85 |
|
87 |
$t->app->hook(after_dispatch => sub { $stash = shift->stash }); |
86 |
$t->app->hook(after_dispatch => sub { $stash = shift->stash }); |
88 |
$t->request_ok($tx)->status_is(200); |
87 |
$t->request_ok($tx)->status_is(200); |
Lines 92-97
subtest 'token-based tests' => sub {
Link Here
|
92 |
is( ref($user), 'Koha::Patron', 'Stashed koha.user object type is Koha::Patron') and |
91 |
is( ref($user), 'Koha::Patron', 'Stashed koha.user object type is Koha::Patron') and |
93 |
is( $user->borrowernumber, $patron->borrowernumber, 'The stashed user is the right one' ); |
92 |
is( $user->borrowernumber, $patron->borrowernumber, 'The stashed user is the right one' ); |
94 |
|
93 |
|
|
|
94 |
my $embed = $stash->{'koha.embed'}; |
95 |
ok( defined $embed, 'The embed hashref is generated and stashed' ); |
96 |
is_deeply( $embed, { fund => {} }, 'The embed data structure is correct' ); |
97 |
|
95 |
$schema->storage->txn_rollback; |
98 |
$schema->storage->txn_rollback; |
96 |
}; |
99 |
}; |
97 |
|
100 |
|
98 |
- |
|
|