From bd71fd6ef0caf7983ad4128d4029515d7e1b0328 Mon Sep 17 00:00:00 2001 From: Jonathan Huot Date: Thu, 26 Jul 2018 17:24:32 +0200 Subject: [PATCH] Added case where no error_uri is defined --- tests/test_oauth2.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_oauth2.py b/tests/test_oauth2.py index 26bc7de..c78445b 100644 --- a/tests/test_oauth2.py +++ b/tests/test_oauth2.py @@ -225,6 +225,21 @@ def test(): return None ) mocked.assert_called_once() + def test_fatal_error_no_page(self): + oauth = BottleOAuth2(self.app) + oauth.initialize(self.server) + + @self.app.route('/fooh') + @oauth.create_authorization_response() + def test(): return None + + with mock.patch("oauthlib.oauth2.Server.create_authorization_response", + side_effect=oauthlib.oauth2.InvalidClientIdError()) as mocked: + app_response = self.urlopen("/fooh") + self.assertEqual(app_response['code'], 500, "error is not handled by BottleOAuth2") + self.assertNotIn('Location', app_response['header']) + mocked.assert_called_once() + class test_create_revocation_decorators(ServerTestBase): def setUp(self):