Skip to content

Commit

Permalink
[#1941] More robust get_cookies test
Browse files Browse the repository at this point in the history
  • Loading branch information
brew committed Nov 14, 2014
1 parent 6623a73 commit 53e76cb
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions ckan/new_tests/lib/test_auth_tkt.py
Expand Up @@ -136,18 +136,26 @@ def _make_plugin(self, httponly):
reissue_time=None,
userid_checker=None)

def test_httponly_present(self):
'''HttpOnly flag should be present in cookie values.'''
def test_httponly_expected_cookies_with_httponly(self):
'''The returned cookies are still what we expect.'''
plugin = self._make_plugin(httponly=True)
cookies = plugin._get_cookies(environ={'SERVER_NAME': '0.0.0.0'},
value='ANYTHING')
for cookie in cookies:
assert 'HttpOnly' in cookie[1]
value='HELLO')
expected_cookies = [
('Set-Cookie', 'auth_tkt="HELLO"; Path=/; HttpOnly'),
('Set-Cookie', 'auth_tkt="HELLO"; Path=/; Domain=0.0.0.0; HttpOnly'),
('Set-Cookie', 'auth_tkt="HELLO"; Path=/; Domain=.0.0.0.0; HttpOnly')
]
assert cookies == expected_cookies

def test_httponly_absent(self):
'''HttpOnly flag should be absent in cookie values.'''
def test_httponly_expected_cookies_without_httponly(self):
'''The returned cookies are still what we expect.'''
plugin = self._make_plugin(httponly=False)
cookies = plugin._get_cookies(environ={'SERVER_NAME': '0.0.0.0'},
value='ANYTHING')
for cookie in cookies:
assert 'HttpOnly' not in cookie[1]
value='HELLO')
expected_cookies = [
('Set-Cookie', 'auth_tkt="HELLO"; Path=/'),
('Set-Cookie', 'auth_tkt="HELLO"; Path=/; Domain=0.0.0.0'),
('Set-Cookie', 'auth_tkt="HELLO"; Path=/; Domain=.0.0.0.0')
]
assert cookies == expected_cookies

0 comments on commit 53e76cb

Please sign in to comment.