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

Function TestComputeIntegrityCacheKey_CustomKey

pkg/workflow/cache_integrity_test.go:343–362  ·  view source on GitHub ↗

TestComputeIntegrityCacheKey_CustomKey verifies that custom keys get the integrity prefix to prevent cross-integrity cache sharing.

(t *testing.T)

Source from the content-addressed store, hash-verified

341// TestComputeIntegrityCacheKey_CustomKey verifies that custom keys get the integrity prefix
342// to prevent cross-integrity cache sharing.
343func TestComputeIntegrityCacheKey_CustomKey(t *testing.T) {
344 cfg := &GitHubToolConfig{
345 MinIntegrity: GitHubIntegrityMerged,
346 AllowedRepos: "all",
347 }
348 policyHash := computePolicyHash(cfg)
349
350 entry := CacheMemoryEntry{
351 ID: "default",
352 Key: "my-custom-key",
353 }
354 key := computeIntegrityCacheKey(entry, cfg)
355
356 // Custom keys must be prefixed with integrity/policy to prevent cross-level sharing
357 expectedPrefix := "memory-merged-" + policyHash + "-"
358 assert.True(t, strings.HasPrefix(key, expectedPrefix),
359 "Custom keys must be prefixed with integrity/policy, got: %s", key)
360 assert.True(t, strings.HasSuffix(key, "-${{ github.run_id }}"),
361 "Custom keys should end with run_id suffix, got: %s", key)
362}
363
364// TestComputeIntegrityCacheKey_CustomKeyWithRunID verifies that custom keys already containing
365// the run_id suffix are not duplicated, but still get the integrity prefix.

Callers

nothing calls this directly

Calls 2

computePolicyHashFunction · 0.85
computeIntegrityCacheKeyFunction · 0.85

Tested by

no test coverage detected