Documentation
¶
Index ¶
- type Config
- func (pc Config) CA() *x509.CertPool
- func (pc Config) CARootsURL(id int) string
- func (pc *Config) CreateCertsAndUpdateConfig(ctx context.Context, outputDir string) (string, error)
- func (pc Config) DirectoryURL() string
- func (pc Config) GetIssuingCA(ctx context.Context, id int) (*x509.CertPool, error)
- func (pc Config) GetIssuingCert(ctx context.Context, id int) ([]byte, error)
- func (pc Config) PossibleValidityPeriods() []time.Duration
- func (pc Config) ValidateCertificate(ctx context.Context, cert *x509.Certificate, intermediates *x509.CertPool) error
- type ConfigOption
- type ServerOption
- type ServerURL
- type T
- func (p *T) EnsureStopped(ctx context.Context, waitFor time.Duration) error
- func (p *T) PID() int
- func (p *T) Start(ctx context.Context, dir, cfg string, forward io.WriteCloser) error
- func (p *T) WaitForIssuedCertificateSerial(ctx context.Context) (string, error)
- func (p *T) WaitForOrderAuthorized(ctx context.Context) (string, error)
- func (p *T) WaitForReady(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Address string
ManagementAddress string
HTTPPort int
TLSPort int
Certificate []byte
CertificateFile string
CAFile string
TestCertBase string
RootCertURL string
// contains filtered or unexported fields
}
Config represents the configuration for a pebble instance that's relevant to using it for testing clients.
func NewConfig ¶
func NewConfig(opt ...ConfigOption) Config
NewConfig creates a new Config instance with default values.
func (Config) CA ¶
CA returns a CertPool containing the root pebble CA certificate. Use it when configuring clients to connect to the pebble instance.
func (Config) CARootsURL ¶
CARootsURL returns the URL from which the pebble root CA certificate can be retrieved, use 0 as the id.
func (*Config) CreateCertsAndUpdateConfig ¶
CreateCertsAndUpdateConfig uses minica to create a self-signed certificate for use with the pebble instance and applies any other config customizations requested by any ConfigOptions. The generated certificate and key are placed in outputDir. It returns the path to the possibly updated configuration file to be used when starting pebble. Use minica to create a self-signed certificate for the domain as per:
minica -ca-cert pebble.minica.pem \
-ca-key pebble.minica.key.pem \
-domains localhost,pebble \
-ip-addresses 127.0.0.1
func (Config) DirectoryURL ¶
DirectoryURL returns the ACME service 'directory' URL.
func (Config) GetIssuingCA ¶
IssuingCA returns a CertPool containing the issuing CA certificate used by pebble to sign issued certificates.
func (Config) GetIssuingCert ¶
GetIssuingCert retrieves the pebble certificate, including intermediates, used to sign issued certificates.
func (Config) PossibleValidityPeriods ¶
PossibleValidityPeriods returns the validity periods specified across all defined profiles in the pebble config.
func (Config) ValidateCertificate ¶
type ConfigOption ¶
type ConfigOption func(*configOption)
ConfigOption represents an option for configuring a new Config instance.
func WithAlternatePorts ¶
func WithAlternatePorts(managementPort, serverPort int) ConfigOption
WithAlternatePorts returns a ConfigOption that sets alternate ports for the pebble management and server ports.
func WithValidityPeriod ¶
func WithValidityPeriod(secs int) ConfigOption
WithValidityPeriod returns a ConfigOption that sets the validity period for all issued certificates by modifying the value in all pebble profiles.
type ServerOption ¶
type ServerOption func(*serverOptions)
ServerOption represents a option for configuring a new Pebble instance.
func WithNoSleep ¶
func WithNoSleep() ServerOption
WithNoSleep returns a ServerOption that disables sleeps in pebble to speed up testing.
type ServerURL ¶
type ServerURL string
ServerURL is the base URL of the Pebble management API (e.g. "https://localhost:15000"). Root and intermediate certs are fetched from the standard Pebble management API paths (/roots/0 and /intermediates/0).
func (ServerURL) IntermediateURL ¶
type T ¶
type T struct {
// contains filtered or unexported fields
}
T manages a pebble instance for testing purposes.
func New ¶
func New(binary string, opts ...ServerOption) *T
New creates a new Pebble instance. The supplied configFile will be used to configure the pebble instance. The server is not started by New.
func (*T) EnsureStopped ¶
EnsureStopped ensures that the pebble instance is stopped.
func (*T) WaitForIssuedCertificateSerial ¶
WaitForIssuedCertificateSerial waits until a certificate is issued and returns its serial number.
func (*T) WaitForOrderAuthorized ¶
WaitForOrderAuthorized waits until an order is authorized and returns its order ID.