testwebapp

package
v0.0.0-...-1592e7a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

README

Package cloudeng.io/webapp/testwebapp

import cloudeng.io/webapp/testwebapp

Variables

ErrNavigateUnexpectedError, ErrNavigateElementNotFound
ErrNavigateUnexpectedError = errors.New("click unexpected error")
ErrNavigateElementNotFound = errors.New("click element not found")

ErrGoGetUnexpectedError, ErrGoGetPathNotFound, ErrGoGetNotFound, ErrGoGetContentMismatch
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")

ErrRedirectUnexpectedError, ErrRedirectPathNotFound, ErrRedirectTargetMismatch, ErrRedirectStatusCodeMismatch
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")

ErrCheckStatusUnexpectedError, ErrCheckStatusCodeMismatch
ErrCheckStatusUnexpectedError = errors.New("check status unexpected error")
ErrCheckStatusCodeMismatch = errors.New("check status code mismatch")

ErrTLSSpecUnexpectedError, ErrTLSInvalidSerialNumbers, ErrTLSInvalidValidFor, ErrTLSInvalidIssuer
ErrTLSSpecUnexpectedError = errors.New("tls unexpected error")
ErrTLSInvalidSerialNumbers = errors.New("tls invalid serial numbers")
ErrTLSInvalidValidFor = errors.New("tls invalid duration")
ErrTLSInvalidIssuer = errors.New("tls invalid issuer")

Functions

Func ClientMaxRedirects
func ClientMaxRedirects(client *http.Client, maxRedirects int) *http.Client

ClientMaxRedirects returns a copy of the given client that follows up to maxRedirects redirects.

Func ClientNoRedirect
func ClientNoRedirect(client *http.Client) *http.Client

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.

Functions
func NewCheckStatus(specs ...CheckStatusSpec) *CheckStatus

NewCheckStatus creates a new CheckStatus for the given specs.

Methods
func (c *CheckStatus) Run(ctx context.Context, client *http.Client) error
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.

Functions
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.

Methods
func (s CheckStatusSpec) String() string

String implements fmt.Stringer, returning the YAML representation of the spec.

Type CipherSuites
type CipherSuites []uint16

CipherSuites is a list of TLS cipher suite names, e.g. "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" as returned by tls.CipherSuiteName. When unmarshaled from YAML it accepts a list of such names and converts them to the corresponding crypto/tls constants.

Methods
func (c CipherSuites) MarshalYAML() (any, error)

MarshalYAML implements yaml.Marshaler.

func (c *CipherSuites) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

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.

Functions
func NewGoGetTest(specs ...goget.Spec) *GoGetTest
Methods
func (g GoGetTest) Run(ctx context.Context, client *http.Client) error
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"`
}
Methods
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.

Functions
func NewHealthzTest(specs ...HealthzSpec) *HealthzTest
Methods
func (h HealthzTest) Run(ctx context.Context, client *http.Client) error
Type MetricsReporter
type MetricsReporter func(ctx context.Context, client *http.Client, url string, expectedMetrics []string) (found, missing []string, err error)
Type MetricsSpec
type MetricsSpec struct {
	URL         string   `yaml:"url,omitempty"`
	MetricNames []string `yaml:"names,omitempty"`
}
Methods
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.

Functions
func NewMetricsTest(reporter MetricsReporter, specs ...MetricsSpec) *MetricsTest
Methods
func (m MetricsTest) Run(ctx context.Context, client *http.Client) error
Type NavigateOption
type NavigateOption func(*navigateTestOptions)

NavigateOption represents options to configure NavigationTest.

Functions
func WithContextOptions(opts ...chromedp.ContextOption) NavigateOption

WithContextOptions appends options to the chromedp context.

func WithElementTimeout(timeout time.Duration) NavigateOption

WithElementTimeout sets the timeout for waiting for each individual DOM element.

func WithExecAllocatorOptions(opts ...chromedp.ExecAllocatorOption) NavigateOption

WithExecAllocatorOptions appends options to the Chrome allocator.

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(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(timeout time.Duration) NavigateOption

WithTimeout sets the overall timeout for the click test execution (including startup and navigation).

func WithUserDataDir(dir string) NavigateOption

WithUserDataDir sets the user data directory for Chrome.

Type NavigationSpec
type NavigationSpec struct {
	URL               string         `yaml:"url"`
	Selectors         []string       `yaml:"selectors"`
	Action            SelectorAction `yaml:"action"`
	SequentialActions bool           `yaml:"sequential_actions"`
}

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).

Methods
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.

Functions
func NewNavigationTest(specs []NavigationSpec, opts ...NavigateOption) *NavigationTest

NewNavigationTest creates a new NavigationTest with the given specs and options.

Methods
func (c *NavigationTest) Run(ctx context.Context) error

Run executes the NavigationTest specifications. It runs the specs concurrently and uses chromedp via chromedputil to control the browser.

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.

Methods
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.

Functions
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.

Methods
func (r RedirectTest) Run(ctx context.Context, client *http.Client) error
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).

Constants
SelectorActionNone, SelectorActionClick, SelectorActionDoubleClick
// 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"

Methods
func (a SelectorAction) MarshalYAML() (any, error)
func (a *SelectorAction) UnmarshalYAML(value *yaml.Node) error
Type SignatureAlgorithms
type SignatureAlgorithms []x509.SignatureAlgorithm

