Commit 20f5ae6
authored
Route local API by api_type before server-specific strategies (#2129)
## Summary
Move the `APIType.LOCAL` check to the top of `build_auth_strategy` so a
local config can carry any `server` identity (e.g. `Server.REXEL`)
purely for labelling, without misrouting to that server's cloud
strategy.
## Why
Local configs are built via `create_local_server_config`. Previously, if
a caller set `server=Server.REXEL` on a local config, the
server-specific Rexel branch matched *before* the generic `api_type ==
APIType.LOCAL` branch and routed to the Rexel OAuth strategy — which
rejects a local token with `TypeError`. The only `server` value that
worked for local was one with no earlier branch (the
`Server.SOMFY_DEVELOPER_MODE` default).
Routing on `api_type` first removes that coupling:
`server`/`name`/`manufacturer` become free-form labels for local
connections.
## Safety
Every server in `SUPPORTED_SERVERS` is `APIType.CLOUD`; the only source
of `APIType.LOCAL` is `create_local_server_config` (or a hand-built
`ServerConfig`). So moving the `LOCAL` check first cannot steal routing
from any cloud server.
## Tests
- Adds `test_build_auth_strategy_local_token_with_cloud_server`: a local
config with `server=Server.REXEL` must still select
`LocalTokenAuthStrategy`.
- Full `tests/test_auth.py` suite passes (70 tests).1 parent c0a5c50 commit 20f5ae6
2 files changed
Lines changed: 41 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
42 | 56 | | |
43 | 57 | | |
44 | 58 | | |
| |||
79 | 93 | | |
80 | 94 | | |
81 | 95 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | 96 | | |
95 | 97 | | |
96 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
343 | 370 | | |
344 | 371 | | |
345 | 372 | | |
| |||
0 commit comments