Skip to content

Commit 753e3e9

Browse files
committed
Make tests and schema in line with query auth errors
1 parent 9a4298c commit 753e3e9

File tree

6 files changed

+25
-12
lines changed

6 files changed

+25
-12
lines changed

docs/openapi.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@
355355
}
356356
]
357357
},
358-
"400": {
358+
"401": {
359359
"description": "Missing or invalid credentials provided by client",
360360
"content": {
361361
"application/json": {
@@ -375,6 +375,9 @@
375375
}
376376
}
377377
},
378+
"404": {
379+
"description": "Requested model or provider not found"
380+
},
378381
"429": {
379382
"description": "The quota has been exceeded",
380383
"content": {
@@ -690,6 +693,16 @@
690693
}
691694
}
692695
},
696+
"400": {
697+
"description": "Missing or invalid credentials provided by client",
698+
"content": {
699+
"application/json": {
700+
"schema": {
701+
"$ref": "#/components/schemas/UnauthorizedResponse"
702+
}
703+
}
704+
}
705+
},
693706
"401": {
694707
"description": "Missing or invalid credentials provided by client",
695708
"content": {
@@ -1267,7 +1280,7 @@
12671280
}
12681281
},
12691282
"403": {
1270-
"description": "Client does not have permission to access conversation",
1283+
"description": "User is not authorized",
12711284
"content": {
12721285
"application/json": {
12731286
"schema": {
@@ -4240,4 +4253,4 @@
42404253
}
42414254
}
42424255
}
4243-
}
4256+
}

src/app/endpoints/query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ def select_model_and_provider_id(
491491
"""
492492
# If no models are available, raise an exception
493493
if not models:
494-
message = "No LLM model found in available models"
494+
message = "No models available"
495495
logger.error(message)
496496
raise HTTPException(
497497
status_code=status.HTTP_404_NOT_FOUND,
@@ -530,7 +530,7 @@ def select_model_and_provider_id(
530530
model_label = model_id.split("/", 1)[1] if "/" in model_id else model_id
531531
return model_id, model_label, provider_id
532532
except (StopIteration, AttributeError) as e:
533-
message = "No LLM model found in available models"
533+
message = "No models available"
534534
logger.error(message)
535535
raise HTTPException(
536536
status_code=status.HTTP_404_NOT_FOUND,

tests/e2e/features/query.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ Scenario: Check if LLM responds for query request with error for missing query
168168
}
169169
"""
170170
Then The status code of the response is 200
171-
Scenario: Check if LLM responds with an error when no models are configured
172-
Given The service is started locally
173-
And REST API service prefix is /v1
171+
172+
@no_models
173+
Scenario: Check if LLM responds with an error when no models are configured
174174
Given The system is in default state
175175
And I set the Authorization header to Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ikpva
176176
When I use "query" to ask question with authorization header

tests/e2e/features/streaming_query.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Feature: streaming_query endpoint API tests
126126
"""
127127
{"query": "Say hello"}
128128
"""
129-
Then The status code of the response is 400
129+
Then The status code of the response is 401
130130
And The body of the response is the following
131131
"""
132132
{"detail": "No Authorization header found"}

tests/integration/test_openapi_json.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def test_servers_section_present_from_url(spec_from_url: dict[str, Any]) -> None
129129
("/v1/shields", "get", {"200", "500"}),
130130
("/v1/providers", "get", {"200", "500"}),
131131
("/v1/providers/{provider_id}", "get", {"200", "404", "422", "500"}),
132-
("/v1/query", "post", {"200", "400", "403", "500", "422"}),
132+
("/v1/query", "post", {"200", "401", "403", "404", "500", "422"}),
133133
("/v1/streaming_query", "post", {"200", "400", "401", "403", "422", "500"}),
134134
("/v1/config", "get", {"200", "503"}),
135135
("/v1/feedback", "post", {"200", "401", "403", "500", "422"}),
@@ -185,7 +185,7 @@ def test_paths_and_responses_exist_from_file(
185185
("/v1/shields", "get", {"200", "500"}),
186186
("/v1/providers", "get", {"200", "500"}),
187187
("/v1/providers/{provider_id}", "get", {"200", "404", "422", "500"}),
188-
("/v1/query", "post", {"200", "400", "403", "500", "422"}),
188+
("/v1/query", "post", {"200", "401", "403", "404", "500", "422"}),
189189
("/v1/streaming_query", "post", {"200", "400", "401", "403", "422", "500"}),
190190
("/v1/config", "get", {"200", "503"}),
191191
("/v1/feedback", "post", {"200", "401", "403", "500", "422"}),

tests/unit/app/endpoints/test_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ def test_select_model_and_provider_id_no_available_models(
459459
mock_client.models.list(), query_request.model, query_request.provider
460460
)
461461

462-
assert "No LLM model found in available models" in str(exc_info.value)
462+
assert "No models available" in str(exc_info.value)
463463

464464

465465
def test_validate_attachments_metadata() -> None:

0 commit comments

Comments
 (0)