Documentation
¶
Overview ¶
Package conformance holds the WebSub and PubSubHubbub 0.4 conformance cases for this package, written so they can be replayed against a websub handler mounted behind any router.
The core module runs them directly. Each adapter module runs the same cases through its own wrapper, which is where a bug in the wrapping shows up: a framework that drops a header, rewrites a path, or consumes the request body breaks a case here rather than in production. If you are writing an adapter of your own, run them the same way:
func TestConformance(t *testing.T) {
conformance.Run(t, conformance.Config{
Wrap: func(h http.Handler) http.Handler { return myAdapter(h) },
})
}
This package is a test helper. It carries no compatibility promise, and the set of cases grows whenever a conformance gap is found.
Index ¶
Constants ¶
const TestLease = 90 * time.Minute
TestLease is the lease fakeHub grants.
Variables ¶
This section is empty.
Functions ¶
func RunHub ¶
RunHub executes the hub conformance cases: subscription handling, lease policy, verification, and content distribution.
func RunPassthrough ¶
RunPassthrough checks that a router preserves the request and response details this protocol depends on.
The full suite in Run already covers these indirectly, but a failure there is hard to read. These cases fail with the exact byte, header, or status that went missing, which is what you want when a framework's request translation is the suspect.
func RunPublisher ¶
RunPublisher executes the publisher conformance cases: discovery advertisement and both publishing methods.
func RunSubscriber ¶
RunSubscriber executes the subscriber conformance cases: discovery, subscription requests, verification of intent, denial, and authenticated content distribution.
Types ¶
type Config ¶
type Config struct {
// Wrap mounts a websub handler behind the router under test and returns
// something serving the same requests. Nil means test the handler
// directly, which is what the core module does.
//
// The handler must be mounted so that every path below the root reaches
// it, since a subscriber's callbacks live under a prefix.
Wrap func(http.Handler) http.Handler
// Serve mounts a websub handler on the router under test, starts it, and
// returns the base URL it is reachable at. It must register its own
// cleanup. When nil, the suite serves Wrap(h) on an httptest server.
Serve func(t *testing.T, h http.Handler) string
// Modes restricts the run to particular spec modes. Empty means every
// mode a case declares support for.
Modes []websub.Mode
}
Config describes the implementation under test.
Set at most one of Wrap and Serve. Wrap suits any router that is itself an http.Handler, which is most of them. Serve exists for frameworks built on something other than net/http, where running the framework's own server is the only faithful test.
type Notification ¶
Notification is one content distribution request as a subscriber saw it.