feat(jobs): auth e2e testing and http_client DI - #377
Conversation
📝 WalkthroughWalkthroughAdds an optional ChangesSync HTTP Client Injection
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/nmp_common/src/nmp/common/sdk_factory.py (1)
134-151: Add keyword-only marker to align with provider interface.The module-level
get_platform_sdklacks the*keyword-only marker that its provider implementations already have. While the codebase uses only keyword arguments (no breaking calls exist), enforce consistency:Fix
def get_platform_sdk( as_service: str | None = None, internal: bool = False, + *, http_client: httpx.Client | None = None, on_behalf_of: str | Principal | None = None, ) -> NeMoPlatform:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/nmp_common/src/nmp/common/sdk_factory.py` around lines 134 - 151, Add a `*` keyword-only marker to the `get_platform_sdk` function signature immediately after the opening parenthesis to enforce that all parameters (as_service, internal, http_client, on_behalf_of) must be passed as keyword arguments. This aligns the module-level function with its provider interface implementations that already enforce keyword-only arguments.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/nmp_common/src/nmp/common/sdk_factory.py`:
- Around line 134-151: Add a `*` keyword-only marker to the `get_platform_sdk`
function signature immediately after the opening parenthesis to enforce that all
parameters (as_service, internal, http_client, on_behalf_of) must be passed as
keyword arguments. This aligns the module-level function with its provider
interface implementations that already enforce keyword-only arguments.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 368139f3-12b1-4f44-b36c-eaa0ada2f844
📒 Files selected for processing (5)
packages/nmp_common/src/nmp/common/sdk_factory.pypackages/nmp_common/tests/sdk_factory/test_sdk.pypackages/nmp_testing/src/nmp/testing/client.pyservices/core/jobs/pyproject.tomlservices/core/jobs/tests/integration/test_task_auth_runtime.py
mckornfield
left a comment
There was a problem hiding this comment.
kind of a nit on the PR title, this is an integration test, not e2e, yeah?
|
|
also might be worth including in the pr title the http client DI you added |
…cess testing Allow callers of get_platform_sdk, get_task_sdk, and PlatformSDKProvider to pass an explicit sync httpx.Client, enabling task code to be tested in-process without spawning a real HTTP server. Add integration tests in services/core/jobs that verify the full NMP_PRINCIPAL → on-behalf-of auth propagation path: a task using get_task_sdk can access secrets as the job creator, and is correctly denied when the creator lacks permission. Register standard pytest markers in the jobs pyproject.toml to support these test categories. Signed-off-by: Ryan Sadler <267728323+ironcommit@users.noreply.github.com>
24ae7a2 to
3796de1
Compare
Allow callers of get_platform_sdk, get_task_sdk, and PlatformSDKProvider to pass an explicit sync httpx.Client, enabling task code to be tested in-process without spawning a real HTTP server.
Add integration tests in services/core/jobs that verify the full NMP_PRINCIPAL → on-behalf-of auth propagation path: a task using get_task_sdk can access secrets as the job creator, and is correctly denied when the creator lacks permission. Register standard pytest markers in the jobs pyproject.toml to support these test categories.
Summary by CodeRabbit
Release Notes
New Features
Tests
Documentation