(self, respx_mock: MockRouter, caplog: pytest.LogCaptureFixture)
| 315 | |
| 316 | @pytest.mark.respx() |
| 317 | def test_azure_api_key_redacted(self, respx_mock: MockRouter, caplog: pytest.LogCaptureFixture) -> None: |
| 318 | respx_mock.post( |
| 319 | "https://example-resource.azure.openai.com/openai/deployments/gpt-4/chat/completions?api-version=2024-06-01" |
| 320 | ).mock(return_value=httpx.Response(200, json={"model": "gpt-4"})) |
| 321 | |
| 322 | client = AzureOpenAI( |
| 323 | api_version="2024-06-01", |
| 324 | api_key="example_api_key", |
| 325 | azure_endpoint="https://example-resource.azure.openai.com", |
| 326 | ) |
| 327 | |
| 328 | with caplog.at_level(logging.DEBUG): |
| 329 | client.chat.completions.create(messages=[], model="gpt-4") |
| 330 | |
| 331 | for record in caplog.records: |
| 332 | if is_dict(record.args) and record.args.get("headers") and is_dict(record.args["headers"]): |
| 333 | assert record.args["headers"]["api-key"] == "<redacted>" |
| 334 | |
| 335 | @pytest.mark.respx() |
| 336 | def test_azure_bearer_token_redacted(self, respx_mock: MockRouter, caplog: pytest.LogCaptureFixture) -> None: |
nothing calls this directly
no test coverage detected