Skip to content

Comments

LCORE-1371: MCP OAuth Integration Tests#1218

Open
jrobertboos wants to merge 1 commit intolightspeed-core:mainfrom
jrobertboos:lcore-1371
Open

LCORE-1371: MCP OAuth Integration Tests#1218
jrobertboos wants to merge 1 commit intolightspeed-core:mainfrom
jrobertboos:lcore-1371

Conversation

@jrobertboos
Copy link
Contributor

@jrobertboos jrobertboos commented Feb 24, 2026

Description

Created integration tests for the MCP OAuth flow on the following endpoints:

  • /tools
  • /query
  • /streaming_query

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement

Tools used to create PR

Identify any AI code assistants used in this PR (for transparency and review context)

  • Assisted-by: Cursor
  • Generated by: Cursor

Related Tickets & Documents

  • Related Issue #
  • Closes LCORE-1371

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

make test-integration

Summary by CodeRabbit

  • Tests
    • Added integration test coverage for OAuth error handling across query, streaming query, and tools endpoints to validate proper 401 responses with appropriate authentication headers.

…points to verify 401 responses with WWW-Authenticate when MCP OAuth is required. Add mock fixtures for Llama Stack client interactions in each test file.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

Walkthrough

Three integration test files are enhanced with new test fixtures and test cases that validate endpoints properly propagate 401 responses with WWW-Authenticate headers when MCP OAuth is required, extending error-path test coverage without modifying existing endpoint logic.

Changes

Cohort / File(s) Summary
Integration Tests for OAuth Error Handling
tests/integration/endpoints/test_query_integration.py, tests/integration/endpoints/test_streaming_query_integration.py, tests/integration/endpoints/test_tools_integration.py
Added integration test fixtures mocking Llama Stack clients and new test cases (test_*_endpoint_returns_401_with_www_authenticate_when_mcp_oauth_required) that verify the query, streaming_query, and tools endpoints correctly propagate 401 responses with WWW-Authenticate headers when MCP OAuth is required and no credentials are supplied.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • asimurka
  • tisnik
  • radofuchs
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'LCORE-1371: MCP OAuth Integration Tests' clearly and concisely summarizes the main change: adding integration tests for MCP OAuth functionality across three endpoints.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
tests/integration/endpoints/test_streaming_query_integration.py (1)

76-80: ⚠️ Potential issue | 🟠 Major

Same potentially incorrect patch target as in test_query_integration.py.

"utils.responses.get_mcp_tools" patches the definition site. If app.endpoints.streaming_query imports the function directly (from utils.responses import get_mcp_tools), the mock won't intercept calls from that module. Verify and, if needed, patch "app.endpoints.streaming_query.get_mcp_tools" instead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration/endpoints/test_streaming_query_integration.py` around lines
76 - 80, The mock currently patches "utils.responses.get_mcp_tools" which may
not intercept calls if streaming_query imports get_mcp_tools directly; update
the test to patch the symbol used by the code under test by replacing the target
with "app.endpoints.streaming_query.get_mcp_tools" (or confirm the import style
in app.endpoints.streaming_query and patch that module's get_mcp_tools) so the
AsyncMock side_effect oauth_401 is applied where streaming_query calls
get_mcp_tools.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@tests/integration/endpoints/test_streaming_query_integration.py`:
- Around line 76-80: The mock currently patches "utils.responses.get_mcp_tools"
which may not intercept calls if streaming_query imports get_mcp_tools directly;
update the test to patch the symbol used by the code under test by replacing the
target with "app.endpoints.streaming_query.get_mcp_tools" (or confirm the import
style in app.endpoints.streaming_query and patch that module's get_mcp_tools) so
the AsyncMock side_effect oauth_401 is applied where streaming_query calls
get_mcp_tools.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 051c06c and a70355c.

📒 Files selected for processing (3)
  • tests/integration/endpoints/test_query_integration.py
  • tests/integration/endpoints/test_streaming_query_integration.py
  • tests/integration/endpoints/test_tools_integration.py

"""Integration tests for the /streaming_query endpoint."""

# pylint: disable=too-many-arguments
# pylint: disable=too-many-positional-arguments
Copy link
Contributor

Choose a reason for hiding this comment

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

is it needed?

"""Integration tests for the /tools endpoint."""

# pylint: disable=too-many-arguments
# pylint: disable=too-many-positional-arguments
Copy link
Contributor

Choose a reason for hiding this comment

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

is it needed?

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