forked from OCA/server-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_logutils.py
69 lines (57 loc) · 1.93 KB
/
test_logutils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright 2016-2017 Versada <https://versada.eu/>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests import TransactionCase
from ..logutils import SanitizeOdooCookiesProcessor
class TestOdooCookieSanitizer(TransactionCase):
def test_cookie_as_string(self):
data = {
"request": {
"cookies": "website_lang=en_us;"
"session_id=hello;"
"Session_ID=hello;"
"foo=bar"
}
}
proc = SanitizeOdooCookiesProcessor()
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()
result = proc.process(data)
self.assertTrue("request" in result)
http = result["request"]
self.assertEqual(
http["cookies"],
"website_lang=en_us;session_id;foo=bar",
)
def test_cookie_header(self):
data = {
"request": {
"headers": {
"Cookie": "foo=bar;"
"session_id=hello;"
"Session_ID=hello;"
"a_session_id_here=hello"
}
}
}
proc = SanitizeOdooCookiesProcessor()
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),
)