mirror of
https://github.com/NixOS/nix
synced 2025-07-07 06:01:48 +02:00
Add NAR hash mismatch test
This commit is contained in:
parent
3432184136
commit
307ce9bc1d
1 changed files with 4 additions and 0 deletions
|
@ -224,6 +224,10 @@ in
|
||||||
hash = client.succeed(f"nix eval --no-trust-tarballs-from-git-forges --raw --expr '(fetchTree {info['url']}).narHash'")
|
hash = client.succeed(f"nix eval --no-trust-tarballs-from-git-forges --raw --expr '(fetchTree {info['url']}).narHash'")
|
||||||
assert hash == info['locked']['narHash']
|
assert hash == info['locked']['narHash']
|
||||||
|
|
||||||
|
# Fetching with an incorrect NAR hash should fail.
|
||||||
|
out = client.fail(f"nix eval --no-trust-tarballs-from-git-forges --raw --expr '(fetchTree \"github:fancy-enterprise/private-flake/{info['revision']}?narHash=sha256-HsrRFZYg69qaVe/wDyWBYLeS6ca7ACEJg2Z%2BGpEFw4A%3D\").narHash' 2>&1")
|
||||||
|
assert "NAR hash mismatch in input" in out, "NAR hash check did not fail with the expected error"
|
||||||
|
|
||||||
# Fetching without a narHash should succeed if trust-github is set and fail otherwise.
|
# Fetching without a narHash should succeed if trust-github is set and fail otherwise.
|
||||||
client.succeed(f"nix eval --raw --expr 'builtins.fetchTree github:github:fancy-enterprise/private-flake/{info['revision']}'")
|
client.succeed(f"nix eval --raw --expr 'builtins.fetchTree github:github:fancy-enterprise/private-flake/{info['revision']}'")
|
||||||
out = client.fail(f"nix eval --no-trust-tarballs-from-git-forges --raw --expr 'builtins.fetchTree github:github:fancy-enterprise/private-flake/{info['revision']}' 2>&1")
|
out = client.fail(f"nix eval --no-trust-tarballs-from-git-forges --raw --expr 'builtins.fetchTree github:github:fancy-enterprise/private-flake/{info['revision']}' 2>&1")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue