Skip to content

Commit

Permalink
Add test for oversized sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisburr committed Oct 2, 2023
1 parent 45c708d commit 0197494
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/routers/jobs/test_sandboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,23 @@ def test_upload_then_download(normal_user_client: TestClient):
r = requests.get(download_info["url"])
assert r.status_code == 200, r.text
assert r.content == data


def test_upload_oversized(normal_user_client: TestClient):
data = secrets.token_bytes(512)
checksum = hashlib.sha256(data).hexdigest()

# Initiate the upload
r = normal_user_client.post(
"/jobs/sandbox",
json={
"checksum_algorithm": "sha256",
"checksum": checksum,
# We can forge the size here to be larger than the actual data as
# we should get an error and never actually upload the data
"size": 1024 * 1024 * 1024,
"format": "tar.bz2",
},
)
assert r.status_code == 400, r.text
assert "Sandbox too large" in r.json()["detail"], r.text

0 comments on commit 0197494

Please sign in to comment.