diff options
author | Abhishek Patel <abhidgreat8394@gmail.com> | 2019-04-21 12:09:00 -0700 |
---|---|---|
committer | Abhishek Patel <abhidgreat8394@gmail.com> | 2019-04-21 12:09:00 -0700 |
commit | 5ae97b984f9fe29717c125c205f79c87c6370613 (patch) | |
tree | daabb9bde019b38cf9e3eaaa97714202c8d5cf17 /tests | |
parent | 81a295de0d00abb37699b6ce6c75737a78b12458 (diff) | |
download | oauthlib-5ae97b984f9fe29717c125c205f79c87c6370613.tar.gz |
Add method to get/set debug flag
- By default debug mode is always off
- Debug mode turned on automatically for tests
- Complete requests sanitized in non debug mode
Diffstat (limited to 'tests')
-rw-r--r-- | tests/__init__.py | 3 | ||||
-rw-r--r-- | tests/test_common.py | 16 |
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py index e69de29..f33236b 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -0,0 +1,3 @@ +import oauthlib + +oauthlib.set_debug(True) diff --git a/tests/test_common.py b/tests/test_common.py index 20d9f5b..ae2531b 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -1,8 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals +import os import sys +import oauthlib from oauthlib.common import (CaseInsensitiveDict, Request, add_params_to_uri, extract_params, generate_client_id, generate_nonce, generate_timestamp, @@ -214,6 +216,20 @@ class RequestTest(TestCase): self.assertEqual(r.headers['token'], 'foobar') self.assertEqual(r.token, 'banana') + def test_sanitized_request_non_debug_mode(self): + """make sure requests are sanitized when in non debug mode. + For the debug mode, the other tests checking sanitization should prove + that debug mode is working. + """ + try: + oauthlib.set_debug(False) + r = Request(URI, headers={'token': 'foobar'}, body='token=banana') + self.assertNotIn('token', repr(r)) + self.assertIn('SANITIZED', repr(r)) + finally: + # set flag back for other tests + oauthlib.set_debug(True) + class CaseInsensitiveDictTest(TestCase): |