Skip to content

Commit 6c0c791

Browse files
committed
Add a test for filtered params.
1 parent fb331fc commit 6c0c791

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

oauthlib/oauth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
SIGNATURE_TYPE_AUTH_HEADER = u'AUTH_HEADER'
2121
SIGNATURE_TYPE_QUERY = u'QUERY'
2222

23+
2324
class OAuthClient(object):
2425
"""An OAuth client used to sign OAuth requests"""
2526
def __init__(self, client_key, client_secret,

tests/test_utils.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from __future__ import absolute_import
2+
3+
from .unittest import TestCase
4+
5+
from oauthlib.utils import *
6+
7+
8+
class UtilsTests(TestCase):
9+
10+
def test_filter_params(self):
11+
12+
@filter_params
13+
def special_test_function(params, realm=None):
14+
""" I am a special test function """
15+
return 'OAuth ' + ','.join(['='.join([k, v]) for k, v in params])
16+
17+
# check that the docstring got through
18+
self.assertEqual(special_test_function.__doc__, " I am a special test function ")
19+
20+
sample_params = [
21+
("notoauth", "shouldnotbehere"),
22+
("oauth_consumer_key", "9djdj82h48djs9d2"),
23+
("oauth_token", "kkk9d7dh3k39sjv7"),
24+
("notoautheither", "shouldnotbehere")
25+
]
26+
27+
# Check that the filtering works as per design.
28+
# Any param that does not start with 'oauth'
29+
# should not be present in the filtered params
30+
filtered_params = special_test_function(sample_params)
31+
self.assertFalse("notoauth" in filtered_params)
32+
self.assertTrue("oauth_consumer_key" in filtered_params)
33+
self.assertTrue("oauth_token" in filtered_params)
34+
self.assertFalse("notoautheither" in filtered_params)

0 commit comments

Comments
 (0)