Fix authentication tests for InferenceService#1175
Fix authentication tests for InferenceService#1175threcc merged 5 commits intoopendatahub-io:mainfrom
Conversation
f497a34 to
35fca5d
Compare
5fa682b to
2a618dc
Compare
📝 WalkthroughWalkthroughAdded logger and updated Jira ID in a test fixture, simplified authentication tests by removing cross-model branches and an admin_client parameter, and extended verify_inference_response to assert HTTP 403 Forbidden responses for unauthorized users. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/model_serving/model_server/kserve/authentication/conftest.py`:
- Line 93: The fixture currently hard-wires a pod restart by calling
predictor_pod.wait_deleted(), which breaks tests that expect "no pod rollout";
instead, make the fixture rollout-agnostic by removing the
predictor_pod.wait_deleted() call and replace it with a polling loop that waits
for the desired auth annotation/setting to be observed on the predictor resource
(or on any current pod/deployment annotations) using the same client used
elsewhere in this file (e.g., check predictor.get_annotations() or query the
deployment/pod annotations) with a timeout, and do not assert a restart—leave
any restart-specific assertions to the rollout test that explicitly checks pod
recreation.
In `@tests/model_serving/model_server/utils.py`:
- Around line 95-96: The helper verify_inference_response currently hardcodes
"resource=inferenceservices" for the 403 check which breaks when called with an
InferenceGraph; update verify_inference_response to derive the resource name
from the passed inference_service object's kind (or type) instead of hardcoding
— e.g., compute resource = inference_service.kind.lower() + "s" (or map kinds to
expected RBAC resource names) and use that resource in the regex assertion (the
function name to edit is verify_inference_response and the parameter is
inference_service).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 8c5970f0-e9fe-4739-907b-702893e75223
📒 Files selected for processing (3)
tests/model_serving/model_server/kserve/authentication/conftest.pytests/model_serving/model_server/kserve/authentication/test_kserve_token_authentication_raw.pytests/model_serving/model_server/utils.py
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/model_serving/model_server/utils.py`:
- Around line 95-97: The current fallback regex in the 403 check only matches
the resource kind and can falsely accept denials for the wrong object; update
the assertion that builds the regex (where resource =
f"{inference_service.kind.lower()}s" and the assert on res["output"]) to also
require the specific inference_service.name in the forbidden message (include
inference_service.name in the regex pattern alongside resource and verb=get) so
the assertion matches the denied object name, not just the kind.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: f5509dc8-7409-458e-affc-756b971150a8
📒 Files selected for processing (3)
tests/model_serving/model_server/kserve/authentication/conftest.pytests/model_serving/model_server/kserve/authentication/test_kserve_token_authentication_raw.pytests/model_serving/model_server/utils.py
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/model_serving/model_server/kserve/authentication/conftest.py
|
Status of building tag latest: success. |
Description
RHOAIENG-19645(cross-model auth returned302instead of403under oldOAuthproxy — fixed by migration tokube-rbac-proxy, closed as WONTDO)patched_remove_raw_authentication_isvcfrom closedRHOAIENG-19275to currentRHOAIENG-52129403Forbidden handling toverify_inference_response, deriving the RBAC resource name from the object's kindTests