MCPcopy Create free account
hub / github.com/crate/crate / test_anonymous_read_write

Method test_anonymous_read_write

blackbox/test_s3.py:236–300  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

234 c.execute('DROP TABLE r1')
235
236 def test_anonymous_read_write(self):
237 client = Minio(endpoint='127.0.0.1:9000',
238 access_key = MinioServer.MINIO_ACCESS_KEY,
239 secret_key = MinioServer.MINIO_SECRET_KEY,
240 region = "myRegion",
241 secure = False)
242
243 with MinioServer() as minio:
244 t = threading.Thread(target=minio.run)
245 t.daemon = True
246 t.start()
247 wait_until(lambda: _is_up('127.0.0.1', 9000))
248
249 client.make_bucket(bucket_name="my.bucket")
250
251 # https://docs.min.io/docs/python-client-api-reference.html#set_bucket_policy
252 # Example anonymous read-write bucket policy.
253 policy = {
254 "Version": "2012-10-17",
255 "Statement": [
256 {
257 "Effect": "Allow",
258 "Principal": {"AWS": "*"},
259 "Action": [
260 "s3:GetBucketLocation",
261 "s3:ListBucket",
262 "s3:ListBucketMultipartUploads",
263 ],
264 "Resource": "arn:aws:s3:::my.bucket",
265 },
266 {
267 "Effect": "Allow",
268 "Principal": {"AWS": "*"},
269 "Action": [
270 "s3:GetObject",
271 "s3:PutObject",
272 "s3:DeleteObject",
273 "s3:ListMultipartUploadParts",
274 "s3:AbortMultipartUpload",
275 ],
276 "Resource": "arn:aws:s3:::my.bucket/*",
277 },
278 ],
279 }
280 client.set_bucket_policy(bucket_name="my.bucket", policy=json.dumps(policy))
281
282 with connect(crate_node.http_url) as conn:
283 c = conn.cursor()
284 c.execute('CREATE TABLE t1 (x int)')
285 c.execute('INSERT INTO t1 (x) VALUES (1), (2), (3)')
286 c.execute('REFRESH TABLE t1')
287
288 c.execute("""
289 COPY t1 TO DIRECTORY 's3://127.0.0.1:9000/my.bucket/' WITH (protocol = 'http')
290 """)
291 c.execute("""
292 COPY t1 FROM 's3://127.0.0.1:9000/my.bucket/*' WITH (protocol = 'http')
293 """)

Callers

nothing calls this directly

Calls 5

MinioServerClass · 0.85
_is_upFunction · 0.85
cursorMethod · 0.80
startMethod · 0.65
executeMethod · 0.65

Tested by

no test coverage detected