Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_session(self):
request.app_name = "myapp"
session = Session(secret="a", expiration=10)
session.on_request()
session["key"] = "value"
session.on_success()
cookie_name = session.local.session_cookie_name
a, b = str(response._cookies)[len("Set-Cookie: ") :].split(";")[0].split("=", 1)
request.cookies[a] = b
request.cookies = response._cookies
session.local.data.clear()
session = Session(secret="b", expiration=10)
session.on_request()
self.assertEqual(session.get("key"), None)
session = Session(secret="a", expiration=10)
session.on_request()
self.assertEqual(session.get("key"), "value")
def test_session(self):
request.app_name = "myapp"
session = Session(secret="a", expiration=10)
session.on_request()
session["key"] = "value"
session.on_success()
cookie_name = session.local.session_cookie_name
a, b = str(response._cookies)[len("Set-Cookie: ") :].split(";")[0].split("=", 1)
request.cookies[a] = b
request.cookies = response._cookies
session.local.data.clear()
session = Session(secret="b", expiration=10)
session.on_request()
self.assertEqual(session.get("key"), None)
session = Session(secret="a", expiration=10)
session.on_request()
self.assertEqual(session.get("key"), "value")
app_dir = os.path.join(FOLDER, appname)
store = io.BytesIO()
zip = zipfile.ZipFile(store, mode="w")
for root, dirs, files in os.walk(app_dir, topdown=False):
if not root.startswith("."):
for name in files:
if not (
name.endswith("~") or name.endswith(".pyc") or name[:1] in "#."
):
filename = os.path.join(root, name)
short = filename[len(app_dir + os.path.sep) :]
print("added", filename, short)
zip.write(filename, short)
zip.close()
data = store.getvalue()
response.headers["Content-Type"] = "application/zip"
return data
def api(self, tablename, id=None):
policy = self.policy
data = self.restapi(request.method, tablename, id, request.query, request.json)
response.status = data["code"]
return data
"databases": [
{"name": name, "tables": tables(name)} for name in databases
]
}
elif len(args) > 2 and args[1] in databases:
db = getattr(module, args[1])
id = args[3] if len(args) == 4 else None
data = action.uses(db, T)(
lambda: RestAPI(db, policy)(
request.method, args[2], id, request.query, request.json
)
)()
else:
data = {}
if "code" in data:
response.status = data["code"]
return data