Lines 39-50
my $t = Test::Mojo->new('Koha::REST::V1');
Link Here
|
39 |
my $tx; |
39 |
my $tx; |
40 |
|
40 |
|
41 |
subtest 'under() tests' => sub { |
41 |
subtest 'under() tests' => sub { |
42 |
plan tests => 15; |
42 |
|
|
|
43 |
plan tests => 20; |
43 |
|
44 |
|
44 |
$schema->storage->txn_begin; |
45 |
$schema->storage->txn_begin; |
45 |
|
46 |
|
46 |
my ($borrowernumber, $session_id) = create_user_and_session(); |
47 |
my ($borrowernumber, $session_id) = create_user_and_session(); |
47 |
|
48 |
|
|
|
49 |
# disable the /public namespace |
50 |
t::lib::Mocks::mock_preference( 'RESTPublicAPI', 0 ); |
51 |
$tx = $t->ua->build_tx( POST => "/api/v1/public/patrons/$borrowernumber/password" ); |
52 |
$tx->req->env( { REMOTE_ADDR => $remote_address } ); |
53 |
$t->request_ok($tx) |
54 |
->status_is(403) |
55 |
->json_is('/error', 'Configuration prevents the usage of this endpoint by unprivileged users'); |
56 |
|
57 |
# enable the /public namespace |
58 |
t::lib::Mocks::mock_preference( 'RESTPublicAPI', 1 ); |
59 |
$tx = $t->ua->build_tx( GET => "/api/v1/public/patrons/$borrowernumber/password" ); |
60 |
$tx->req->env( { REMOTE_ADDR => $remote_address } ); |
61 |
$t->request_ok($tx)->status_is(404); |
62 |
|
48 |
# 401 (no authentication) |
63 |
# 401 (no authentication) |
49 |
$tx = $t->ua->build_tx( GET => "/api/v1/patrons" ); |
64 |
$tx = $t->ua->build_tx( GET => "/api/v1/patrons" ); |
50 |
$tx->req->env( { REMOTE_ADDR => $remote_address } ); |
65 |
$tx->req->env( { REMOTE_ADDR => $remote_address } ); |
51 |
- |
|
|