From 1473775de26481cb22db6a5f54af9577af2db328 Mon Sep 17 00:00:00 2001 From: Qixiang Wan Date: Aug 03 2017 11:33:53 +0000 Subject: Fix test failure while testing with old werkzeug Exceptins in old versions of werkzeug doesn't include description in string representation, which causes the failure in #25. Fixes: #25 --- diff --git a/tests/test_auth.py b/tests/test_auth.py index 9352718..365c527 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -195,14 +195,13 @@ class TestLoadOpenIDCUserFromRequest(ModelsBaseTest): 'OIDC_CLAIM_iss': 'https://iddev.fedorainfracloud.org/openidc/', 'OIDC_CLAIM_scope': 'openid https://id.fedoraproject.org/scope/groups', } - with patch.object(odcs.auth.conf, - 'auth_openidc_required_scopes', - ['new-compose']): + + with patch.object(odcs.auth.conf, 'auth_openidc_required_scopes', ['new-compose']): with app.test_request_context(environ_base=environ_base): - self.assertRaisesRegexp( - Unauthorized, - 'Required OIDC scope new-compose not present.', - load_openidc_user, flask.request) + with self.assertRaises(Unauthorized) as ctx: + load_openidc_user(flask.request) + self.assertEqual(ctx.exception.code, 401) + self.assertEqual(ctx.exception.description, 'Required OIDC scope new-compose not present.') class TestQueryLdapGroups(unittest.TestCase):