Skip to content

fix: register guard test uses non-noop guard for policy validation#2273

Merged
lpcox merged 1 commit into
mainfrom
fix/register-guard-test-noop-bypass
Mar 21, 2026
Merged

fix: register guard test uses non-noop guard for policy validation#2273
lpcox merged 1 commit into
mainfrom
fix/register-guard-test-noop-bypass

Conversation

@lpcox
Copy link
Copy Markdown
Collaborator

@lpcox lpcox commented Mar 21, 2026

Problem

TestRegisterGuard_InvalidPolicy_ReturnsError was failing on main because it used a noop guard type. requireGuardPolicyIfGuardEnabled intentionally short-circuits for noop guards (g.Name() == "noop") without validating the policy — this is by design (documented in the companion test TestRegisterGuard_GuardConfigFound_NoopType_GlobalAllowOnlyPolicy).

Fix

  • Changed the test to register a non-noop guard type (write-sink via guard.RegisterGuardType) so the invalid global policy validation path is actually exercised
  • Fixed gofmt whitespace alignment in proxy_test.go

Testing

make agent-finished passes — all unit and integration tests green.

TestRegisterGuard_InvalidPolicy_ReturnsError was failing because it used
a noop guard type. requireGuardPolicyIfGuardEnabled intentionally
short-circuits for noop guards (g.Name() == "noop") without validating
the policy. Changed the test to register a non-noop guard type
(write-sink) so the invalid global policy validation path is exercised.

Also fixed gofmt whitespace alignment in proxy_test.go.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 21, 2026 17:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a failing guard registration unit test by ensuring the test exercises the intended policy-validation path (which is skipped for noop guards by design).

Changes:

  • Update TestRegisterGuard_InvalidPolicy_ReturnsError to register and use a non-noop guard type so invalid global guard policy validation is reached.
  • Add clarifying test comment explaining the noop short-circuit behavior.
  • Apply a minor gofmt alignment fix in proxy_test.go.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
internal/server/register_guard_test.go Adjusts the invalid-policy test setup to use a non-noop guard type so requireGuardPolicyIfGuardEnabled triggers resolveGuardPolicy validation.
internal/proxy/proxy_test.go Fixes whitespace alignment in a response header map literal (gofmt-style).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lpcox lpcox merged commit 80e9966 into main Mar 21, 2026
23 checks passed
@lpcox lpcox deleted the fix/register-guard-test-noop-bypass branch March 21, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants