Coverage for mongo/sandbox.py: 100%
8 statements
« prev ^ index » next coverage.py v7.3.2, created at 2024-11-05 04:22 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2024-11-05 04:22 +0000
1import secrets
2from .submission import Submission
5def find_by_token(token: str):
6 '''
7 Find sandbox by token. return None if cannot find a sandbox with that token.
8 '''
9 sandboxes = Submission.config().sandbox_instances
10 for sandbox in sandboxes:
11 if secrets.compare_digest(token, sandbox.token):
12 return sandbox
13 return None