-
Notifications
You must be signed in to change notification settings - Fork 56
Use correct status codes for /query endpoint #776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f20305b
9a4298c
753e3e9
c5bcb25
14b1227
0d2d85b
977825e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| --- | ||
| # A run configuration for lightspeed-stack that defines no models. | ||
| # Used for E2E testing. | ||
| llm: | ||
| mode: "library" | ||
| model_name: "" | ||
| model_provider: "" | ||
| api_key: "EMPTY" | ||
| parameters: | ||
| max_new_tokens: 256 | ||
| server: | ||
| host: "0.0.0.0" | ||
| port: 8080 | ||
| url: "http://llama-stack:8080" | ||
| lightspeed_stack: | ||
| server: | ||
| host: "0.0.0.0" | ||
| port: 8008 | ||
| logging: | ||
| level: "INFO" | ||
| style: "default" | ||
| model_defaults: | ||
| provider: "openai" | ||
| model: "gpt-4-turbo" | ||
| providers: | ||
| - name: "openai" | ||
| api_key: "EMPTY" | ||
| url: "http://llama-stack:8080" | ||
| type: "openai" | ||
| models: [] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,7 +108,7 @@ Feature: feedback endpoint API tests | |
| And The body of the response is the following | ||
| """ | ||
| { | ||
| "detail": "Forbidden: User is not authorized to access this resource" | ||
| "detail": "Forbidden: Feedback is disabled" | ||
| } | ||
| """ | ||
|
|
||
|
|
@@ -246,7 +246,6 @@ Feature: feedback endpoint API tests | |
| Scenario: Check if feedback endpoint is not working when not authorized | ||
| Given The system is in default state | ||
| And A new conversation is initialized | ||
| And I remove the auth header | ||
| When I submit the following feedback for the conversation created before | ||
| """ | ||
| { | ||
|
|
@@ -256,29 +255,23 @@ Feature: feedback endpoint API tests | |
| "user_question": "Sample Question" | ||
| } | ||
| """ | ||
| Then The status code of the response is 400 | ||
| Then The status code of the response is 401 | ||
| And The body of the response is the following | ||
| """ | ||
| { | ||
| "detail": { | ||
| "cause": "Missing or invalid credentials provided by client", | ||
| "response": "Unauthorized" | ||
| } | ||
| "detail": "No Authorization header found" | ||
| } | ||
|
Comment on lines
+258
to
263
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the inherited auth header before expecting 401. Because the background step sets a valid Authorization header, this scenario will still send credentials and won’t return 401. To make the test match the new expectation, clear the header after initializing the conversation: And A new conversation is initialized
+ And I remove the auth header
When I submit the following feedback for the conversation created before
🤖 Prompt for AI Agents |
||
| """ | ||
|
|
||
| Scenario: Check if update feedback status endpoint is not working when not authorized | ||
| Given The system is in default state | ||
| And I remove the auth header | ||
| When The feedback is enabled | ||
| Then The status code of the response is 400 | ||
| Then The status code of the response is 401 | ||
| And The body of the response is the following | ||
| """ | ||
| { | ||
| "detail": { | ||
| "cause": "Missing or invalid credentials provided by client", | ||
| "response": "Unauthorized" | ||
| } | ||
| "detail": "No Authorization header found" | ||
| } | ||
| """ | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,12 +53,36 @@ Feature: Query endpoint API tests | |
| """ | ||
| {"query": "Write a simple code for reversing string"} | ||
| """ | ||
| Then The status code of the response is 400 | ||
| Then The status code of the response is 401 | ||
| And The body of the response is the following | ||
| """ | ||
| {"detail": "No Authorization header found"} | ||
| """ | ||
|
|
||
| Scenario: Check if LLM responds to sent question with error when authenticated with invalid token | ||
| Given The system is in default state | ||
| And I set the Authorization header to Bearer invalid | ||
| When I use "query" to ask question with authorization header | ||
| """ | ||
| {"query": "Write a simple code for reversing string"} | ||
| """ | ||
| Then The status code of the response is 401 | ||
| And The body of the response is the following | ||
| """ | ||
| {"detail":"Invalid token: decode error"} | ||
| """ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The above scenario fails (returns 200) because "Bearer invalid" is actually a valid token - everything that matches "Bearer something" is valid token.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you actually want to test invalid bearer token, write something like BearerInvalid, Invalid or whatever you want. When you use Bearer with anything, it always passes the check |
||
|
|
||
| Scenario: Check if LLM responds to sent question with error when model does not exist | ||
| Given The system is in default state | ||
| And I set the Authorization header to Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ikpva | ||
| When I use "query" to ask question with authorization header | ||
| """ | ||
| {"query": "Write a simple code for reversing string", "model": "does-not-exist", "provider": "does-not-exist"} | ||
| """ | ||
| Then The status code of the response is 404 | ||
| And The body of the response contains Model does-not-exist from provider does-not-exist not found in available models | ||
|
|
||
|
|
||
| Scenario: Check if LLM responds to sent question with error when attempting to access conversation | ||
| Given The system is in default state | ||
| And I set the Authorization header to Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ikpva | ||
|
|
@@ -138,3 +162,4 @@ Scenario: Check if LLM responds for query request with error for missing query | |
| } | ||
| """ | ||
| Then The status code of the response is 200 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not valid config for lightspeed-stack.