forked from mtusi2026/mtusi2026lab4
grade4
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import os, sys, urllib.request, urllib.error
|
||||
BUCKET = os.getenv("S3_BUCKET", "messenger-attachments")
|
||||
KEY = os.getenv("S3_KEY")
|
||||
URL = f"http://s3:8333/{BUCKET}/{KEY}"
|
||||
try:
|
||||
urllib.request.urlopen(URL)
|
||||
print("FAIL: object accessible without auth"); sys.exit(1)
|
||||
except urllib.error.HTTPError as e:
|
||||
if e.code in (401, 403):
|
||||
print(f"PASS: anonymous GET -> {e.code}"); sys.exit(0)
|
||||
print(f"FAIL: unexpected {e.code}"); sys.exit(1)
|
||||
Reference in New Issue
Block a user