Ejemplo n.º 1
0
 def test_mix_unmix(self):
     dough = mix(self.exp, self.data)
     exp, data = unmix(dough)
     self.assertEqual(data, self.data)
     # we are comparing seconds here, ten-thousandth
     # second should be enough.
     self.assertAlmostEqual(exp, self.exp, places=4)
Ejemplo n.º 2
0
 def test_mix_unmix(self):
     dough = mix(self.exp, self.data)
     exp, data = unmix(dough)
     self.assertEqual(data, self.data)
     # we are comparing seconds here, ten-thousandth
     # second should be enough.
     self.assertAlmostEqual(exp, self.exp, places=4)
Ejemplo n.º 3
0
 def test_mix_unmix3(self):
     c = self.jar.makeCookie(self.exp, self.data)
     s = Cookie.SmartCookie()
     s.load(c.output())
     exp, data, digest = unmix3(s[self._token].value)
     self.failUnlessEqual(data, self.data)
     self.failUnlessEqual(float(exp), self.exp)
     key = self.jar._key     # Peeking...
     mac = binascii.b2a_base64(EVP.hmac(key, mix(self.exp, self.data), 'sha1'))[:-1]
     self.failUnlessEqual(digest, mac)
 def test_mix_unmix3(self):
     c = self.jar.makeCookie(self.exp, self.data)
     s = Cookie.SmartCookie()
     s.load(c.output())
     exp, data, digest = unmix3(s[self._token].value)
     self.failUnlessEqual(data, self.data)
     self.failUnlessEqual(float(exp), self.exp)
     key = self.jar._key     # Peeking...
     mac = binascii.b2a_base64(EVP.hmac(key, mix(self.exp, self.data), 'sha1'))[:-1]
     self.failUnlessEqual(digest, mac)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
 def test_make_cookie(self):
     c = self.jar.makeCookie(self.exp, self.data)
     self.failUnless(isinstance(c, AuthCookie))
     self.failUnlessEqual(c.expiry(), self.exp)
     self.failUnlessEqual(c.data(), self.data)
     # Peek inside the cookie jar...
     key = self.jar._key
     mac = binascii.b2a_base64(EVP.hmac(key, mix(self.exp, self.data), 'sha1'))[:-1]
     self.failUnlessEqual(c.mac(), mac)
     # Ok, stop peeking now.
     cookie_str = self._format % (repr(self.exp), self.data, mac)
     self.failUnlessEqual(c.output(), cookie_str)
 def test_make_cookie(self):
     c = self.jar.makeCookie(self.exp, self.data)
     self.failUnless(isinstance(c, AuthCookie))
     self.failUnlessEqual(c.expiry(), self.exp)
     self.failUnlessEqual(c.data(), self.data)
     # Peek inside the cookie jar...
     key = self.jar._key
     mac = binascii.b2a_base64(EVP.hmac(key, mix(self.exp, self.data), 'sha1'))[:-1]
     self.failUnlessEqual(c.mac(), mac)
     # Ok, stop peeking now.
     cookie_str = self._format % (repr(self.exp), self.data, mac)
     self.failUnlessEqual(c.output(), cookie_str)
Ejemplo n.º 9
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)
Ejemplo n.º 10
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)
Ejemplo n.º 11
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)
Ejemplo n.º 12
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)
Ejemplo n.º 13
0
 def test_mix_unmix(self):
     dough = mix(self.exp, self.data)
     exp, data = unmix(dough)
     self.failUnlessEqual(data, self.data)
     self.failUnlessEqual(exp, self.exp)
Ejemplo n.º 14
0
 def test_mix_unmix(self):
     dough = mix(self.exp, self.data)
     exp, data = unmix(dough)
     self.failUnlessEqual(data, self.data)
     self.failUnlessEqual(exp, self.exp)
Ejemplo n.º 15
0
 def test_mix_unmix(self):
     dough = mix(self.exp, self.data)
     exp, data = unmix(dough)
     self.assertEqual(data, self.data)
     self.assertEqual(exp, self.exp)
Ejemplo n.º 16
0
 def test_mix_unmix(self):
     dough = mix(self.exp, self.data)
     exp, data = unmix(dough)
     self.assertEqual(data, self.data)
     self.assertEqual(exp, self.exp)