Пример #1
0
    def test_subject_cookie(self):
        # the subject token is extracted from the cookie and 
        # made available as part of the request.
        cookie = make_cookie()
        add_value(cookie, SUBJECT_COOKIE_NAME, 'mycookie', 60, True)

        env = {'HTTP_COOKIE': get_value(cookie)}
        request = Request(env)
        self.assertEqual(request.subject, 'mycookie')
Пример #2
0
    def test_subject_cookie(self):
        # the subject token is extracted from the cookie and
        # made available as part of the request.
        cookie = make_cookie()
        add_value(cookie, SUBJECT_COOKIE_NAME, 'mycookie', 60, True)

        env = {'HTTP_COOKIE': get_value(cookie)}
        request = Request(env)
        self.assertEqual(request.subject, 'mycookie')
Пример #3
0
    def test_create_not_secure_cookie(self):
        logger = logging.getLogger('zoom.cookies')

        cookie = http.cookies.SimpleCookie()
        add_value(cookie, SESSION_COOKIE_NAME, 'mysession', 60, False)
        add_value(cookie, SUBJECT_COOKIE_NAME, 'mysubject', 60, False)
        cookie = str(cookie)
        logger.info(cookie)

        self.assertIn('Set-Cookie:', cookie)
        self.assertIn('zoom_session=mysession', cookie)
        self.assertIn('expires=', cookie)
        self.assertIn('HttpOnly', cookie)
        self.assertIn('Path=/', cookie)
        self.assertNotIn('Secure', cookie)
Пример #4
0
    def test_create_not_secure_cookie(self):
        logger = logging.getLogger('zoom.cookies')

        cookie = make_cookie()
        add_value(cookie, SESSION_COOKIE_NAME, 'mysession', 60, False)
        add_value(cookie, SUBJECT_COOKIE_NAME, 'mysubject', 60, False)
        logger.info(str(cookie))

        cookie2 = Cookie.SimpleCookie()
        cookie2[SESSION_COOKIE_NAME] = 'mysession'
        cookie2[SESSION_COOKIE_NAME]['httponly'] = True
        cookie2[SESSION_COOKIE_NAME]['expires'] = 60
        cookie2[SUBJECT_COOKIE_NAME] = 'mysubject'
        cookie2[SUBJECT_COOKIE_NAME]['httponly'] = True
        cookie2[SUBJECT_COOKIE_NAME]['expires'] = 60
        logger.info(str(cookie2))

        self.assertEqual(str(cookie), str(cookie2))
Пример #5
0
    def test_create_not_secure_cookie(self):
        logger = logging.getLogger('zoom.cookies')

        cookie = make_cookie()
        add_value(cookie, SESSION_COOKIE_NAME, 'mysession', 60, False)
        add_value(cookie, SUBJECT_COOKIE_NAME, 'mysubject', 60, False)
        logger.info(str(cookie))

        cookie2 = Cookie.SimpleCookie()
        cookie2[SESSION_COOKIE_NAME] = 'mysession'
        cookie2[SESSION_COOKIE_NAME]['httponly'] = True
        cookie2[SESSION_COOKIE_NAME]['expires'] = 60
        cookie2[SUBJECT_COOKIE_NAME] = 'mysubject'
        cookie2[SUBJECT_COOKIE_NAME]['httponly'] = True
        cookie2[SUBJECT_COOKIE_NAME]['expires'] = 60
        logger.info(str(cookie2))

        self.assertEqual(str(cookie), str(cookie2))