|
28 | 28 | TeamsAdapter, |
29 | 29 | _handle_teams_error, |
30 | 30 | ) |
31 | | -from chat_sdk.adapters.teams.types import TeamsAdapterConfig, TeamsThreadId |
| 31 | +from chat_sdk.adapters.teams.types import ( |
| 32 | + TeamsAdapterConfig, |
| 33 | + TeamsAuthCertificate, |
| 34 | + TeamsThreadId, |
| 35 | +) |
32 | 36 | from chat_sdk.shared.errors import ( |
33 | 37 | AdapterPermissionError, |
34 | 38 | AdapterRateLimitError, |
@@ -542,10 +546,45 @@ def test_raises_validation_error(self): |
542 | 546 | TeamsAdapterConfig( |
543 | 547 | app_id="app", |
544 | 548 | app_password="pass", |
545 | | - certificate={"certificate_private_key": "key", "certificate_thumbprint": "thumb"}, |
| 549 | + certificate=TeamsAuthCertificate( |
| 550 | + certificate_private_key="key", |
| 551 | + certificate_thumbprint="thumb", |
| 552 | + ), |
546 | 553 | ) |
547 | 554 | ) |
548 | 555 |
|
| 556 | + def test_raises_with_exact_upstream_message(self): |
| 557 | + """Startup throw message matches upstream adapter-teams/src/config.ts:13-18 verbatim. |
| 558 | +
|
| 559 | + Upstream references ``appPassword`` (camelCase TS field name); we preserve |
| 560 | + that in the error text so consumers tailing upstream logs see identical |
| 561 | + output. Protects against well-meaning rewording to ``app_password``. |
| 562 | + """ |
| 563 | + expected = ( |
| 564 | + "Certificate-based authentication is not yet supported by the Teams SDK adapter. " |
| 565 | + "Use appPassword (client secret) or federated (workload identity) authentication instead." |
| 566 | + ) |
| 567 | + with pytest.raises(ValidationError) as exc_info: |
| 568 | + TeamsAdapter( |
| 569 | + TeamsAdapterConfig( |
| 570 | + certificate=TeamsAuthCertificate(certificate_private_key="key"), |
| 571 | + ) |
| 572 | + ) |
| 573 | + assert expected in str(exc_info.value) |
| 574 | + |
| 575 | + def test_minimal_certificate_only_requires_private_key(self): |
| 576 | + """``certificate_thumbprint`` and ``x5c`` are optional per upstream types.ts:7-9. |
| 577 | +
|
| 578 | + A ``TeamsAuthCertificate`` constructed with only ``certificate_private_key`` |
| 579 | + must still trigger the startup throw (i.e. the adapter checks presence, not |
| 580 | + shape). |
| 581 | + """ |
| 582 | + cert = TeamsAuthCertificate(certificate_private_key="pem-key") |
| 583 | + assert cert.certificate_thumbprint is None |
| 584 | + assert cert.x5c is None |
| 585 | + with pytest.raises(ValidationError, match="Certificate-based"): |
| 586 | + TeamsAdapter(TeamsAdapterConfig(certificate=cert)) |
| 587 | + |
549 | 588 |
|
550 | 589 | # --------------------------------------------------------------------------- |
551 | 590 | # Stream via post+edit |
|
0 commit comments