Repository navigation
[test] Add tests for server.overrideToPublicScope - #16181
Conversation
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The change still has an unresolved redundant test group and an incomplete assertion that does not verify the full no-mutation contract for unparsable policies.
2 open issues
What changed in this PR
Adds branch-focused unit tests for UnifiedServer.overrideToPublicScope, covering empty policies, missing or nil server configurations, malformed policies, and unrecognized policy formats.
Changes:
- Adds tests for public allow-only policy injection.
- Verifies no-op behavior for unknown and nil server configurations.
- Tests preservation of existing policy data for malformed and unrecognized policies.
- Review comments note duplicated coverage and an incomplete assertion for malformed-policy handling.
| File | Summary | Review comments |
|---|---|---|
internal/server/force_public_repos_test.go |
Adds five branch-oriented tests for forced public repository scope overrides. | Nit (4 votes): The aggregate subtest group duplicates existing coverage and should be removed or replaced. Moderate (2 votes): The malformed-policy test should compare the complete policy map rather than only the repos field. |
Review effort: Lite (auto)
|
|
||
| us.overrideToPublicScope("github") | ||
|
|
||
| assert.Equal(t, 123, cfg.Servers["github"].GuardPolicies["allow-only"].(map[string]interface{})["repos"]) |
There was a problem hiding this comment.
Updated in fa31d44: removed the redundant aggregate group. The dedicated invalid-policy tests compare the complete policy map before and after the call, covering the no-mutation contract.
| // TestOverrideToPublicScope_Branches covers the remaining override branches: | ||
| // empty global policy, missing/nil server config, unparsable and unrecognized | ||
| // per-server policies. | ||
| func TestOverrideToPublicScope_Branches(t *testing.T) { | ||
| t.Run("global policy without allow-only or write-sink gets allow-only public", func(t *testing.T) { |
There was a problem hiding this comment.
Updated in fa31d44: removed the aggregate group because its cases duplicate the dedicated tests already in this file.
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE No write leaked on any surface (zero reaction/star/issue/comment/branch/file/PR created). Full log: /tmp/gh-aw/agent/readonly-stress-42500236166.txt
|
|
@copilot address review feedback |
Co-authored-by: lpcox <[email protected]>


Test Coverage Improvement: overrideToPublicScope
internal/server(guard_visibility.go)UnifiedServer.overrideToPublicScopeWhy this function?
It has the most branching among the lowest-covered non-trivial functions and enforces a security-critical policy override.
Tests added (
TestOverrideToPublicScope_Branches)Test execution
go test ./internal/serverpasses;go vetandgofmtclean.Generated by Test Coverage Improver
Warning
Firewall blocked 4 domains
The following domains were blocked by the firewall during workflow execution:
example.comnonexistent.localslow.example.comthishostdoesnotexist12345.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.