Skip to content

Commit 35fca5d

Browse files
committed
update authentication tests
1 parent c214dd7 commit 35fca5d

File tree

3 files changed

+17
-39
lines changed

3 files changed

+17
-39
lines changed

tests/model_serving/model_server/kserve/authentication/conftest.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
create_isvc_view_role,
2929
get_pods_by_isvc_label,
3030
)
31-
from utilities.jira import is_jira_open
3231
from utilities.logger import RedactedString
3332
from utilities.serving_runtime import ServingRuntimeFromTemplate
3433

@@ -74,7 +73,6 @@ def http_raw_inference_token(model_service_account: ServiceAccount, http_raw_rol
7473

7574
@pytest.fixture()
7675
def patched_remove_raw_authentication_isvc(
77-
admin_client: DynamicClient,
7876
unprivileged_client: DynamicClient,
7977
http_s3_ovms_raw_inference_service: InferenceService,
8078
) -> Generator[InferenceService, Any, Any]:
@@ -92,8 +90,7 @@ def patched_remove_raw_authentication_isvc(
9290
}
9391
}
9492
):
95-
if is_jira_open(jira_id="RHOAIENG-19275", admin_client=admin_client):
96-
predictor_pod.wait_deleted()
93+
predictor_pod.wait_deleted()
9794

9895
yield http_s3_ovms_raw_inference_service
9996

tests/model_serving/model_server/kserve/authentication/test_kserve_token_authentication_raw.py

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
from tests.model_serving.model_server.utils import verify_inference_response
55
from utilities.constants import Annotations, Protocols
6-
from utilities.inference_utils import Inference, UserInference
6+
from utilities.inference_utils import Inference
77
from utilities.infra import check_pod_status_in_time, get_pods_by_isvc_label
8-
from utilities.jira import is_jira_open
98
from utilities.manifests.onnx import ONNX_INFERENCE_CONFIG
109

1110
pytestmark = pytest.mark.usefixtures("valid_aws_config")
@@ -50,14 +49,15 @@ def test_disabled_raw_model_authentication(self, patched_remove_raw_authenticati
5049
)
5150

5251
@pytest.mark.sanity
53-
@pytest.mark.jira("RHOAIENG-19275", run=False)
5452
def test_raw_disable_enable_authentication_no_pod_rollout(self, http_s3_ovms_raw_inference_service):
5553
"""Verify no pod rollout when disabling and enabling authentication"""
5654
pod = get_pods_by_isvc_label(
5755
client=http_s3_ovms_raw_inference_service.client,
5856
isvc=http_s3_ovms_raw_inference_service,
5957
)[0]
6058

59+
import pdb; pdb.set_trace()
60+
6161
ResourceEditor(
6262
patches={
6363
http_s3_ovms_raw_inference_service: {
@@ -101,37 +101,15 @@ def test_re_enabled_raw_model_authentication(self, http_s3_ovms_raw_inference_se
101101
)
102102
@pytest.mark.dependency(name="test_cross_model_authentication_raw")
103103
def test_cross_model_authentication_raw(
104-
self, http_s3_ovms_raw_inference_service_2, http_raw_inference_token, admin_client
104+
self, http_s3_ovms_raw_inference_service_2, http_raw_inference_token
105105
):
106106
"""Verify model with another model token"""
107-
if is_jira_open(jira_id="RHOAIENG-19645", admin_client=admin_client):
108-
inference = UserInference(
109-
inference_service=http_s3_ovms_raw_inference_service_2,
110-
inference_config=ONNX_INFERENCE_CONFIG,
111-
inference_type=Inference.INFER,
112-
protocol=Protocols.HTTPS,
113-
)
114-
115-
res = inference.run_inference_flow(
116-
model_name=http_s3_ovms_raw_inference_service_2.name,
117-
use_default_query=True,
118-
token=http_raw_inference_token,
119-
insecure=False,
120-
)
121-
output = res.get("output", res)
122-
if isinstance(output, dict):
123-
output = str(output)
124-
status_line = output.splitlines()[0]
125-
# Updated: Now expecting 403 Forbidden for cross-model authentication
126-
# (token from service 1 cannot access service 2)
127-
assert "403 Forbidden" in status_line, f"Expected '403 Forbidden' in status line, got: {status_line}"
128-
else:
129-
verify_inference_response(
130-
inference_service=http_s3_ovms_raw_inference_service_2,
131-
inference_config=ONNX_INFERENCE_CONFIG,
132-
inference_type=Inference.INFER,
133-
protocol=Protocols.HTTPS,
134-
use_default_query=True,
135-
token=http_raw_inference_token,
136-
authorized_user=False,
137-
)
107+
verify_inference_response(
108+
inference_service=http_s3_ovms_raw_inference_service_2,
109+
inference_config=ONNX_INFERENCE_CONFIG,
110+
inference_type=Inference.INFER,
111+
protocol=Protocols.HTTPS,
112+
use_default_query=True,
113+
token=http_raw_inference_token,
114+
authorized_user=False,
115+
)

tests/model_serving/model_server/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ def verify_inference_response(
9292
):
9393
assert "x-forbidden-reason: Access to the InferenceGraph is not allowed" in res["output"]
9494

95+
elif "403 Forbidden" in res["output"]:
96+
assert re.search(r"Forbidden \(user=.*verb=get.*resource=inferenceservices", res["output"])
97+
9598
else:
9699
raise ValueError(f"Auth header {auth_header} not found in response. Response: {res['output']}")
97100

0 commit comments

Comments
 (0)