Bug 20624: (QA follow-up) Unit tests for missing deps situation
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 3 May 2018 18:24:56 +0000 (15:24 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 9 May 2018 15:56:02 +0000 (12:56 -0300)
commita8579ac6c4fac0a660b506949bc47fcc7faf7674
tree4dc86b76d15d054ded71b21d119c6c4054b87d79
parent5cf8bbfb7aea34b6367dfbbfb9d73f88851507fb
Bug 20624: (QA follow-up) Unit tests for missing deps situation

This patch tests the situation in which Net::OAuth2::AuthorizationServer
is missing. It mocks Module::Load::Conditional::can_load and expects the
/token endpoint answers 'Unimplemented grant type' to all requests, and
the 'authenticate_api_request' in 'under' exit with unauthorized (403)
to requests in which the Authorization header is passed containing a
Bearer token, but OAuth2 is not really available.

To test:
- Apply this patch
- Run:
  $ kshell
 k$ prove t/db_dependent/api/v1/oauth.t
=> FAIL: Tests fail because our REST endpoints don't support this
behaviour.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/api/v1/oauth.t