Пример #1
0
 def setUp(self):
     self.inner_app = inner_app
     test_key = binascii.hexlify(os.urandom(32))
     wrapped_app = SessionMiddleware(inner_app,
                                     's3krit',
                                     encryption_key=test_key)
     self.app = TestApp(wrapped_app)
Пример #2
0
 def setUp(self):
     self.inner_app = inner_app
     self.backend = {}
     wrapped_app = SessionMiddleware(inner_app,
                                     's3krit',
                                     backend=self.backend)
     self.app = TestApp(wrapped_app)
Пример #3
0
    def test_getset_basic(self):
        wrapped_app = SessionMiddleware(inner_app, 's3krit')
        app = TestApp(wrapped_app)

        app.get('/get/foo', status=404)

        resp = app.get('/set/foo/bar')
        resp.mustcontain('ok')

        resp = app.get('/get/foo')
        resp.mustcontain('bar')

        with self.assertRaises(ValueError):
            app.get('/set/quux/bogus-value?clientside=0')
Пример #4
0
 def test_non_hex_key(self):
     with self.assertRaises(ValueError):
         SessionMiddleware(self.inner_app,
                           's3krit',
                           encryption_key=('s' * 64))
Пример #5
0
 def test_wrong_key_length(self):
     with self.assertRaises(ValueError):
         SessionMiddleware(self.inner_app,
                           's3krit',
                           encryption_key=binascii.hexlify(os.urandom(20)))
Пример #6
0
 def test_bad_middleware_config(self):
     with self.assertRaises(ValueError):
         SessionMiddleware(inner_app, 's3krit', clientside=False)