Documentation
¶
Overview ¶
Package cdntest is a fake CDN edge for tests (decision 0029). It checks a provider's URL signature the way the real edge does, then serves the blob the URL names from a blob store, honouring Range and the response overrides, so a download redirect is tested end to end without a cloud.
The edge listens on "localhost" by default. A registry under test listens on 127.0.0.1, so Go clients, the JFrog CLI among them, treat the edge as another host and drop their Authorization header on the redirect, as they do for a real CDN; the edge records whether one arrived.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSignature = errors.New("cdntest: signature refused")
ErrSignature reports a request the edge refuses: no signature, a bad one, an unknown key or an expired URL.
Functions ¶
This section is empty.
Types ¶
type CloudCDN ¶
CloudCDN validates URL signatures as Cloud CDN does: Keys maps each key name on the backend bucket to its raw 16-byte key. Cloud CDN itself passes an unsigned request to the origin, which refuses it because the bucket is private (decision 0029); the fake refuses it at the edge with the same status. URLPrefix signatures and signed cookies are not modelled.
type CloudFront ¶
CloudFront validates canned-policy signed URLs as CloudFront does with a trusted key group: Keys maps each public key ID to its key. Custom policies are not modelled.
type Edge ¶
type Edge struct {
// URL is the edge's base URL, for example "http://localhost:51234"; use
// it as the CDN domain.
URL string
// contains filtered or unexported fields
}
Edge is a running fake edge.
func StartFrontDoor ¶
func StartFrontDoor(o FrontDoorOptions) (*Edge, error)
StartFrontDoor listens and serves a fake Front Door until Close.
type FrontDoorOptions ¶
type FrontDoorOptions struct {
// Origin is the storage endpoint the edge forwards to, the account URL
// without a trailing slash, for example Azurite's
// "http://127.0.0.1:10000/devstoreaccount1". The request's path
// ("/<container>/<blob name>") and query, the SAS, are appended.
Origin string
// CacheTTL is the route's cache expiry cap: the longest a whole-object
// response stays cached under its full URL, query included, shortened by
// the response's Cache-Control max-age. Zero means no caching.
CacheTTL time.Duration
// Host is the address the edge listens on; empty means "localhost".
Host string
// Now is the cache's clock; nil means time.Now.
Now func() time.Time
// Client forwards requests to the origin; nil means a plain client.
Client *http.Client
}
FrontDoorOptions configures StartFrontDoor.
type Options ¶
type Options struct {
// Validator checks every request; required.
Validator Validator
// Origin serves the blobs; required. The last segment of a request path
// is the blob's SHA-256, as in every store's object keys.
Origin blob.Store
// Host is the address the edge listens on; empty means "localhost".
Host string
// Now is the clock signatures are checked against; nil means time.Now.
Now func() time.Time
}
Options configures Start.
type Request ¶
type Request struct {
Method string
Path string
Range string
// Authorization reports whether the request carried that header, which
// a client must not send to a CDN on another host.
Authorization bool
Status int
// Cached reports a Front Door edge answering from its cache.
Cached bool
}
Request is one request the edge answered.