MCPcopy Create free account
hub / github.com/github/gh-aw / TestComputePolicyHash_Deterministic

Function TestComputePolicyHash_Deterministic

pkg/workflow/cache_integrity_test.go:34–46  ·  view source on GitHub ↗

TestComputePolicyHash_Deterministic verifies that the same policy always produces the same hash.

(t *testing.T)

Source from the content-addressed store, hash-verified

32
33// TestComputePolicyHash_Deterministic verifies that the same policy always produces the same hash.
34func TestComputePolicyHash_Deterministic(t *testing.T) {
35 cfg := &GitHubToolConfig{
36 MinIntegrity: GitHubIntegrityUnapproved,
37 AllowedRepos: []any{"github/gh-aw"},
38 BlockedUsers: []string{"attacker1"},
39 }
40
41 hash1 := computePolicyHash(cfg)
42 hash2 := computePolicyHash(cfg)
43 assert.Equal(t, hash1, hash2, "Same policy must always produce the same hash")
44 assert.Len(t, hash1, 8, "Hash must be 8 characters long")
45 assert.NotEqual(t, noPolicySentinel, hash1, "Hash with policy must not equal nopolicy sentinel")
46}
47
48// TestComputePolicyHash_FieldChanges verifies that changing any single policy field produces a different hash.
49func TestComputePolicyHash_FieldChanges(t *testing.T) {

Callers

nothing calls this directly

Calls 1

computePolicyHashFunction · 0.85

Tested by

no test coverage detected