Documentation
¶
Overview ¶
Package devtest provides utilities for the development and testing of web applications, including TLS certificate generation and management.
Index ¶
- func CertPoolForTesting(pemFiles ...string) (*x509.CertPool, error)
- func NewSelfSignedCert(certFile, keyFile string, options ...SelfSignedOption) error
- func NewSelfSignedCertUsingMkcert(certFile, keyFile string, hosts ...string) error
- type JSServer
- type SelfSignedOption
- type TypescriptOption
- type TypescriptSources
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CertPoolForTesting ¶
CertPoolForTesting returns a new x509.CertPool containing the certs in the specified pem files. If no pem files are specified nil it will return the system cert pool. It is intended for testing purposes only.
func NewSelfSignedCert ¶
func NewSelfSignedCert(certFile, keyFile string, options ...SelfSignedOption) error
NewSelfSignedCert creates a self signed certificate. Default values for the supported options are:
- an rsa 4096 bit private key will be generated and used.
- "localhost" and "127.0.0.1" are used for the DNS and IP addresses included in the certificate.
- certificates are valid from time.Now() and for 5 days.
- the organization is 'cloudeng llc'.
func NewSelfSignedCertUsingMkcert ¶
NewSelfSignedCertUsingMkcert uses mkcert (https://github.com/FiloSottile/mkcert) to create certificates. If mkcert --install has been run then these certificates will be trusted by the browser and other local applications.
Types ¶
type JSServer ¶
type JSServer struct {
// contains filtered or unexported fields
}
JSServer provides a http.Handler for serving JavaScript files using a simple template that executes each file in turn. An optional TypescriptSources can be provided to compile TypeScript files before generating the http response.
func NewJSServer ¶
func NewJSServer(title string, ts *TypescriptSources, jsScripts ...string) *JSServer
type SelfSignedOption ¶
type SelfSignedOption func(ssc *selfSignedCertOptions)
SelfSignedOption represents an option to NewSelfSignedCert.
func CertAllIPAddresses ¶
func CertAllIPAddresses() SelfSignedOption
CertIPAddresses specifies that all local IPs be used in the generated certificate.
func CertDNSHosts ¶
func CertDNSHosts(hosts ...string) SelfSignedOption
CertDNSHosts specifies the set of dns host names to use in the generated certificate.
func CertIPAddresses ¶
func CertIPAddresses(ips ...string) SelfSignedOption
CertIPAddresses specifies the set of ip addresses to use in the generated certificate.
func CertOrganizations ¶
func CertOrganizations(orgs ...string) SelfSignedOption
CertOrganizations specifies that the organization to be used in the generated certificate.
func CertPrivateKey ¶
func CertPrivateKey(key crypto.PrivateKey) SelfSignedOption
CertPrivateKey specifies the private key to use for the certificate.
type TypescriptOption ¶
type TypescriptOption func(o *typescriptOptions)
TypescriptOption represents an option to NewTypescriptSources.
func WithTypescriptCompiler ¶
func WithTypescriptCompiler(compiler string) TypescriptOption
WithTypescriptCompiler sets the TypeScript compiler to use. The default is "tsc".
func WithTypescriptTarget ¶
func WithTypescriptTarget(target string) TypescriptOption
WithTypescriptTarget sets the target version for the TypeScript compiler. The default is "es2015".
type TypescriptSources ¶
type TypescriptSources struct {
// contains filtered or unexported fields
}
TypescriptSources represents a collection of TypeScript source files that can be compiled using the TypeScript compiler.
func NewTypescriptSources ¶
func NewTypescriptSources(opts ...TypescriptOption) *TypescriptSources
NewTypescriptSources creates a new instance of TypescriptSources
func (*TypescriptSources) Compile ¶
func (ts *TypescriptSources) Compile(ctx context.Context) error
Compile compiles the TypeScript sources that have been modified since it was last run.
func (*TypescriptSources) SetDirAndFiles ¶
func (ts *TypescriptSources) SetDirAndFiles(dir string, files ...string)
SetFiles sets the directory and files for the TypeScript sources. The output will be in the same directory, 'dir', as the input files.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package chromedputil provides utility functions for working with the Chrome DevTools Protocol via github.com/chromedp.
|
Package chromedputil provides utility functions for working with the Chrome DevTools Protocol via github.com/chromedp. |