forked from mtusi2026/mtusi2026lab4
11 lines
447 B
Python
11 lines
447 B
Python
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) |