2323 'access_token' : 'oauth2 access token' ,
2424 'custom_key1' : 'you should not see this' ,
2525 'custom_key2' : 'you should not see this' ,
26+ 'custom_key3' : {'mask' : 'This entire dict' }
2627}
2728
2829
@@ -37,6 +38,7 @@ def _will_throw_type_error(foo, **kwargs):
3738 access_token = "secret stuff!" # NOQA F841
3839 custom_key1 = "you shouldn't see this" # NOQA F841
3940 custom_key2 = "you shouldn't see this" # NOQA F841
41+ custom_key3 = "you shouldn't see this" # NOQA F841
4042
4143 # TypeError: unsupported operand type(s) for /: 'str' and 'str'
4244 raise exception_class ()
@@ -84,7 +86,9 @@ def get_extra_data():
8486class SanitizeKeysProcessorTest (TestCase ):
8587
8688 def setUp (self ):
87- client = Mock (sanitize_keys = ['custom_key1' , 'custom_key2' ])
89+ client = Mock (
90+ sanitize_keys = ['custom_key1' , 'custom_key2' , 'custom_key3' ]
91+ )
8892 self .proc = SanitizeKeysProcessor (client )
8993
9094 def _check_vars_sanitized (self , vars , MASK ):
@@ -95,6 +99,8 @@ def _check_vars_sanitized(self, vars, MASK):
9599 self .assertEquals (vars ['custom_key1' ], MASK )
96100 self .assertTrue ('custom_key2' in vars )
97101 self .assertEquals (vars ['custom_key2' ], MASK )
102+ self .assertTrue ('custom_key3' in vars )
103+ self .assertEquals (vars ['custom_key3' ], MASK )
98104
99105 def test_stacktrace (self , * args , ** kwargs ):
100106 data = get_stack_trace_data_real ()
@@ -131,14 +137,15 @@ def test_extra(self):
131137
132138 def test_querystring_as_string (self ):
133139 data = get_http_data ()
134- data ['request' ]['query_string' ] = 'foo=bar&custom_key1=nope&custom_key2=nope'
140+ data ['request' ]['query_string' ] = 'foo=bar&custom_key1=nope&custom_key2=nope&custom_key3=%7B%27key2%27%3A+%27nope%27%2C+%27key1%27%3A+%27nope%27%7D '
135141 result = self .proc .process (data )
136142
137143 self .assertTrue ('request' in result )
138144 http = result ['request' ]
139145 self .assertEquals (
140146 http ['query_string' ],
141- 'foo=bar&custom_key1=%(m)s&custom_key2=%(m)s' % {'m' : self .proc .MASK })
147+ "foo=bar&custom_key1=%(m)s&custom_key2=%(m)s&custom_key3=%(m)s" % {'m' : self .proc .MASK }
148+ )
142149
143150 def test_querystring_as_string_with_partials (self ):
144151 data = get_http_data ()
@@ -147,11 +154,16 @@ def test_querystring_as_string_with_partials(self):
147154
148155 self .assertTrue ('request' in result )
149156 http = result ['request' ]
150- self .assertEquals (http ['query_string' ], 'foo=bar&custom_key1&baz=bar' % {'m' : self .proc .MASK })
157+ self .assertEquals (
158+ http ['query_string' ],
159+ 'foo=bar&custom_key1&baz=bar' % {'m' : self .proc .MASK }
160+ )
151161
152162 def test_cookie_as_string (self ):
153163 data = get_http_data ()
154- data ['request' ]['cookies' ] = 'foo=bar;custom_key1=nope;custom_key2=nope;'
164+
165+ data ['request' ]['cookies' ] = \
166+ 'foo=bar;custom_key1=nope;custom_key2=nope;'
155167 result = self .proc .process (data )
156168
157169 self .assertTrue ('request' in result )
@@ -167,7 +179,10 @@ def test_cookie_as_string_with_partials(self):
167179
168180 self .assertTrue ('request' in result )
169181 http = result ['request' ]
170- self .assertEquals (http ['cookies' ], 'foo=bar;custom_key1;baz=bar' % dict (m = self .proc .MASK ))
182+ self .assertEquals (
183+ http ['cookies' ],
184+ 'foo=bar;custom_key1;baz=bar' % dict (m = self .proc .MASK )
185+ )
171186
172187 def test_cookie_header (self ):
173188 data = get_http_data ()
0 commit comments