@@ -306,6 +306,56 @@ describe("microsoft-foundry plugin", () => {
|
306 | 306 | expect(config.auth?.order?.["microsoft-foundry"]).toEqual(["microsoft-foundry:default"]); |
307 | 307 | }); |
308 | 308 | |
| 309 | +it("fails clearly when the selected Azure subscription is not in the enabled list", async () => { |
| 310 | +const provider = registerProvider(); |
| 311 | +execFileSyncMock.mockImplementation((_file: string, args: string[]) => { |
| 312 | +const command = args.join(" "); |
| 313 | +if (command === "version --output none") { |
| 314 | +return ""; |
| 315 | +} |
| 316 | +if (command === "account show --output json") { |
| 317 | +return JSON.stringify({ |
| 318 | +id: "sub-one", |
| 319 | +name: "Subscription One", |
| 320 | +tenantId: "tenant-one", |
| 321 | +state: "Enabled", |
| 322 | +user: { name: "user@example.com" }, |
| 323 | +}); |
| 324 | +} |
| 325 | +if (command === "account list --output json --all") { |
| 326 | +return JSON.stringify([ |
| 327 | +{ |
| 328 | +id: "sub-one", |
| 329 | +name: "Subscription One", |
| 330 | +tenantId: "tenant-one", |
| 331 | +state: "Enabled", |
| 332 | +}, |
| 333 | +{ |
| 334 | +id: "sub-two", |
| 335 | +name: "Subscription Two", |
| 336 | +tenantId: "tenant-one", |
| 337 | +state: "Enabled", |
| 338 | +}, |
| 339 | +]); |
| 340 | +} |
| 341 | +throw new Error(`unexpected az command: ${command}`); |
| 342 | +}); |
| 343 | +const entraAuth = provider.auth.find((method: { id: string }) => method.id === "entra-id"); |
| 344 | + |
| 345 | +await expect( |
| 346 | +entraAuth?.run({ |
| 347 | +config: {}, |
| 348 | +agentDir: defaultFoundryAgentDir, |
| 349 | +opts: {}, |
| 350 | +prompter: { |
| 351 | +confirm: vi.fn(async () => true), |
| 352 | +select: vi.fn(async () => "missing-subscription"), |
| 353 | +note: vi.fn(async () => undefined), |
| 354 | +}, |
| 355 | +} as never), |
| 356 | +).rejects.toThrow("Selected subscription not found: missing-subscription"); |
| 357 | +}); |
| 358 | + |
309 | 359 | it("preserves the model-derived base URL for Entra runtime auth refresh", async () => { |
310 | 360 | const provider = registerProvider(); |
311 | 361 | const prepareRuntimeAuth = requirePrepareRuntimeAuth(provider); |
|