-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The Report.parse() method now removes sensitive report data returned from the API. By default the 'breakdown' and 'properties' values are removed. This behaviour can be overridden by setting ONFIDO_REPORT_SCRUBBER to an alternative function that takes the raw dict and updates it in whichever way you require.
- Loading branch information
1 parent
6534c6c
commit f84a986
Showing
5 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
import mock | ||
|
||
from django.test import TestCase, override_settings | ||
|
||
from ..settings import DEFAULT_REPORT_SCRUBBER | ||
|
||
|
||
class SettingsTests(TestCase): | ||
|
||
"""settings module tests.""" | ||
|
||
def test_default_report_scrubber(self): | ||
"""Test the report_scrubber default function.""" | ||
data = { | ||
'foo': 'bar', | ||
'breakdown': {}, | ||
'properties': {} | ||
} | ||
# default function should remove breakdown and properties | ||
data = DEFAULT_REPORT_SCRUBBER(data) | ||
self.assertFalse('breakdown' in data) | ||
self.assertFalse('properties' in data) | ||
|
||
# mock scrubber that does nothing and returns the data unchanged | ||
@mock.patch('onfido.settings.scrub_report_data', lambda d: d) | ||
def test_override_report_scrubber(self): | ||
"""Test the report_scrubber default function.""" | ||
data = { | ||
'foo': 'bar', | ||
'breakdown': {}, | ||
'properties': {} | ||
} | ||
# import here otherwise the mock is ineffective | ||
from ..settings import scrub_report_data | ||
# default function should remove breakdown and properties | ||
scrub_report_data(data) | ||
self.assertTrue('breakdown' in data) | ||
self.assertTrue('properties' in data) |