zoom.cookies module

zoom.cookies

The following test is a bit lame because the timestamp makes it tricky to test. Ideally we’d pass in a timer somehow but the cookie module is handling the time calculation so without diving into the innards of the http.cookies module this is what we have right now.

>>> cookie = SimpleCookie()
>>> add_value(cookie, 'name1', 'value1', 60, True)
>>> v = get_value(cookie)
>>> v.startswith('name1=value1; expires=')
True
>>> v.endswith('; Secure')
True
>>> len(v)
77
zoom.cookies.add_value(cookie, name, value, lifespan, secure)

add a value to a cookie

zoom.cookies.get_cookies(raw_cookie)

extract cookies from raw cookie data

zoom.cookies.get_value(cookie)

get the value portion of a cookie

zoom.cookies.handler(request, handler, *rest)

Cookie handler

>>> request = zoom.utils.Bunch(
...     cookies=None,
...     session_timeout=1,
...     site=zoom.sites.Site(),
... )
>>> response = handler(request, lambda a: zoom.response.Response())
>>> 'zoom_session=' in str(response.cookie)
True
zoom.cookies.new_token()

generate a new subject ID

construct a session cookie

>>> response = zoom.response.HTMLResponse('my page')
>>> set_session_cookie(response, 'sessionid', 'subjectid', 60)
>>> 'zoom_session=sessionid' in str(response.cookie)
True
>>> 'Secure' in str(response.cookie)
True