fix test case CORS Options
This commit is contained in:
parent
7445bb8ad9
commit
1a7c5fd50a
3 changed files with 7 additions and 3 deletions
|
@ -2750,6 +2750,8 @@ int main(int argc, char ** argv) {
|
|||
}
|
||||
|
||||
// API key is invalid or not provided
|
||||
// TODO: make another middleware for CORS related logic
|
||||
res.set_header("Access-Control-Allow-Origin", req.get_header_value("Origin"));
|
||||
res.set_content("Unauthorized: Invalid API Key", "text/plain; charset=utf-8");
|
||||
res.status = 401; // Unauthorized
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ Feature: Security
|
|||
|
||||
|
||||
Scenario Outline: CORS Options
|
||||
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>
|
||||
|
||||
|
|
|
@ -564,8 +564,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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue