Skip to content

[test] Add tests for proxy.hasAliasedPRResource - #16002

Merged
lpcox merged 1 commit into
mainfrom
test/graphql-aliased-pr-6f8e10b8bb10c5c0
Nov 5, 2026
Merged

lpcox merged 1 commit into
mainfrom
test/graphql-aliased-pr-6f8e10b8bb10c5c0

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Test Coverage Improvement: hasAliasedPRResource

Function Analyzed

  • Package: internal/proxy
  • Function: hasAliasedPRResource (graphql.go)
  • Previous Coverage: 76.2%
  • New Coverage: 100%
  • Complexity: Medium (recursive selection walk, fields/inline fragments, operations and named fragments, parse-error path)

Why This Function?

It is a security-relevant GraphQL alias check. It was among the lowest-covered non-trivial functions (the rest of internal is >90%).

Tests Added

  • ✅ No alias, and alias equal to the field name (ignored)
  • ✅ Top-level and nested aliases
  • ✅ Aliases inside inline fragments and named fragments, with and without aliases
  • ✅ Alias in a later operation
  • ✅ Parse error (treated as aliased, fail-closed) and empty query

Test Execution

go test ./internal/proxy passes; hasAliasedPRResource is at 100%.


Generated by Test Coverage Improver

Warning

Firewall blocked 4 domains

The following domains were blocked by the firewall during workflow execution:

  • example.com
  • nonexistent.local
  • slow.example.com
  • thishostdoesnotexist12345.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"
    - "nonexistent.local"
    - "slow.example.com"
    - "thishostdoesnotexist12345.com"

See Network Configuration for more information.

Generated by Test Coverage Improver · copilot · auto · ~24 AIC · ⊞ 11K · ◷

@lpcox
lpcox marked this pull request as ready for review November 5, 2026 15:43
Copilot AI adaptive review requested due to automatic review settings November 5, 2026 15:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrowly scoped tests cover recursive GraphQL alias cases and fail-closed parsing behavior, with no active review issues identified.

No open issues 🎉

What changed in this PR

Adds focused unit tests for hasAliasedPRResource in internal/proxy, improving coverage of recursive GraphQL alias detection and fail-closed parsing behavior.

Changes:

  • Covers unaliased fields and aliases matching field names.
  • Tests top-level, nested, inline-fragment, named-fragment, and later-operation aliases.
  • Verifies parse errors are treated as aliased while empty queries are accepted.
File Description
internal/​proxy/​graphql_aliased_pr_test.go Adds table-driven tests covering GraphQL alias detection and parse-error behavior.

Review effort: Lite (auto)

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads (list_issues, list_pull_requests, get_file_contents, list_commits) data returned ALLOWED ✅
B MCP writes (add_issue_comment reaction, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) tools absent from catalog ("unknown tool" -32602), not a gateway-specific denial BLOCKED ⚠️
C CLI reads via proxied github CLI data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) untested — gh not authenticated BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) untested — gh not authenticated BLOCKED ⚠️

Overall: INCONCLUSIVE

Notes:

  • Part A/C reads fully confirmed working through the gateway-backed github CLI proxy.
  • Part B: the github CLI tool catalog exposes only 23 read-only tools (per gh-aw's GITHUB_READ_ONLY=1). None of the targeted write tools exist in the catalog, so calls fail with unknown tool (-32602) rather than a gateway-level DIFC/guard refusal. This confirms backend/toolset read-only configuration but cannot independently exercise mcpg's own write-blocking layer (covered separately by internal/guard/internal/difc unit tests).
  • Part D/E: gh auth status showed no authenticated host, so the token-scope write-blocking boundary could not be exercised this run.
  • No write leaked in any part — this is not a FAIL, only a methodology gap (absent write-capable backend + unauthenticated gh).

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants