diff options
author | David Cramer <dcramer@gmail.com> | 2012-01-19 16:16:11 -0800 |
---|---|---|
committer | David Cramer <dcramer@gmail.com> | 2012-01-19 16:16:11 -0800 |
commit | cae3c5dad0fc0f3998e15d03ebf85e99c2f07642 (patch) | |
tree | 05a6ef73cf5561fbc1b8ee93a7c70dc1b64a0583 /tests/processors | |
parent | 94e822e67f3550710347f563ae1d32e301d2e08b (diff) | |
download | raven-cae3c5dad0fc0f3998e15d03ebf85e99c2f07642.tar.gz |
Improve SanitizePasswordsProcessor to handle http data
Diffstat (limited to 'tests/processors')
-rw-r--r-- | tests/processors/__init__.py | 0 | ||||
-rw-r--r-- | tests/processors/tests.py | 89 |
2 files changed, 89 insertions, 0 deletions
diff --git a/tests/processors/__init__.py b/tests/processors/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/processors/__init__.py diff --git a/tests/processors/tests.py b/tests/processors/tests.py new file mode 100644 index 0000000..948461c --- /dev/null +++ b/tests/processors/tests.py @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- + +from mock import Mock +from unittest2 import TestCase +from raven.processors import SantizePasswordsProcessor + + +class SantizePasswordsProcessorTest(TestCase): + def test_stacktrace(self): + data = { + 'sentry.interfaces.Stacktrace': { + 'frames': [ + { + 'vars': { + 'foo': 'bar', + 'password': 'hello', + 'the_secret': 'hello', + 'a_password_here': 'hello', + }, + } + ] + } + } + + proc = SantizePasswordsProcessor(Mock()) + result = proc.process(data) + + self.assertTrue('sentry.interfaces.Stacktrace' in result) + stack = result['sentry.interfaces.Stacktrace'] + self.assertTrue('frames' in stack) + self.assertEquals(len(stack['frames']), 1) + frame = stack['frames'][0] + self.assertTrue('vars' in frame) + vars = frame['vars'] + self.assertTrue('foo' in vars) + self.assertEquals(vars['foo'], 'bar') + self.assertTrue('password' in vars) + self.assertEquals(vars['password'], proc.MASK) + self.assertTrue('the_secret' in vars) + self.assertEquals(vars['the_secret'], proc.MASK) + self.assertTrue('a_password_here' in vars) + self.assertEquals(vars['a_password_here'], proc.MASK) + + def test_http(self): + data = { + 'sentry.interfaces.Http': { + 'data': { + 'foo': 'bar', + 'password': 'hello', + 'the_secret': 'hello', + 'a_password_here': 'hello', + }, + 'env': { + 'foo': 'bar', + 'password': 'hello', + 'the_secret': 'hello', + 'a_password_here': 'hello', + }, + 'headers': { + 'foo': 'bar', + 'password': 'hello', + 'the_secret': 'hello', + 'a_password_here': 'hello', + }, + 'cookies': { + 'foo': 'bar', + 'password': 'hello', + 'the_secret': 'hello', + 'a_password_here': 'hello', + }, + } + } + + proc = SantizePasswordsProcessor(Mock()) + result = proc.process(data) + + self.assertTrue('sentry.interfaces.Http' in result) + http = result['sentry.interfaces.Http'] + for n in ('data', 'env', 'headers', 'cookies'): + self.assertTrue(n in http) + vars = http[n] + self.assertTrue('foo' in vars) + self.assertEquals(vars['foo'], 'bar') + self.assertTrue('password' in vars) + self.assertEquals(vars['password'], proc.MASK) + self.assertTrue('the_secret' in vars) + self.assertEquals(vars['the_secret'], proc.MASK) + self.assertTrue('a_password_here' in vars) + self.assertEquals(vars['a_password_here'], proc.MASK) |