|
20 | 20 | get_strategy, |
21 | 21 | join_url, |
22 | 22 | ) |
23 | | -from virtualizarr.tests import requires_pyarrow |
| 23 | +from virtualizarr.tests import requires_minio, requires_pyarrow |
24 | 24 |
|
25 | 25 | pytestmark = requires_pyarrow |
26 | 26 |
|
@@ -545,3 +545,52 @@ def test_sharded_array_raises_error(tmpdir): |
545 | 545 | match="Zarr V3 arrays with sharding are not yet supported", |
546 | 546 | ): |
547 | 547 | parser(url=filepath, registry=registry) |
| 548 | + |
| 549 | + |
| 550 | +@requires_minio |
| 551 | +@pytest.mark.xfail( |
| 552 | + reason="ZarrParser does not yet support buckets without list permissions" |
| 553 | +) |
| 554 | +def test_zarr_parser_nolist_bucket(minio_nolist_bucket): |
| 555 | + """Test that ZarrParser works with a bucket that does not allow list operations.""" |
| 556 | + import obstore as obs |
| 557 | + |
| 558 | + bucket = minio_nolist_bucket["bucket"] |
| 559 | + endpoint = minio_nolist_bucket["endpoint"] |
| 560 | + username = minio_nolist_bucket["username"] |
| 561 | + password = minio_nolist_bucket["password"] |
| 562 | + |
| 563 | + # Write a Zarr V3 store directly to the bucket using admin credentials |
| 564 | + admin_store = obs.store.S3Store( |
| 565 | + bucket, |
| 566 | + endpoint_url=endpoint, |
| 567 | + access_key_id=username, |
| 568 | + secret_access_key=password, |
| 569 | + virtual_hosted_style_request=False, |
| 570 | + client_options={"allow_http": True}, |
| 571 | + ) |
| 572 | + zarr_store = zarr.storage.ObjectStore(store=admin_store) |
| 573 | + ds = xr.Dataset( |
| 574 | + {"data": (("x", "y"), np.arange(12, dtype="float32").reshape(3, 4))}, |
| 575 | + coords={"x": np.arange(3), "y": np.arange(4)}, |
| 576 | + ) |
| 577 | + ds.to_zarr(zarr_store, consolidated=False, zarr_format=3) |
| 578 | + |
| 579 | + # Create an anonymous S3 store (subject to bucket policy which denies list) |
| 580 | + anon_store = obs.store.S3Store( |
| 581 | + bucket, |
| 582 | + endpoint_url=endpoint, |
| 583 | + skip_signature=True, |
| 584 | + virtual_hosted_style_request=False, |
| 585 | + client_options={"allow_http": True}, |
| 586 | + ) |
| 587 | + |
| 588 | + url = f"s3://{bucket}" |
| 589 | + registry = ObjectStoreRegistry({url: anon_store}) |
| 590 | + parser = ZarrParser() |
| 591 | + manifeststore = parser(url=url, registry=registry) |
| 592 | + |
| 593 | + with xr.open_dataset( |
| 594 | + manifeststore, engine="zarr", consolidated=False, zarr_format=3 |
| 595 | + ) as actual: |
| 596 | + xr.testing.assert_identical(actual, ds) |
0 commit comments