You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

78 lines
2.1 KiB

# -*- coding: utf-8 -*-
# Copyright 2016-2017 Versada <https://versada.eu/>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import unittest2
import mock
from ..logutils import SanitizeOdooCookiesProcessor
class TestOdooCookieSanitizer(unittest2.TestCase):
def test_cookie_as_string(self):
data = {
'request': {
'cookies': 'website_lang=en_us;'
'session_id=hello;'
'Session_ID=hello;'
'foo=bar',
},
}
proc = SanitizeOdooCookiesProcessor(mock.Mock())
result = proc.process(data)
self.assertTrue('request' in result)
http = result['request']
self.assertEqual(
http['cookies'],
'website_lang=en_us;'
'session_id={m};'
'Session_ID={m};'
'foo=bar'.format(
m=proc.MASK,
),
)
def test_cookie_as_string_with_partials(self):
data = {
'request': {
'cookies': 'website_lang=en_us;session_id;foo=bar',
},
}
proc = SanitizeOdooCookiesProcessor(mock.Mock())
result = proc.process(data)
self.assertTrue('request' in result)
http = result['request']
self.assertEqual(
http['cookies'],
'website_lang=en_us;session_id;foo=bar'.format(m=proc.MASK),
)
def test_cookie_header(self):
data = {
'request': {
'headers': {
'Cookie': 'foo=bar;'
'session_id=hello;'
'Session_ID=hello;'
'a_session_id_here=hello',
},
},
}
proc = SanitizeOdooCookiesProcessor(mock.Mock())
result = proc.process(data)
self.assertTrue('request' in result)
http = result['request']
self.assertEqual(
http['headers']['Cookie'],
'foo=bar;'
'session_id={m};'
'Session_ID={m};'
'a_session_id_here={m}'.format(m=proc.MASK))