Skip to content

Comments

LCORE-1352: integration tests for /authorized endpoint#1195

Merged
tisnik merged 2 commits intolightspeed-core:mainfrom
tisnik:lcore-1352-integration-tests-for-authorized-endpoint
Feb 23, 2026
Merged

LCORE-1352: integration tests for /authorized endpoint#1195
tisnik merged 2 commits intolightspeed-core:mainfrom
tisnik:lcore-1352-integration-tests-for-authorized-endpoint

Conversation

@tisnik
Copy link
Contributor

@tisnik tisnik commented Feb 23, 2026

Description

LCORE-1352: integration tests for /authorized endpoint

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

  • Assisted-by: N/A
  • Generated by: N/A

Related Tickets & Documents

  • Related Issue #LCORE-1352

Summary by CodeRabbit

  • Tests
    • Added integration tests for the authorized endpoint to validate user authentication and response structure.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 23, 2026

Warning

Rate limit exceeded

@tisnik has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 2 minutes and 18 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 49c2370 and ad5c22a.

📒 Files selected for processing (1)
  • tests/integration/endpoints/test_authorized_endpoint.py

Walkthrough

Introduces a new integration test module for the /authorized endpoint. Adds a fixture to mock AsyncLlamaStackClientHolder with a configured version, and an async test that validates the authorized endpoint returns correct user identity and configuration response fields.

Changes

Cohort / File(s) Summary
Authorized Endpoint Integration Tests
tests/integration/endpoints/test_authorized_endpoint.py
New integration test module with a mock fixture for AsyncLlamaStackClientHolder and a test validating the /authorized endpoint response includes correct user_id, username, and skip_userid_check values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 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 clearly and specifically describes the main change: adding integration tests for the /authorized endpoint, with a ticket reference.
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 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.

@tisnik tisnik force-pushed the lcore-1352-integration-tests-for-authorized-endpoint branch from a835252 to 49c2370 Compare February 23, 2026 08:15
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.

🧹 Nitpick comments (2)
tests/integration/endpoints/test_authorized_endpoint.py (2)

15-40: Remove the dead mock_llama_stack_client fixture — wrong module patched, never invoked

Three separate problems make this fixture dead code:

  1. Wrong patch target — Line 30 patches "app.endpoints.info.AsyncLlamaStackClientHolder" (the info endpoint's module). The test is for the authorized endpoint.
  2. Handler has no such dependencyauthorized_endpoint_handler (see src/app/endpoints/authorized.py:24-42) never references AsyncLlamaStackClientHolder; it simply unpacks the injected auth tuple.
  3. Fixture is not injectedmock_llama_stack_client is absent from test_authorized_endpoint's parameter list, so pytest never invokes it.

This looks like an unmodified copy-paste from the info-endpoint test. Remove the fixture entirely; the test is already self-contained.

Removing the fixture also cleans up the orphaned imports on lines 3 and 7 (Generator, Any, VersionInfo).

🗑️ Proposed cleanup
-from typing import Generator, Any
-import pytest
-from pytest_mock import MockerFixture
-
-from llama_stack_client.types import VersionInfo
-from authentication.interface import AuthTuple
+import pytest
+from authentication.interface import AuthTuple

 from configuration import AppConfig
 from app.endpoints.authorized import authorized_endpoint_handler
 from constants import DEFAULT_USER_UID, DEFAULT_USER_NAME, DEFAULT_SKIP_USER_ID_CHECK
-
-
-@pytest.fixture(name="mock_llama_stack_client")
-def mock_llama_stack_client_fixture(
-    mocker: MockerFixture,
-) -> Generator[Any, None, None]:
-    ...
-    mock_holder_class = mocker.patch("app.endpoints.info.AsyncLlamaStackClientHolder")
-    mock_client = mocker.AsyncMock()
-    mock_client.inspect.version.return_value = VersionInfo(version="0.2.22")
-    mock_holder_instance = mock_holder_class.return_value
-    mock_holder_instance.get_client.return_value = mock_client
-    yield mock_client
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration/endpoints/test_authorized_endpoint.py` around lines 15 -
40, Delete the unused pytest fixture named mock_llama_stack_client from
tests/integration/endpoints/test_authorized_endpoint.py because it patches the
wrong target ("app.endpoints.info.AsyncLlamaStackClientHolder"), is never
injected into the test (not present in test_authorized_endpoint parameters), and
the authorized handler (authorized_endpoint_handler) does not depend on
AsyncLlamaStackClientHolder; also remove the now-orphaned imports Generator,
Any, and VersionInfo at the top of the file. Ensure no other tests in this file
reference mock_llama_stack_client before removing it.

59-60: Minor: prefer discarding the fixture value directly in the signature

The _ = test_config workaround exists because linters flag unused function parameters. A more idiomatic approach is to indicate the parameter is intentionally unused at the signature level:

✨ Alternative
 async def test_authorized_endpoint(
-    test_config: AppConfig,
+    test_config: AppConfig,  # noqa: ARG001  (side-effect only: loads app config)
     test_auth: AuthTuple,
 ) -> None:
     ...
-    # Fixtures with side effects (needed but not directly used)
-    _ = test_config
-
     response = await authorized_endpoint_handler(auth=test_auth)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration/endpoints/test_authorized_endpoint.py` around lines 59 -
60, Replace the runtime discard "_ = test_config" with an unused-parameter
indicator in the test signature: remove the assignment and rename the fixture
parameter to start with an underscore (e.g., change parameter test_config to
_test_config) or use pytest.mark.usefixtures("test_config") on the test
function; update the test function signature where test_config is declared and
remove the "_ = test_config" line so linters no longer flag an unused variable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/integration/endpoints/test_authorized_endpoint.py`:
- Around line 15-40: Delete the unused pytest fixture named
mock_llama_stack_client from
tests/integration/endpoints/test_authorized_endpoint.py because it patches the
wrong target ("app.endpoints.info.AsyncLlamaStackClientHolder"), is never
injected into the test (not present in test_authorized_endpoint parameters), and
the authorized handler (authorized_endpoint_handler) does not depend on
AsyncLlamaStackClientHolder; also remove the now-orphaned imports Generator,
Any, and VersionInfo at the top of the file. Ensure no other tests in this file
reference mock_llama_stack_client before removing it.
- Around line 59-60: Replace the runtime discard "_ = test_config" with an
unused-parameter indicator in the test signature: remove the assignment and
rename the fixture parameter to start with an underscore (e.g., change parameter
test_config to _test_config) or use pytest.mark.usefixtures("test_config") on
the test function; update the test function signature where test_config is
declared and remove the "_ = test_config" line so linters no longer flag an
unused variable.
ℹ️ 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 6c1821d and 49c2370.

📒 Files selected for processing (1)
  • tests/integration/endpoints/test_authorized_endpoint.py

@tisnik
Copy link
Contributor Author

tisnik commented Feb 23, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 23, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tisnik tisnik merged commit fb0389b into lightspeed-core:main Feb 23, 2026
22 checks passed
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.

1 participant