SignatureAlgorithms is a list of x509 signature algorithm names, e.g. "SHA256-RSA" as returned by x509.SignatureAlgorithm.String(). When unmarshaled from YAML it accepts a list of such names and converts them to the corresponding crypto/x509 constants.

Methods
func (s SignatureAlgorithms) MarshalYAML() (any, error)

MarshalYAML implements yaml.Marshaler.

func (s *SignatureAlgorithms) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

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      uint16             `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                  CipherSuites        `yaml:"cipher-suites" doc:"names of the cipher suites that the server must support, e.g. TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256; see tls.CipherSuites for a list of supported cipher suites"`
	NotAllowedCipherSuites        CipherSuites        `yaml:"not-allowed-cipher-suites" doc:"names of the cipher suites that the server must not negotiate; see tls.CipherSuites for a list of supported cipher suites. Use 'insecure' to refer to all insecure suites."`
	SignatureAlgorithms           SignatureAlgorithms `yaml:"signature-algorithms" doc:"names of the signature algorithms that the certificate must use, e.g. SHA256-RSA; see tlsvalidate.WithAllowedSignatureAlgorithms. Use 'rsa', 'dsa', 'ecdsa', 'ed25519' or 'rsa-pss' to refer to all algorithms of that type."`
	NotAllowedSignatureAlgorithms SignatureAlgorithms `yaml:"not-allowed-signature-algorithms" doc:"names of the signature algorithms that the certificate must not use; see tlsvalidate.WithDeniedSignatureAlgorithms"`
	// contains filtered or unexported fields
}

TLSSpec represents a specification for a TLS test.

Functions
func LetsEncryptTLSSpec() TLSSpec
func WithCustomCAPEMFile(s []TLSSpec, pemFile string) []TLSSpec

WithCustomCAPEMFile sets the custom CA PEM file for all specs if not already set in each/any spec.

Methods
func (s TLSSpec) String() string

String implements fmt.Stringer, returning the YAML representation of the spec.

Type TLSTest
type TLSTest struct {
	// contains filtered or unexported fields
}

TLSTest can be used to validate TLS certificates for a set of hosts.

Functions
func NewTLSTest(specs ...TLSSpec) *TLSTest
Methods
func (t *TLSTest) Run(ctx context.Context) error
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.

Methods
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.

Functions
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.

Methods
func (w *WebhookRoundTripTest) Run(ctx context.Context, client *http.Client) error

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNavigateUnexpectedError = errors.New("click unexpected error")
	ErrNavigateElementNotFound = errors.New("click element not found")
)
View Source
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")
)
View Source
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")
)
View Source
var (
	ErrCheckStatusUnexpectedError = errors.New("check status unexpected error")
	ErrCheckStatusCodeMismatch    = errors.New("check status code mismatch")
)
View Source
var (
	ErrTLSSpecUnexpectedError  = errors.New("tls unexpected error")
	ErrTLSInvalidSerialNumbers = errors.New("tls invalid serial numbers")
	ErrTLSInvalidValidFor      = errors.New("tls invalid duration")
	ErrTLSInvalidIssuer        = errors.New("tls invalid issuer")
)

Functions

func ClientMaxRedirects

func ClientMaxRedirects(client *http.Client, maxRedirects int) *http.Client

ClientMaxRedirects returns a copy of the given client that follows up to maxRedirects redirects.

func ClientNoRedirect

func ClientNoRedirect(client *http.Client) *http.Client

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.

func (*CheckStatus) Run

func (c *CheckStatus) Run(ctx context.Context, client *http.Client) error

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

func NewGoGetTest(specs ...goget.Spec) *GoGetTest

func (GoGetTest) Run

func (g GoGetTest) Run(ctx context.Context, client *http.Client) error

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

func (HealthzTest) Run

func (h HealthzTest) Run(ctx context.Context, client *http.Client) error

type MetricsReporter

type MetricsReporter func(ctx context.Context, client *http.Client, url string, expectedMetrics []string) (found, missing []string, err error)

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

func (MetricsTest) Run

func (m MetricsTest) Run(ctx context.Context, client *http.Client) error
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 struct {
	URL               string         `yaml:"url"`
	Selectors         []string       `yaml:"selectors"`
	Action            SelectorAction `yaml:"action"`
	SequentialActions bool           `yaml:"sequential_actions"`
}

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 (s NavigationSpec) String() string

String implements fmt.Stringer, returning the YAML representation of the spec.

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.

func (c *NavigationTest) Run(ctx context.Context) error

Run executes the NavigationTest specifications. It runs the specs concurrently and uses chromedp via chromedputil to control the browser.

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.

func (RedirectTest) Run

func (r RedirectTest) Run(ctx context.Context, client *http.Client) error

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

func WithCustomCAPEMFile(s []TLSSpec, pemFile string) []TLSSpec

WithCustomCAPEMFile sets the custom CA PEM file for all specs if not already set in each/any spec.

func (TLSSpec) String

func (s TLSSpec) String() string

String implements fmt.Stringer, returning the YAML representation of the 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

func NewTLSTest(specs ...TLSSpec) *TLSTest

func (*TLSTest) Run

func (t *TLSTest) Run(ctx context.Context) error

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.

func (*WebhookRoundTripTest) Run

func (w *WebhookRoundTripTest) Run(ctx context.Context, client *http.Client) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL