View | Details | Raw Unified | Return to bug 25045
Collapse All | Expand All

(-)a/t/db_dependent/api/v1/auth_authenticate_api_request.t (-2 / +34 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 2;
20
use Test::More tests => 3;
21
use Test::Mojo;
21
use Test::Mojo;
22
22
23
use Module::Load::Conditional qw(can_load);
23
use Module::Load::Conditional qw(can_load);
Lines 141-146 subtest 'cookie-based tests' => sub { Link Here
141
    $schema->storage->txn_rollback;
141
    $schema->storage->txn_rollback;
142
};
142
};
143
143
144
subtest 'anonymous requests to public API' => sub {
145
146
    plan tests => 4;
147
148
    $schema->storage->txn_begin;
149
150
    t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
151
152
    my $password = 'AbcdEFG123';
153
    my $userid   = 'tomasito';
154
    # Add a patron
155
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
156
    $patron->set_password({ password => $password });
157
    # Add a biblio
158
    my $biblio_id = $builder->build_sample_biblio()->biblionumber;
159
160
    # Enable the public API
161
    t::lib::Mocks::mock_preference( 'RESTPublicAPI', 1 );
162
    # Disable anonymous requests on the public namespace
163
    t::lib::Mocks::mock_preference( 'RESTPublicAnonymousRequests', 0 );
164
165
    $t->get_ok("/api/v1/public/biblios/" . $biblio_id => { Accept => 'application/marc' })
166
      ->status_is( 401, 'Unauthorized anonymous attempt to access a resource' );
167
168
    # Disable anonymous requests on the public namespace
169
    t::lib::Mocks::mock_preference( 'RESTPublicAnonymousRequests', 1 );
170
171
    $t->get_ok("/api/v1/public/biblios/" . $biblio_id => { Accept => 'application/marc' })
172
      ->status_is( 200, 'Successfull anonymous access to a resource' );
173
174
    $schema->storage->txn_rollback;
175
};
176
144
sub create_user_and_session {
177
sub create_user_and_session {
145
178
146
    my $args  = shift;
179
    my $args  = shift;
147
- 

Return to bug 25045