예제 #1
0
 def test_mix_unmix3(self):
     c = self.jar.makeCookie(self.exp, self.data)
     s = SimpleCookie()
     s.load(c.output())
     exp, data, digest = unmix3(s[self._token].value)
     self.assertEqual(data, self.data)
     self.assertEqual(float(exp), self.exp)
     key = self.jar._key  # Peeking...
     mac = util.bin_to_hex(
         EVP.hmac(key, util.py3bytes(mix(self.exp, self.data)), 'sha1'))
     self.assertEqual(digest, mac)
예제 #2
0
 def test_mix_unmix3(self):
     c = self.jar.makeCookie(self.exp, self.data)
     s = SimpleCookie()
     s.load(c.output(header=""))
     exp, data, digest = unmix3(s[self._token].value)
     self.assertEqual(data, self.data)
     # see comment in test_mix_unmix
     self.assertAlmostEqual(exp, self.exp, places=4)
     key = self.jar._key  # pylint: disable=protected-access
     mac = util.bin_to_hex(
         EVP.hmac(key, six.ensure_binary(mix(self.exp, self.data)), 'sha1'))
     self.assertEqual(digest, mac)
예제 #3
0
 def test_mix_unmix3(self):
     c = self.jar.makeCookie(self.exp, self.data)
     s = SimpleCookie()
     s.load(c.output(header=""))
     exp, data, digest = unmix3(s[self._token].value)
     self.assertEqual(data, self.data)
     # see comment in test_mix_unmix
     self.assertAlmostEqual(exp, self.exp, places=4)
     key = self.jar._key     # pylint: disable=protected-access
     mac = util.bin_to_hex(
         EVP.hmac(key, util.py3bytes(mix(self.exp, self.data)), 'sha1'))
     self.assertEqual(digest, mac)
예제 #4
0
 def test_make_cookie(self):
     c = self.jar.makeCookie(self.exp, self.data)
     self.assertTrue(isinstance(c, AuthCookie))
     self.assertEqual(c.expiry(), self.exp)
     self.assertEqual(c.data(), self.data)
     # Peek inside the cookie jar...
     key = self.jar._key  # pylint: disable=protected-access
     mac = util.bin_to_hex(
         EVP.hmac(key, six.ensure_binary(mix(self.exp, self.data)), 'sha1'))
     self.assertEqual(c.mac(), mac)
     # Ok, stop peeking now.
     cookie_str = self._format % (self.exp, self.data, mac)
     self.assertEqual(c.output(), cookie_str)
예제 #5
0
 def test_make_cookie(self):
     c = self.jar.makeCookie(self.exp, self.data)
     self.assertTrue(isinstance(c, AuthCookie))
     self.assertEqual(c.expiry(), self.exp)
     self.assertEqual(c.data(), self.data)
     # Peek inside the cookie jar...
     key = self.jar._key
     mac = util.bin_to_hex(
         EVP.hmac(key, util.py3bytes(mix(self.exp, self.data)), 'sha1'))
     self.assertEqual(c.mac(), mac)
     # Ok, stop peeking now.
     cookie_str = self._format % (repr(self.exp), self.data, mac)
     self.assertEqual(c.output(), cookie_str)
예제 #6
0
 def test_make_cookie(self):
     c = self.jar.makeCookie(self.exp, self.data)
     self.assertTrue(isinstance(c, AuthCookie))
     self.assertEqual(c.expiry(), self.exp)
     self.assertEqual(c.data(), self.data)
     # Peek inside the cookie jar...
     key = self.jar._key  # pylint: disable=protected-access
     mac = util.bin_to_hex(
         EVP.hmac(key, util.py3bytes(mix(self.exp, self.data)), 'sha1'))
     self.assertEqual(c.mac(), mac)
     # Ok, stop peeking now.
     cookie_str = self._format % (self.exp, self.data, mac)
     self.assertEqual(c.output(), cookie_str)
예제 #7
0
 def _hmac(self, key, data):
     # type: (bytes, str) -> str
     return util.bin_to_hex(m2.hmac(key, six.ensure_binary(data), m2.sha1()))
예제 #8
0
 def _hmac(self, key, data):
     # type: (bytes, str) -> str
     return util.bin_to_hex(m2.hmac(key, six.ensure_binary(data),
                                    m2.sha1()))
예제 #9
0
 def _hmac(self, key, data):
     # type: (bytes, str) -> str
     return util.bin_to_hex(m2.hmac(key, util.py3bytes(data), m2.sha1()))