mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-03 22:19:27 +00:00
test: assert Azure endpoint hostname instead of substring match
CodeQL flagged the `"test.openai.azure.com" in llm.endpoint` substring check as incomplete URL sanitization — the substring could match in an arbitrary position. Parse the URL and assert against `urlparse(...).hostname` instead, which is the precise check we want.
This commit is contained in:
@@ -2,6 +2,7 @@ import os
|
||||
import sys
|
||||
import types
|
||||
from unittest.mock import patch, MagicMock, Mock
|
||||
from urllib.parse import urlparse
|
||||
import pytest
|
||||
|
||||
from crewai.llm import LLM
|
||||
@@ -442,7 +443,7 @@ def test_azure_lazy_build_reads_env_vars_set_after_construction():
|
||||
assert client is not None
|
||||
assert llm.api_key == "late-key"
|
||||
assert llm.endpoint is not None
|
||||
assert "test.openai.azure.com" in llm.endpoint
|
||||
assert urlparse(llm.endpoint).hostname == "test.openai.azure.com"
|
||||
assert llm.is_azure_openai_endpoint is True
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user