Skip to content

Commit 0d0cc5c

Browse files
committed
fix(provider-tck): say that the HTTP control drives its backend over HTTP
`HttpControl` did not declare the optional `control_api` property, so a flagd conformance report omitted `backend.controlApi` -- putting a run driven over the normative control API on the same footing as one from a control that declined to say which path it took. That distinction is the whole point of the field: an in-process claim from a provider that does have a backend is meant to be readable as such. The property is documented on `BackendControl` in the base, so declaring it here adds nothing to the adopter API. Every operation on this class is an HTTP request to `control-api.yaml`, which makes "http" the one answer it can give without qualification. Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>
1 parent fbe273c commit 0d0cc5c

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎tools/openfeature-provider-tck/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,10 @@ This mirrors what `openfeature-flagd-api-testkit` already does for the flagd tes
375375
| `test_lifecycle_steps` | the steps that call the provider directly | the in-memory suites skip `@lifecycle`, so the shutdown, re-initialise and metadata steps are driven against a recording provider instead |
376376
| `test_declaration` | what a `TckConfig` claims | none of it is observable in a pass or a fail, so nothing else would catch it |
377377
| `test_extensions` | an adopter's own scenarios | an extension runs inside the canonical suite, changes nothing for an adopter who has none, and cannot take a canonical scenario's identity |
378-
| `test_http_control` | `HttpControl` | the `/reset` fallback and the disconnect bookkeeping, against a stubbed control API |
378+
| `test_http_control` | `HttpControl` | the `/reset` fallback, the disconnect bookkeeping and the control-API it reports, against a stubbed control API |
379379

380380
```
381-
123 passed, 21 skipped, 2 xfailed
381+
124 passed, 21 skipped, 2 xfailed
382382
```
383383

384384
No Docker and no network beyond loopback. The conformance suites take under a second;

‎tools/openfeature-provider-tck/src/openfeature/contrib/tools/provider_tck/httpcontrol.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ def __init__(
118118
# prepare_scenario starts it rather than merely resetting flag state.
119119
self._backend_maybe_down = False
120120

121+
@property
122+
def control_api(self) -> str:
123+
"""Report that this control drives its backend over the HTTP control API.
124+
125+
The optional property ``BackendControl`` documents. This is the one
126+
control in the package that can answer it without qualification: every
127+
operation below is an HTTP request to ``control-api.yaml``. Leaving it
128+
unsaid would put a report from the normative control path on the same
129+
footing as one from a control that declined to say which path it took.
130+
"""
131+
return "http"
132+
121133
@property
122134
def description(self) -> str:
123135
return f"the backend at {self._base_url}, driven over the control API"

‎tools/openfeature-provider-tck/tests/test_http_control.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,14 @@ def test_a_trailing_slash_does_not_produce_a_double_slash_path() -> None:
221221
HttpControl(stub.base_url + "/").change_flag()
222222

223223
assert stub.paths == ["/change"]
224+
225+
226+
def test_the_control_reports_which_api_it_drives_the_backend_through() -> None:
227+
"""The optional property ``BackendControl`` documents, answered here.
228+
229+
A control that stays quiet has the field omitted from its report, which puts
230+
the normative HTTP path on the same footing as one that declined to say. This
231+
control can say, so it does.
232+
"""
233+
with _StubControlApi() as stub:
234+
assert HttpControl(stub.base_url).control_api == "http"

0 commit comments

Comments
 (0)