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)
def setUp(self): self.inner_app = inner_app self.backend = {} wrapped_app = SessionMiddleware(inner_app, 's3krit', backend=self.backend) self.app = TestApp(wrapped_app)
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')
def test_non_hex_key(self): with self.assertRaises(ValueError): SessionMiddleware(self.inner_app, 's3krit', encryption_key=('s' * 64))
def test_wrong_key_length(self): with self.assertRaises(ValueError): SessionMiddleware(self.inner_app, 's3krit', encryption_key=binascii.hexlify(os.urandom(20)))
def test_bad_middleware_config(self): with self.assertRaises(ValueError): SessionMiddleware(inner_app, 's3krit', clientside=False)