Skip to content

test(model): cover createAzureOpenAILanguageModel auth headers - #436

Open
Mohammed Alkindi (MohammedAlkindi) wants to merge 1 commit into
microsoft:mainfrom
MohammedAlkindi:test/azure-model-auth-headers
Open

Mohammed Alkindi (MohammedAlkindi) wants to merge 1 commit into
microsoft:mainfrom
MohammedAlkindi:test/azure-model-auth-headers

Conversation

@MohammedAlkindi

Copy link
Copy Markdown

createAzureOpenAILanguageModel sets two headers, and the comments in model.ts:214-219 say why: Authorization: Bearer <key> for managed identity, api-key for a regular key. PR #139 added the first one after 401s. typescript/tests/model.test.mjs had describe blocks for createOpenAILanguageModel, createLanguageModel and the timeout/size-limit behaviour, and nothing for Azure, so a regression to the single-header shape would not have been caught.

This adds a createAzureOpenAILanguageModel block asserting both headers, following the existing setupFetch / capturedRequests pattern in the file.

Verified it actually catches the regression by deleting the Authorization line from the built Azure factory only, leaving the OpenAI one intact, and re-running:

without the header   1 failed, 31 passed
                     actual: undefined
                     expected: 'Bearer azure-test-key'

with the header      32 passed

Could not verify: npm ci from a clean node_modules runs the workspace prepare lifecycle, which does not complete on this machine, so I installed with --ignore-scripts and built with npx tsc -p src before running node --test. Same compiled output, different entry point.

The Azure factory sets both an Authorization Bearer header, needed for managed identity, and an api-key header. Nothing asserted either, so a regression to the pre-microsoft#139 single-header shape would have gone unnoticed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant