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

(-)a/t/db_dependent/api/v1/auth_authenticate_api_request.t (-2 / +20 lines)
Lines 100-106 subtest 'token-based tests' => sub { Link Here
100
100
101
subtest 'cookie-based tests' => sub {
101
subtest 'cookie-based tests' => sub {
102
102
103
    plan tests => 5;
103
    plan tests => 6;
104
104
105
    $schema->storage->txn_begin;
105
    $schema->storage->txn_begin;
106
106
Lines 119-124 subtest 'cookie-based tests' => sub { Link Here
119
    is( ref($user), 'Koha::Patron', 'Stashed koha.user object type is Koha::Patron') and
119
    is( ref($user), 'Koha::Patron', 'Stashed koha.user object type is Koha::Patron') and
120
    is( $user->borrowernumber, $borrowernumber, 'The stashed user is the right one' );
120
    is( $user->borrowernumber, $borrowernumber, 'The stashed user is the right one' );
121
121
122
    subtest 'logged-out tests' => sub {
123
        plan tests => 3;
124
125
        # Generate an anonymous session
126
        my $session = C4::Auth::get_session('');
127
        $session->param( 'ip',          $remote_address );
128
        $session->param( 'lasttime',    time() );
129
        $session->param( 'sessiontype', 'anon' );
130
        $session->flush;
131
132
        my $tx = $t->ua->build_tx( GET => '/api/v1/libraries' );
133
        $tx->req->cookies({ name => 'CGISESSID', value => $session->id });
134
        $tx->req->env({ REMOTE_ADDR => $remote_address });
135
136
        $t->request_ok($tx)
137
          ->status_is( 401, 'Anonymous session on permission protected resource returns 401' )
138
          ->json_is( { error => 'Authentication failure.' } );
139
    };
140
122
    $schema->storage->txn_rollback;
141
    $schema->storage->txn_rollback;
123
};
142
};
124
143
125
- 

Return to bug 24862