Repository navigation
[test-improver] Improve tests for internal/server guard_policy_parsing - #12919
Conversation
- Convert TestParseServerGuardPolicy_AllowOnly into a table-driven test covering modern allow-only (slice and string repos), legacy repos/min-integrity, and write-sink formats. - Replace the raw t.Fatalf type-assertion failure with a testify require.True/assert.Equal check for consistency with project conventions. - Add TestParseServerGuardPolicy_Errors covering the invalid-scope and server-id-nested-non-object error paths returned by config.ParseServerGuardPolicy. - Keep TestResolveGuardPolicy_ServerGuardPolicies as the smoke test for server-level policy resolution (already covered in depth by resolve_guard_policy_test.go). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Tighten the invalid-repos assertion and rename the broader-scope test.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This test-only PR expands and restructures guard-policy parsing coverage.
Changes:
- Adds table-driven cases for modern, legacy, and write-sink formats.
- Adds malformed-policy error coverage.
- Uses testify assertions consistently.
Review notes: rename the allow-only test to reflect its broader scope and assert the specific invalid-repos error message.
File summaries
| File | Description |
|---|---|
internal/server/guard_policy_parsing_test.go |
Expanded and reorganized guard-policy parsing tests. |
Review details
Suppressed comments (1)
internal/server/guard_policy_parsing_test.go:108
- This expectation is too broad for the case named
invalid repos scope value: any error containingreposwould pass, including an unrelated missing-field or parsing error. Pin the validation message already produced for this input (allow-only.repos string must be 'all' or 'public') so the test verifies the intended error path.
wantErr: "repos",
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
🔒 mcpg Read-Only Stress — gvisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No writes leaked. No cleanup needed.
|
This comment has been minimized.
This comment has been minimized.
…licy Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE No write leaked through mcpg in this run. Part B is
|
File analyzed
internal/server/guard_policy_parsing_test.goImprovements made
TestParseServerGuardPolicy_AllowOnlyfrom a single ad-hoc test into a table-driven test covering:repos/min-integrityformatt.Fatalf("repos is not a []interface{}, got %T: %v", ...)) withrequire.True/assert.Equal, aligning with the project's testify conventions.TestParseServerGuardPolicy_Errors(new) covering two previously-untested error paths inconfig.ParseServerGuardPolicy: an invalid repos scope value, and a server-ID-nested value that isn't an object.TestResolveGuardPolicy_ServerGuardPoliciesas-is since it's a focused smoke test; the exhaustiveresolveGuardPolicybranch coverage already lives inresolve_guard_policy_test.go.Coverage
internal/serverpackage coverage: 94.4% → 94.4% (this file's target functions were already well covered by sibling test files; the change focuses on structure, clarity, and adding two previously-missing error-path assertions forconfig.ParseServerGuardPolicy).internal/configParseServerGuardPolicy: 96.0% (unchanged; verified viago tool cover).Test output
Also verified with
go test -count=3 ./internal/server/...(pass),go vet ./internal/server/...(clean), andgofmt -l(clean). Fullgo test ./...across all packages andtest/integrationpass; only the unrelated Rust guard test step failed due to a sandboxed network/crates.io registry restriction in this environment.Warning
Firewall blocked 6 domains
The following domains were blocked by the firewall during workflow execution:
api.hub.lumenfield.workexample.comindex.crates.iononexistent.localslow.example.comthishostdoesnotexist12345.com[!TIP]
api.hub.lumenfield.workis blocked because GitHub API access uses the built-in GitHub tools by default. Instead of addingapi.hub.lumenfield.worktonetwork.allowed, usetools.github.mode: gh-proxyfor direct pre-authenticated GitHub CLI access without requiring network access toapi.github.com:See GitHub Tools for more information on
gh-proxymode.To allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.