Пример #1
0
 def test_from_cookieval_vary(self):
     middleware = self._makeOne('secret', 'thecookiename')
     middleware.vary = ('REMOTE_ADDR', 'HTTP_USER_AGENT', 'NONEXISTENT')
     environ = {'REMOTE_ADDR': '127.0.0.1', 'HTTP_USER_AGENT': 'Fluzbox'}
     tamper_key = 'secret127.0.0.1Fluzbox'
     import hmac
     h = hmac.new(tamper_key, _DEFAULT_BID).hexdigest()
     cookieval = '%s!%s' % (_DEFAULT_BID, h)
     browser_id = middleware.from_cookieval(environ, cookieval)
     self._assertBrowserId(browser_id)
Пример #2
0
 def test_from_cookieval_vary(self):
     middleware = self._makeOne('secret', 'thecookiename')
     middleware.vary = ('REMOTE_ADDR', 'HTTP_USER_AGENT', 'NONEXISTENT')
     environ = {'REMOTE_ADDR':'127.0.0.1', 'HTTP_USER_AGENT':'Fluzbox'}
     tamper_key = 'secret127.0.0.1Fluzbox'
     import hmac
     h = hmac.new(tamper_key, _DEFAULT_BID).hexdigest()
     cookieval = '%s!%s' % (_DEFAULT_BID, h)
     browser_id = middleware.from_cookieval(environ, cookieval)
     self._assertBrowserId(browser_id)
Пример #3
0
 def test_from_cookieval_bad(self):
     middleware = self._makeOne('secret', 'thecookiename')
     cookieval = 'badcookie'
     browser_id = middleware.from_cookieval({}, cookieval)
     self.assertEqual(browser_id, None)
Пример #4
0
 def test_from_cookieval_bad(self):
     middleware = self._makeOne('secret', 'thecookiename')
     cookieval = 'badcookie'
     browser_id = middleware.from_cookieval({}, cookieval)
     self.assertEqual(browser_id, None)