TestComputePolicyHash_Deterministic verifies that the same policy always produces the same hash.
(t *testing.T)
| 32 | |
| 33 | // TestComputePolicyHash_Deterministic verifies that the same policy always produces the same hash. |
| 34 | func 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. |
| 49 | func TestComputePolicyHash_FieldChanges(t *testing.T) { |
nothing calls this directly
no test coverage detected