summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBert JW Regeer <bertjw@regeer.org>2013-02-01 18:30:42 -0700
committerBert JW Regeer <bertjw@regeer.org>2013-02-02 00:42:54 -0700
commit54d31379c1c10879ba89b6616b033152d9bb69bf (patch)
treec004d1300f9d82984a3f4cf0aaa937321f1fe9bd
parentfbd5b4a8023f3ff3c42ab66b1a660d587e9c331b (diff)
downloadpyramid-54d31379c1c10879ba89b6616b033152d9bb69bf.tar.gz
pyramid-54d31379c1c10879ba89b6616b033152d9bb69bf.tar.bz2
pyramid-54d31379c1c10879ba89b6616b033152d9bb69bf.zip
Add tests for AuthTicket/parse_ticket for IPv6 compat
Add some simple tests that test IPv6 compatibility with the AuthTicket class and the parse_ticket function.
-rw-r--r--pyramid/tests/test_authentication.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/pyramid/tests/test_authentication.py b/pyramid/tests/test_authentication.py
index 37e088934..cfabf9a9d 100644
--- a/pyramid/tests/test_authentication.py
+++ b/pyramid/tests/test_authentication.py
@@ -1119,6 +1119,20 @@ class TestAuthTicket(unittest.TestCase):
self.assertEqual(result,
'66f9cc3e423dc57c91df696cf3d1f0d80000000auserid!a,b!')
+ def test_ipv4(self):
+ ticket = self._makeOne('secret', 'userid', '198.51.100.1',
+ time=10, hashalg='sha256')
+ result = ticket.cookie_value()
+ self.assertEqual(result, 'b3e7156db4f8abde4439c4a6499a0668f9e7ffd7fa27b'\
+ '798400ecdade8d76c530000000auserid!')
+
+ def test_ipv6(self):
+ ticket = self._makeOne('secret', 'userid', '2001:db8::1',
+ time=10, hashalg='sha256')
+ result = ticket.cookie_value()
+ self.assertEqual(result, 'd025b601a0f12ca6d008aa35ff3a22b7d8f3d1c1456c8'\
+ '5becf8760cd7a2fa4910000000auserid!')
+
class TestBadTicket(unittest.TestCase):
def _makeOne(self, msg, expected=None):
from pyramid.authentication import BadTicket
@@ -1162,6 +1176,19 @@ class Test_parse_ticket(unittest.TestCase):
result = self._callFUT('secret', ticket, '0.0.0.0', 'sha512')
self.assertEqual(result, (10, 'userid', ['a', 'b'], ''))
+ def test_ipv4(self):
+ ticket = 'b3e7156db4f8abde4439c4a6499a0668f9e7ffd7fa27b798400ecdade8d7'\
+ '6c530000000auserid!'
+ result = self._callFUT('secret', ticket, '198.51.100.1', 'sha256')
+ self.assertEqual(result, (10, 'userid', [''], ''))
+
+ def test_ipv6(self):
+ ticket = 'd025b601a0f12ca6d008aa35ff3a22b7d8f3d1c1456c85becf8760cd7a2f'\
+ 'a4910000000auserid!'
+ result = self._callFUT('secret', ticket, '2001:db8::1', 'sha256')
+ self.assertEqual(result, (10, 'userid', [''], ''))
+ pass
+
class TestSessionAuthenticationPolicy(unittest.TestCase):
def _getTargetClass(self):
from pyramid.authentication import SessionAuthenticationPolicy