Skip to content

Commit 69e80e5

Browse files
test(coverage): drive internal/middleware to 95.3% (≥95% target) (#155)
middleware was ~51.8%; black-box + white-box suites now cover auth bearer/JWT extraction, fingerprint masking + dedup cap, geo fail-open (+ real MaxMind fixture), rate-limit fail-open on Redis error, idempotency canonicalisation, DPoP helpers, role lookup, and the NewRelic emit path. Also fixes a flaky base64-prefix assertion in the already-merged crypto coverage test (a random nonce can legitimately begin with "v"; the real invariant is "not a vN. versioned envelope"). internal/middleware 95.3% · internal/crypto 95.6% Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 06f8202 commit 69e80e5

7 files changed

Lines changed: 2633 additions & 1 deletion

File tree

internal/crypto/coverage_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ func TestKeyring_Decrypt_LegacyUnversioned(t *testing.T) {
243243
keyA := mustKey(t, coverageKeyHexA)
244244
legacy, err := crypto.Encrypt(keyA, "pre-rotation-secret")
245245
require.NoError(t, err)
246-
require.False(t, strings.HasPrefix(legacy, "v"))
246+
// A raw Encrypt envelope is base64 (random nonce), so it may coincidentally
247+
// begin with "v"; the invariant is that it is NOT a "vN." versioned envelope.
248+
require.False(t, len(legacy) >= 3 && legacy[0] == 'v' && legacy[2] == '.' && legacy[1] >= '1' && legacy[1] <= '9')
247249

248250
kr, err := crypto.NewKeyring('1', map[byte][]byte{'1': keyA})
249251
require.NoError(t, err)

0 commit comments

Comments
 (0)