# s3-security: lab4: private bucket outside API, limited API key, no console/ports, idempotent bootstrap
# date: 2026-11-01 20:38:59, commit: 470d9d6 + uncommitted changes
# command: python.exe student-tests/test_s3_security.py
# exit code: 0, 10.5 s

anonymous get_object directly to S3 (from the data network) -> 403 AccessDenied
anonymous head_object directly to S3 (from the data network) -> 403 
anonymous list_bucket directly to S3 (from the data network) -> 403 AccessDenied
anonymous put_object directly to S3 (from the data network) -> 403 AccessDenied
anonymous get_bucket_policy directly to S3 (from the data network) -> 403 AccessDenied
the same file through the API for a chat member -> 200
PASS: the bucket is private: no anonymous read, list, write or policy read
API key: list buckets                     -> ['messenger-attachments']
API key: get own object                   -> allowed
API key: put object                       -> allowed
API key: delete object                    -> allowed
API key: list bucket                      -> allowed
API key: create another bucket            -> denied: AccessDenied
API key: make bucket public (put policy)  -> denied: NotImplemented
API key: read bucket policy               -> denied: NoSuchBucketPolicy
API key: delete bucket                    -> denied: AccessDenied
API key: change versioning                -> denied: NotImplemented
PASS: the API key can only get/put/delete/list objects of its own bucket; bucket admin, policy and other buckets are denied
compose: s3 has no published ports, only the internal network 'data' (S3 8333, master UI 9333, filer UI 8888 are reachable only inside the stand)
127.0.0.1:8333 from the host -> connection refused
127.0.0.1:9333 from the host -> connection refused
127.0.0.1:8888 from the host -> connection refused
127.0.0.1:19333 from the host -> connection refused
secrets of api: ['cache_url', 'database_url', 's3_access_key_id', 's3_secret_access_key']
secrets of dispatcher: ['broker_url_dispatcher', 'database_url']
secrets of grafana: ['grafana_admin_password']
secrets of janitor: ['database_url', 's3_access_key_id', 's3_secret_access_key']
secrets of lb: -
secrets of loki: -
secrets of migrate: ['database_url']
secrets of otel-collector: -
secrets of postgres: ['postgres_password']
secrets of prometheus: -
secrets of rabbitmq: ['rabbitmq_definitions']
secrets of redis: ['redis_auth']
secrets of s3: ['s3_config']
secrets of s3-init: ['s3_access_key_id', 's3_root_password', 's3_root_user', 's3_secret_access_key']
secrets of telemetry-init: -
secrets of tempo: -
secrets of worker: ['broker_url_worker', 'database_url', 's3_access_key_id', 's3_secret_access_key']
PASS: S3 is reachable only inside the stand; admin keys are only in s3 and s3-init
s3-init: s3-init: bucket messenger-attachments exists
s3-init: s3-init: api key can put/get/list/delete objects of its bucket
s3-init: s3-init: api key cannot create buckets (AccessDenied)
s3-init: s3-init: bucket is private (anonymous list/get/put -> [403])
after the repeated bootstrap: old file downloads, new upload works
PASS: bucket/user/policy bootstrap can be repeated safely
4 passed, 0 failed
