23
23
'access_token' : 'oauth2 access token' ,
24
24
'custom_key1' : 'you should not see this' ,
25
25
'custom_key2' : 'you should not see this' ,
26
+ 'custom_key3' : {'mask' : 'This entire dict' }
26
27
}
27
28
28
29
@@ -37,6 +38,7 @@ def _will_throw_type_error(foo, **kwargs):
37
38
access_token = "secret stuff!" # NOQA F841
38
39
custom_key1 = "you shouldn't see this" # NOQA F841
39
40
custom_key2 = "you shouldn't see this" # NOQA F841
41
+ custom_key3 = "you shouldn't see this" # NOQA F841
40
42
41
43
# TypeError: unsupported operand type(s) for /: 'str' and 'str'
42
44
raise exception_class ()
@@ -84,7 +86,9 @@ def get_extra_data():
84
86
class SanitizeKeysProcessorTest (TestCase ):
85
87
86
88
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
+ )
88
92
self .proc = SanitizeKeysProcessor (client )
89
93
90
94
def _check_vars_sanitized (self , vars , MASK ):
@@ -95,6 +99,8 @@ def _check_vars_sanitized(self, vars, MASK):
95
99
self .assertEquals (vars ['custom_key1' ], MASK )
96
100
self .assertTrue ('custom_key2' in vars )
97
101
self .assertEquals (vars ['custom_key2' ], MASK )
102
+ self .assertTrue ('custom_key3' in vars )
103
+ self .assertEquals (vars ['custom_key3' ], MASK )
98
104
99
105
def test_stacktrace (self , * args , ** kwargs ):
100
106
data = get_stack_trace_data_real ()
@@ -131,14 +137,15 @@ def test_extra(self):
131
137
132
138
def test_querystring_as_string (self ):
133
139
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 '
135
141
result = self .proc .process (data )
136
142
137
143
self .assertTrue ('request' in result )
138
144
http = result ['request' ]
139
145
self .assertEquals (
140
146
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
+ )
142
149
143
150
def test_querystring_as_string_with_partials (self ):
144
151
data = get_http_data ()
@@ -147,11 +154,16 @@ def test_querystring_as_string_with_partials(self):
147
154
148
155
self .assertTrue ('request' in result )
149
156
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
+ )
151
161
152
162
def test_cookie_as_string (self ):
153
163
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;'
155
167
result = self .proc .process (data )
156
168
157
169
self .assertTrue ('request' in result )
@@ -167,7 +179,10 @@ def test_cookie_as_string_with_partials(self):
167
179
168
180
self .assertTrue ('request' in result )
169
181
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
+ )
171
186
172
187
def test_cookie_header (self ):
173
188
data = get_http_data ()
0 commit comments