flyte.extras.webhooks.testing
Conformance harness — enforce the common provider format.
Every flyteplugins.webhooks.<product> plugin ships a one-line test:
from flyte.extras.webhooks.testing import assert_provider_conforms
import flyteplugins.github as plugin
def test_conformance():
assert_provider_conforms(plugin)CI then fails if a plugin drifts from the shared format. The checks are the ones that actually bit the per-product plugins this family replaces: verification that raises instead of returning False, event constants that render as enum names, dedupe keys that collapse distinct events onto one key.
Directory
Protocols
| Protocol | Description |
|---|---|
ProviderFactory |
What a plugin’s exported provider class must look like. |
Methods
| Method | Description |
|---|---|
assert_provider_conforms() |
Assert that a provider plugin implements the common webhook contract. |
Methods
assert_provider_conforms()
def assert_provider_conforms(
plugin: typing.Any,
)Assert that a provider plugin implements the common webhook contract.
The contract:
- exports exactly one
Providersubclass, constructible with no arguments and whosenamematches the plugin’s module name, so/webhook/<name>routes to it andproviders=[SomethingProvider()]is all a user writes; - exports an
eventsmodule whose__all__namesEventTypesubclasses, every member of which is astrthat renders as its wire value; - exports
SAMPLE_DELIVERY, a(headers, body)pair of a real payload, which must verify under a known secret, reject the wrong secret, survive hostile headers without raising, parse into aWebhookEventcarrying this provider’s name, and dedupe stably.
Providers with signed=True must additionally reject a tampered body, since
a signature covers it. A shared token does not, so signed=False opts out of
that one check — and makes the dashboard say the product does not sign.
SAMPLE_DELIVERY is what makes the rest checkable: without a real payload
there is no way to assert that parse and verify actually agree with the
product, and every check here would be vacuous.
Raises AssertionError with a specific message on any deviation.
| Parameter | Type | Description |
|---|---|---|
plugin |
typing.Any |