summaryrefslogtreecommitdiff
path: root/examples/server/tests
diff options
context:
space:
mode:
authorXuan Son Nguyen <thichthat@gmail.com>2024-03-09 11:27:53 +0100
committerGitHub <noreply@github.com>2024-03-09 11:27:53 +0100
commit950ba1ab84db199f0bbdecdb2bb911f35261b321 (patch)
treee1633dcc8ed207b71d0b6c60af099ae344a0cb66 /examples/server/tests
parente1fa9569ba8ce276bc7801a3cebdcf8b1aa116ea (diff)
Server: reorganize some http logic (#5939)
* refactor static file handler * use set_pre_routing_handler for validate_api_key * merge embedding handlers * correct http verb for endpoints * fix embedding response * fix test case CORS Options * fix code style
Diffstat (limited to 'examples/server/tests')
-rw-r--r--examples/server/tests/features/security.feature5
-rw-r--r--examples/server/tests/features/steps/steps.py3
2 files changed, 5 insertions, 3 deletions
diff --git a/examples/server/tests/features/security.feature b/examples/server/tests/features/security.feature
index 42a6709a..1d6aa40e 100644
--- a/examples/server/tests/features/security.feature
+++ b/examples/server/tests/features/security.feature
@@ -39,8 +39,9 @@ Feature: Security
Scenario Outline: CORS Options
- When an OPTIONS request is sent from <origin>
- Then CORS header <cors_header> is set to <cors_header_value>
+ Given a user api key llama.cpp
+ When an OPTIONS request is sent from <origin>
+ Then CORS header <cors_header> is set to <cors_header_value>
Examples: Headers
| origin | cors_header | cors_header_value |
diff --git a/examples/server/tests/features/steps/steps.py b/examples/server/tests/features/steps/steps.py
index 0076f805..14204850 100644
--- a/examples/server/tests/features/steps/steps.py
+++ b/examples/server/tests/features/steps/steps.py
@@ -582,8 +582,9 @@ async def step_detokenize(context):
@async_run_until_complete
async def step_options_request(context, origin):
async with aiohttp.ClientSession() as session:
+ headers = {'Authorization': f'Bearer {context.user_api_key}', 'Origin': origin}
async with session.options(f'{context.base_url}/v1/chat/completions',
- headers={"Origin": origin}) as response:
+ headers=headers) as response:
assert response.status == 200
context.options_response = response