Documentation
¶
Index ¶
- Variables
- func ClientMaxRedirects(client *http.Client, maxRedirects int) *http.Client
- func ClientNoRedirect(client *http.Client) *http.Client
- func DrainRelayURL[T any](ctx context.Context, client *http.Client, relayURL string, ...) ([]T, error)
- type CheckStatus
- type CheckStatusSpec
- type GoGetTest
- type HealthzSpec
- type HealthzTest
- type MetricsReporter
- type MetricsSpec
- type MetricsTest
- type NavigateOption
- func WithContextOptions(opts ...chromedp.ContextOption) NavigateOption
- func WithElementTimeout(timeout time.Duration) NavigateOption
- func WithExecAllocatorOptions(opts ...chromedp.ExecAllocatorOption) NavigateOption
- func WithSelectorActions(selector string, actions ...chromedp.Action) NavigateOption
- func WithSuppressedCertErrorsFor(certs ...*x509.Certificate) NavigateOption
- func WithTimeout(timeout time.Duration) NavigateOption
- func WithUserDataDir(dir string) NavigateOption
- type NavigationSpec
- type NavigationTest
- type RedirectSpec
- type RedirectTest
- type SelectorAction
- type TLSSpec
- type TLSTest
- type WebhookRoundTripSpec
- type WebhookRoundTripTest
Constants ¶
This section is empty.
Variables ¶
var ( )
var ( ErrGoGetUnexpectedError = errors.New("go-get unexpected error") ErrGoGetPathNotFound = errors.New("go-get path not found") ErrGoGetNotFound = errors.New("go-get meta tag not found") ErrGoGetContentMismatch = errors.New("go-get meta tag content mismatch") )
var ( ErrRedirectUnexpectedError = errors.New("redirect unexpected error") ErrRedirectPathNotFound = errors.New("redirect path not found") ErrRedirectTargetMismatch = errors.New("redirect target mismatch") ErrRedirectStatusCodeMismatch = errors.New("redirect status code mismatch") )
var ( ErrCheckStatusUnexpectedError = errors.New("check status unexpected error") ErrCheckStatusCodeMismatch = errors.New("check status code mismatch") )
Functions ¶
func ClientMaxRedirects ¶
ClientMaxRedirects returns a copy of the given client that follows up to maxRedirects redirects.
func ClientNoRedirect ¶
ClientNoRedirect returns a copy of the given client that does not follow redirects.
func DrainRelayURL ¶
func DrainRelayURL[T any](ctx context.Context, client *http.Client, relayURL string, timeout time.Duration) ([]T, error)
DrainRelayURL collects all payloads from relayURL, decoding each as T. It uses timeout as an idle deadline: after receiving a payload it resets the timer, so a short queue returns quickly. It returns when no payload arrives within timeout or ctx is cancelled.
Types ¶
type CheckStatus ¶
type CheckStatus struct {
// contains filtered or unexported fields
}
CheckStatus validates that a set of URLs return a given status code after following up to a configurable number of redirects.
func NewCheckStatus ¶
func NewCheckStatus(specs ...CheckStatusSpec) *CheckStatus
NewCheckStatus creates a new CheckStatus for the given specs.
type CheckStatusSpec ¶
type CheckStatusSpec struct {
URL string `yaml:"url" json:"url"`
Code int `yaml:"code" json:"code"`
Redirects int `yaml:"redirects" json:"redirects"`
}
CheckStatusSpec represents a specification for a status check after following redirects.
func GenerateCheckStatusSpecs ¶
func GenerateCheckStatusSpecs(urls []string, code int, redirects int) []CheckStatusSpec
GenerateCheckStatusSpecs generates a slice of CheckStatusSpec for the given URLs, status code and number of redirects.
func (CheckStatusSpec) String ¶
func (s CheckStatusSpec) String() string
String implements fmt.Stringer, returning the YAML representation of the spec.
type GoGetTest ¶
type GoGetTest struct {
// contains filtered or unexported fields
}
GoGetTest can be used to validate go-get meta tags for a set of import paths.
func NewGoGetTest ¶
type HealthzSpec ¶
type HealthzSpec struct {
URL string `yaml:"url" json:"url"`
Interval time.Duration `yaml:"interval" json:"interval"`
Timeout time.Duration `yaml:"timeout" json:"timeout"`
NumHealthChecks int `yaml:"num_health_checks" json:"num_health_checks"`
}
func (HealthzSpec) String ¶
func (s HealthzSpec) String() string
String implements fmt.Stringer, returning the YAML representation of the spec.
type HealthzTest ¶
type HealthzTest struct {
// contains filtered or unexported fields
}
HealthzTest can be used to validate /healthz endpoints.
func NewHealthzTest ¶
func NewHealthzTest(specs ...HealthzSpec) *HealthzTest
type MetricsReporter ¶
type MetricsSpec ¶
type MetricsSpec struct {
URL string `yaml:"url,omitempty"`
MetricNames []string `yaml:"names,omitempty"`
}
func (MetricsSpec) String ¶
func (s MetricsSpec) String() string
String implements fmt.Stringer, returning the YAML representation of the spec.
type MetricsTest ¶
type MetricsTest struct {
// contains filtered or unexported fields
}
MetricsTest can be used to validate /metrics endpoints.
func NewMetricsTest ¶
func NewMetricsTest(reporter MetricsReporter, specs ...MetricsSpec) *MetricsTest
type NavigateOption ¶
type NavigateOption func(*navigateTestOptions)
NavigateOption represents options to configure NavigationTest.
func WithContextOptions ¶
func WithContextOptions(opts ...chromedp.ContextOption) NavigateOption
WithContextOptions appends options to the chromedp context.
func WithElementTimeout ¶
func WithElementTimeout(timeout time.Duration) NavigateOption
WithElementTimeout sets the timeout for waiting for each individual DOM element.
func WithExecAllocatorOptions ¶
func WithExecAllocatorOptions(opts ...chromedp.ExecAllocatorOption) NavigateOption
WithExecAllocatorOptions appends options to the Chrome allocator.
func WithSelectorActions ¶
func WithSelectorActions(selector string, actions ...chromedp.Action) NavigateOption
WithSelectorActions registers chromedp actions to run after WaitVisible for the given selector. If no actions are registered for a selector, only WaitVisible is performed. Call this option once per selector that requires additional interaction (e.g. chromedp.Click).
func WithSuppressedCertErrorsFor ¶
func WithSuppressedCertErrorsFor(certs ...*x509.Certificate) NavigateOption
WithSuppressedCertErrorsFor configures Chrome to suppress certificate errors for connections whose chain includes one of the provided CA certificates. Intended for testing against servers using locally issued certificates such as those from the Pebble ACME test server.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) NavigateOption
WithTimeout sets the overall timeout for the click test execution (including startup and navigation).
func WithUserDataDir ¶
func WithUserDataDir(dir string) NavigateOption
WithUserDataDir sets the user data directory for Chrome.
type NavigationSpec ¶
type NavigationSpec struct {
}
NavigationSpec represents a specification for verifying and interacting with elements on a URL. Action is applied to every selector in Selectors; use WithSelectorActions to override the action for individual selectors. By default all selectors are waited on concurrently; set SequentialActions to true when the actions have ordering dependencies (e.g. clicking one element causes another to appear).
func (NavigationSpec) String ¶
func (s NavigationSpec) String() string
String implements fmt.Stringer, returning the YAML representation of the spec.
type NavigationTest ¶
type NavigationTest struct {
// contains filtered or unexported fields
}
NavigationTest can be used to validate pages by navigating to a URL, waiting for DOM elements to exist/be visible, and optionally acting on them.
func NewNavigationTest ¶
func NewNavigationTest(specs []NavigationSpec, opts ...NavigateOption) *NavigationTest
NewNavigationTest creates a new NavigationTest with the given specs and options.
type RedirectSpec ¶
type RedirectSpec struct {
URL string `yaml:"url" json:"url"`
Target string `yaml:"target" json:"target"`
Code int `yaml:"code" json:"code"`
}
RedirectSpec represents a specification for a redirect test.
func (RedirectSpec) String ¶
func (s RedirectSpec) String() string
String implements fmt.Stringer, returning the YAML representation of the spec.
type RedirectTest ¶
type RedirectTest struct {
// contains filtered or unexported fields
}
RedirectTest can be used to validate redirects for a set of URLs.
func NewRedirectTest ¶
func NewRedirectTest(redirects ...RedirectSpec) *RedirectTest
NewRedirectTest creates a new RedirectTest. The client's CheckRedirect will be overridden to stop at the first redirect so that each hop can be inspected.
type SelectorAction ¶
type SelectorAction string
SelectorAction is an enum of the actions that can be performed on a DOM element after it becomes visible. Use WithSelectorActions for actions not covered by this enum (e.g. right-click via MouseClickNode).
const ( // SelectorActionNone waits for the element to be visible but performs no // further action. This is the default when no action is specified. SelectorActionNone SelectorAction = "" // SelectorActionClick performs a single left click on the element. SelectorActionClick SelectorAction = "click" // SelectorActionDoubleClick performs a double left click on the element. SelectorActionDoubleClick SelectorAction = "double_click" )
func (SelectorAction) MarshalYAML ¶
func (a SelectorAction) MarshalYAML() (any, error)
func (*SelectorAction) UnmarshalYAML ¶
func (a *SelectorAction) UnmarshalYAML(value *yaml.Node) error
type TLSSpec ¶
type TLSSpec struct {
Host string `yaml:"host"`
Port string `yaml:"port"`
CustomDNSServer string `yaml:"custom-dns-server" doc:"custom DNS server to use for resolving hostnames, if empty the system resolver is used"` // custom DNS server to use for resolving hostnames, if empty the system resolver is used
LogCertInfo bool `yaml:"log-cert-info" doc:"if true, log certificate information"` // if true, log certificate information
ExpandDNSNames bool `yaml:"expand-dns-names" doc:"see tlsvalidate.WithExpandDNSNames"` // see tlsvalidate.WithExpandDNSNames
CheckSerialNumbers bool `yaml:"check-serial-numbers" doc:"see tlsvalidate.WithCheckSerialNumbers"` // see tlsvalidate.WithCheckSerialNumbers
ValidFor time.Duration `yaml:"valid-for" doc:"see tlsvalidate.WithValidForAtLeast"` // see tlsvalidate.WithValidForAtLeast
TLSMinVersion webapp.TLSVersion `yaml:"tls-min-version" doc:"see tlsvalidate.WithTLSMinVersion"` // see tlsvalidate.WithTLSMinVersion
IssuerREs cmdyaml.RegexpList `yaml:"issuer-res" doc:"see tlsvalidate.WithIssuerRegexps"` // see tlsvalidate.WithIssuerRegexps
CustomCAPEM string `yaml:"custom-ca-pem" doc:"used tlsvalidate.WithCustomRootCAPEM"` // used tlsvalidate.WithCustomRootCAPEM
CustomCAPEMOnly bool `yaml:"custom-ca-pem-only" doc:"if true, only the custom CA PEM file is used, otherwise it's appended to the system cert pool"` // if true, only the custom CA PEM file is used, otherwise it's appended to the system cert pool
// CipherSuites and SignatureAlgorithms specify the set of algorithms that
// the server must support/use; if either is non-empty the corresponding
// check is run. NotAllowedCipherSuites and NotAllowedSignatureAlgorithms
// specify algorithms that the server must not use; if either is
// non-empty and the server negotiates/uses one of them, validation
// fails.
CipherSuites webapp.CipherSuites `` /* 186-byte string literal not displayed */
NotAllowedCipherSuites webapp.CipherSuites `` /* 209-byte string literal not displayed */
SignatureAlgorithms webapp.SignatureAlgorithms `` /* 254-byte string literal not displayed */
NotAllowedSignatureAlgorithms webapp.SignatureAlgorithms `` /* 160-byte string literal not displayed */
// contains filtered or unexported fields
}
TLSSpec represents a specification for a TLS test.
func LetsEncryptTLSSpec ¶
func LetsEncryptTLSSpec() TLSSpec
func WithCustomCAPEMFile ¶
WithCustomCAPEMFile sets the custom CA PEM file for all specs if not already set in each/any spec.
type TLSTest ¶
type TLSTest struct {
// contains filtered or unexported fields
}
TLSTest can be used to validate TLS certificates for a set of hosts.
func NewTLSTest ¶
type WebhookRoundTripSpec ¶
type WebhookRoundTripSpec struct {
DeliveryURL string `yaml:"delivery_url" doc:"URL that the webhook payload is delivered to"`
RelayURL string `yaml:"relay_url" doc:"URL that the relayed result is read from"`
}
WebhookRoundTripSpec defines a single webhook round-trip test: a signed payload is delivered to DeliveryURL and the relayed result is read back from RelayURL and compared to the original payload. The signer for each delivery URL is looked up from the map passed to NewWebhookRoundTripTest.
func (WebhookRoundTripSpec) String ¶
func (s WebhookRoundTripSpec) String() string
String implements fmt.Stringer, returning the YAML representation of the spec.
type WebhookRoundTripTest ¶
type WebhookRoundTripTest struct {
// contains filtered or unexported fields
}
WebhookRoundTripTest validates webhook relay round-trips for a set of specs.
func NewWebhookRoundTripTest ¶
func NewWebhookRoundTripTest(signers map[string]operations.Signer, specs ...WebhookRoundTripSpec) *WebhookRoundTripTest
NewWebhookRoundTripTest creates a new WebhookRoundTripTest. signers maps each delivery URL to the operations.Signer used to sign payloads for that endpoint; a nil or missing entry means the request is sent unsigned.