@@ -169,33 +169,44 @@ def test_authenticated_gateway(random_zarr_dataset: tuple[str, xr.Dataset]):
169
169
xr .testing .assert_identical (loaded_ds , expected_ds )
170
170
171
171
# # Test with just bearer_token key
172
- # hamt = HAMT(
173
- # store=IPFSStore(
174
- # # api_key="test",
175
- # # basic_auth=("test", "test"),
176
- # bearer_token="test",
177
- # ),
178
- # transformer_encode=encrypt,
179
- # transformer_decode=decrypt,
180
- # )
181
- # test_ds.to_zarr(store=hamt, mode="w")
182
-
183
- # hamt.make_read_only()
184
- # loaded_ds = xr.open_zarr(store=hamt)
185
- # xr.testing.assert_identical(loaded_ds, expected_ds)
172
+ hamt = HAMT (
173
+ store = IPFSStore (
174
+ bearer_token = "test" ,
175
+ ),
176
+ transformer_encode = encrypt ,
177
+ transformer_decode = decrypt ,
178
+ )
179
+ test_ds .to_zarr (store = hamt , mode = "w" )
186
180
181
+ hamt .make_read_only ()
182
+ loaded_ds = xr .open_zarr (store = hamt )
183
+ xr .testing .assert_identical (loaded_ds , expected_ds )
187
184
188
- # Test with wrong API Key
185
+ # # Test with just basic auth
189
186
hamt = HAMT (
190
- store = IPFSStore (
191
- rpc_uri_stem = "http://127.0.0.1:5002" ,
192
- api_key = "badKey" ,
187
+ store = IPFSStore (
188
+ basic_auth = ("test" , "test" ),
193
189
),
194
190
transformer_encode = encrypt ,
195
191
transformer_decode = decrypt ,
196
192
)
193
+ test_ds .to_zarr (store = hamt , mode = "w" )
194
+
195
+ hamt .make_read_only ()
196
+ loaded_ds = xr .open_zarr (store = hamt )
197
+ xr .testing .assert_identical (loaded_ds , expected_ds )
198
+
199
+
200
+ # Test with wrong API Key
197
201
with pytest .raises (Exception ):
198
- test_ds .to_zarr (store = hamt , mode = "w" )
202
+ hamt = HAMT (
203
+ store = IPFSStore (
204
+ rpc_uri_stem = "http://127.0.0.1:5002" ,
205
+ api_key = "badKey" ,
206
+ ),
207
+ transformer_encode = encrypt ,
208
+ transformer_decode = decrypt ,
209
+ )
199
210
200
211
# Now trying to load without a decryptor, xarray should be able to read the metadata and still perform operations on the unencrypted variable
201
212
print ("Attempting to read and print metadata of partially encrypted zarr" )
0 commit comments