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

(-)a/t/db_dependent/api/v1/oauth.t (-2 / +13 lines)
Lines 31-37 my $schema = Koha::Database->new->schema; Link Here
31
my $builder = t::lib::TestBuilder->new();
31
my $builder = t::lib::TestBuilder->new();
32
32
33
subtest '/oauth/token tests' => sub {
33
subtest '/oauth/token tests' => sub {
34
    plan tests => 24;
34
    plan tests => 27;
35
35
36
    $schema->storage->txn_begin;
36
    $schema->storage->txn_begin;
37
37
Lines 51-56 subtest '/oauth/token tests' => sub { Link Here
51
        ->status_is(400)
51
        ->status_is(400)
52
        ->json_is({error => 'Unimplemented grant type'});
52
        ->json_is({error => 'Unimplemented grant type'});
53
53
54
    t::lib::Mocks::mock_preference('RESTOAuth2ClientCredentials', 1);
55
54
    # No client_id/client_secret
56
    # No client_id/client_secret
55
    $t->post_ok('/api/v1/oauth/token', form => { grant_type => 'client_credentials' })
57
    $t->post_ok('/api/v1/oauth/token', form => { grant_type => 'client_credentials' })
56
        ->status_is(403)
58
        ->status_is(403)
Lines 99-103 subtest '/oauth/token tests' => sub { Link Here
99
        ->status_is(403)
101
        ->status_is(403)
100
        ->json_is({ error => 'unauthorized_client' });
102
        ->json_is({ error => 'unauthorized_client' });
101
103
104
    # disable client credentials grant
105
    t::lib::Mocks::mock_preference('RESTOAuth2ClientCredentials', 0);
106
107
    # enable API key
108
    $api_key->active(1)->store;
109
    # Wrong grant type
110
    $t->post_ok('/api/v1/oauth/token', form => $formData )
111
        ->status_is(400)
112
        ->json_is({ error => 'Unimplemented grant type' });
113
102
    $schema->storage->txn_rollback;
114
    $schema->storage->txn_rollback;
103
};
115
};
104
- 

Return to bug 20624