Skip to content

Commit 55ea3d3

Browse files
committed
test(tests/nixos/s3-binary-cache-store): test public bucket operations
Add `test_public_bucket_operations` to validate that store operations work correctly on public S3 buckets without requiring credentials. Tests nix store info and nix copy operations.
1 parent 7d0c06f commit 55ea3d3

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/nixos/s3-binary-cache-store.nix

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,42 @@ in
340340
print(" ✓ nix copy works")
341341
print(" ✓ Credentials cached on client")
342342
343+
@setup_s3(populate_bucket=[PKGS['A'], PKGS['B']], public=True)
344+
def test_public_bucket_operations(bucket):
345+
"""Test store operations on public bucket without credentials"""
346+
print("\n=== Testing Public Bucket Operations ===")
347+
348+
store_url = make_s3_url(bucket)
349+
350+
# Verify store info works without credentials
351+
client.succeed(f"nix store info --store '{store_url}' >&2")
352+
print(" ✓ nix store info works without credentials")
353+
354+
# Get and validate store info JSON
355+
info_json = client.succeed(f"nix store info --json --store '{store_url}'")
356+
store_info = json.loads(info_json)
357+
358+
if not store_info.get("url"):
359+
raise Exception("Store should have a URL")
360+
361+
print(f" ✓ Store URL: {store_info['url']}")
362+
363+
# Verify packages are not yet in client store
364+
client.fail(f"nix path-info {PKGS['A']}")
365+
client.fail(f"nix path-info {PKGS['B']}")
366+
367+
# Test copy from public bucket without credentials
368+
client.succeed(
369+
f"nix copy --debug --no-check-sigs "
370+
f"--from '{store_url}' {PKGS['A']} {PKGS['B']} 2>&1"
371+
)
372+
373+
# Verify packages were copied successfully
374+
client.succeed(f"nix path-info {PKGS['A']}")
375+
client.succeed(f"nix path-info {PKGS['B']}")
376+
377+
print(" ✓ nix copy from public bucket works without credentials")
378+
343379
@setup_s3(populate_bucket=[PKGS['A']])
344380
def test_url_format_variations(bucket):
345381
"""Test different S3 URL parameter combinations"""
@@ -506,6 +542,7 @@ in
506542
test_error_message_formatting()
507543
test_fork_credential_preresolution()
508544
test_store_operations()
545+
test_public_bucket_operations()
509546
test_url_format_variations()
510547
test_concurrent_fetches()
511548
test_compression_narinfo_gzip()

0 commit comments

Comments
 (0)