Bugzilla – Attachment 74987 Details for
Bug 20624
Disable the OAuth2 client credentials grant by default
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20624: Unit tests
Bug-20624-Unit-tests.patch (text/plain), 1.91 KB, created by
Tomás Cohen Arazi (tcohen)
on 2018-05-02 19:00:29 UTC
(
hide
)
Description:
Bug 20624: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2018-05-02 19:00:29 UTC
Size:
1.91 KB
patch
obsolete
>From 7d04f21fbe44442f54d2f937ac82aa227f2ce912 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 2 May 2018 15:21:53 -0300 >Subject: [PATCH] Bug 20624: Unit tests > >This patch adds tests to verify that disabling the RESTOAuth2ClientCredentials syspref >makes any request on the /api/v1/oauth/token using the >'client_credentials' grant fail with 'grant not implemented'. > >To test: >- Apply this patch >- Run: > $ kshell > k$ prove t/db_dependent/api/v1/oauth.t >=> FAIL: Tests fail because the change is not implemented! >--- > t/db_dependent/api/v1/oauth.t | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/oauth.t b/t/db_dependent/api/v1/oauth.t >index a07a2dba5d..e5762a2933 100755 >--- a/t/db_dependent/api/v1/oauth.t >+++ b/t/db_dependent/api/v1/oauth.t >@@ -31,7 +31,7 @@ my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new(); > > subtest '/oauth/token tests' => sub { >- plan tests => 24; >+ plan tests => 27; > > $schema->storage->txn_begin; > >@@ -51,6 +51,8 @@ subtest '/oauth/token tests' => sub { > ->status_is(400) > ->json_is({error => 'Unimplemented grant type'}); > >+ t::lib::Mocks::mock_preference('RESTOAuth2ClientCredentials', 1); >+ > # No client_id/client_secret > $t->post_ok('/api/v1/oauth/token', form => { grant_type => 'client_credentials' }) > ->status_is(403) >@@ -99,5 +101,15 @@ subtest '/oauth/token tests' => sub { > ->status_is(403) > ->json_is({ error => 'unauthorized_client' }); > >+ # disable client credentials grant >+ t::lib::Mocks::mock_preference('RESTOAuth2ClientCredentials', 0); >+ >+ # enable API key >+ $api_key->active(1)->store; >+ # Wrong grant type >+ $t->post_ok('/api/v1/oauth/token', form => $formData ) >+ ->status_is(400) >+ ->json_is({ error => 'Unimplemented grant type' }); >+ > $schema->storage->txn_rollback; > }; >-- >2.17.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20624
:
74986
|
74987
|
74988
|
74989
|
75020
|
75021
|
75060
|
75061
|
75062
|
75063
|
75064
|
75065
|
75132
|
75184
|
75206