Documentation
¶
Index ¶
- func CopyFile(t *testing.T, src, dest string)
- func FilesEqual(t *testing.T, expected, actual string)
- func GenerateSelfSignedCert(destCert, destKey io.Writer, hosts []string) error
- func IsUUID(t *testing.T, str string)
- func JSONResponse(t *testing.T, code int, body any) *http.Response
- func MustCommand(t *testing.T, command string, args ...string)
- func NewRandomPort(t *testing.T) string
- func NewTestClient(fn RoundTripFunc) *http.Client
- func RequireGID(t *testing.T, path string, group int)
- func RequireGroup(t *testing.T, path string, groupName string)
- func RequireJSONValue(t *testing.T, input, key string, value any)
- func RequireOwner(t *testing.T, path string, username string)
- func RequirePerms(t *testing.T, path string, perms fs.FileMode)
- func RequireUID(t *testing.T, path string, owner int)
- func SetEnvs(t *testing.T, envs map[string]string) func(t *testing.T)
- func Walk(t *testing.T, root string) []string
- type CertificateAuthority
- type RoundTripFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFile ¶ added in v0.0.11
CopyFile copies src to dest atomically by creating an intermediate temporary file and then doing an atomic rename.
func FilesEqual ¶ added in v0.0.6
FilesEqual compares the contents of two files to see if they're equal. If not, a unified diff is displayed showing the differences.
func GenerateSelfSignedCert ¶ added in v0.0.3
GenerateSelfSignedCert generates a self-signed RSA certificate for testing purposes.
func JSONResponse ¶ added in v0.0.4
JSONResponse sets up a basic http.Response with an object in the body of the response.
func MustCommand ¶ added in v0.0.8
MustCommand executes the command and requires a clean exit code.
func NewRandomPort ¶ added in v0.0.2
NewRandomPort identifies a port on the localhost interface for use during tests and returns the string in interface:port format. It uses similar methodology to how the net/http/httptest server chooses a port.
func NewTestClient ¶ added in v0.0.4
func NewTestClient(fn RoundTripFunc) *http.Client
NewTestClient returns *http.Client with Transport replaced to avoid making real calls.
func RequireJSONValue ¶ added in v0.0.13
RequireJSONValue takes a JSON string as input, then checks that the key matches the value.
func RequirePerms ¶ added in v0.0.10
Types ¶
type CertificateAuthority ¶ added in v0.0.7
type CertificateAuthority struct { Cert *x509.Certificate PrivKey *rsa.PrivateKey PEMCert []byte PEMKey []byte }
CertificateAuthority is a test CA that is capable of signing certs for use during testing.
func LoadCertificateAuthority ¶ added in v0.0.15
func LoadCertificateAuthority(cert, key io.Reader) (*CertificateAuthority, error)
LoadCertificateAuthority loads a CA from two io.Readers.
func LoadCertificateAuthorityFiles ¶ added in v0.0.15
func LoadCertificateAuthorityFiles(cert, key string) (*CertificateAuthority, error)
LoadCertificateAuthorityFiles loads a CA from a cert and key on disk.
func NewCertificateAuthority ¶ added in v0.0.7
func NewCertificateAuthority() (*CertificateAuthority, error)
NewCertificateAuthority initializes a CertificateAuthority.
func (*CertificateAuthority) MakeCert ¶ added in v0.0.7
func (c *CertificateAuthority) MakeCert(destCert, destKey io.Writer, hosts ...string) error
MakeCert is a helper method that will generate a cert using the hosts and/or ips in the hosts array.
func (*CertificateAuthority) SignCert ¶ added in v0.0.7
func (c *CertificateAuthority) SignCert(template *x509.Certificate, destCert, destKey io.Writer) error
SignCert will sign a certificate with the CA. This method gives you more control of the cert than the MakeCert method does.
type RoundTripFunc ¶ added in v0.0.4
RoundTripFunc is a function that will be called to fulfill and http request.