Skip to content

Commit

Permalink
Testing invalid value and no headers
Browse files Browse the repository at this point in the history
  • Loading branch information
KrishnanPrash committed Dec 13, 2024
1 parent abf7407 commit 4953905
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions qa/L0_python_api/test_kserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,12 @@ def test_restrict_inference(self, frontend, client_type, url, key_prefix):
server = utils.setup_server()

# Specifying restricted features that restricts inference.
infer_key, infer_value = "infer-key", "infer-value"

rf = RestrictedFeatures()
rf.create_feature_group(
key="infer-key",
value="infer-value",
key=infer_key,
value=infer_value,
features=[Feature.INFERENCE],
)

Expand All @@ -466,13 +468,21 @@ def test_restrict_inference(self, frontend, client_type, url, key_prefix):
headers = {key_prefix + "infer-key": "infer-value"}
assert utils.send_and_test_inference_identity(client_type, url, headers)

# Invalid headers sent with inference request
headers = {key_prefix + "fake-key": "fake-value"}
with pytest.raises(
InferenceServerException,
match=f"expecting header '{key_prefix}infer-key'",
):
utils.send_and_test_inference_identity(client_type, url, headers)
# Combinations of Invalid (or no) headers sent with inference request
invalid_key_value = {key_prefix + "fake-key": "fake-value"}
invalid_value = {key_prefix + infer_key: "fake-value"}
error_msg = f"expecting header '{key_prefix}infer-key'"

for header, err_msg in [
(invalid_key_value, error_msg),
(invalid_value, error_msg),
(None, error_msg),
]:
with pytest.raises(
InferenceServerException,
match=err_msg,
):
utils.send_and_test_inference_identity(client_type, url, header)

utils.teardown_service(service)
utils.teardown_server(server)
Expand Down

0 comments on commit 4953905

Please sign in to comment.