testhelpers

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 12 Imported by: 0

README

testhelpers

This package contains various testing helper functions.

Documentation

Overview

Package testhelpers contains various testing helper functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustExtractECPublicKey

func MustExtractECPublicKey(t *testing.T, keyPEM string) *ecdsa.PublicKey

MustExtractECPublicKey successfully parses a PEM-encoded EC private key and extracts the public key from it or fails the test.

func MustExtractRSAPublicKey

func MustExtractRSAPublicKey(t *testing.T, keyPEM string) *rsa.PublicKey

MustExtractRSAPublicKey successfully parses a PEM-encoded RSA private key and extracts the public key from it or fails the test.

func MustGetCSRFromFile

func MustGetCSRFromFile(t *testing.T, filename string) *x509.CertificateRequest

MustGetCSRFromFile successfully retrieves a CSR from a PEM-encoded file or fails the test.

func MustGetCertFromFile

func MustGetCertFromFile(t *testing.T, filename string) *x509.Certificate

MustGetCertFromFile successfully retrieves a certificate from a PEM-encoded file or fails the test.

func MustGetConfigFromEnv

func MustGetConfigFromEnv(v string) string

MustGetConfigFromEnv retrieves a value from the named environment variable, or exits if the environment variable is not set.

func MustGetPrivateKeyFromFile

func MustGetPrivateKeyFromFile(t *testing.T, filename string) interface{}

MustGetPrivateKeyFromFile successfully retrieves a private key from a PEM-encoded file or fails the test.

func MustGetPrivateKeyFromFileWithPassword

func MustGetPrivateKeyFromFileWithPassword(t *testing.T, filename, password string) interface{}

MustGetPrivateKeyFromFileWithPassword successfully retrieves an encrypted private key from a PEM-encoded file or fails the test.

func MustGetPublicKeyFromFile

func MustGetPublicKeyFromFile(t *testing.T, filename string) interface{}

MustGetPublicKeyFromFile successfully retrieves a public key from a PEM-encoded file or fails the test.

func MustMakeRandomIdentifier

func MustMakeRandomIdentifier(t *testing.T, n int) string

MustMakeRandomIdentifier returns a random alphabetic identifier of length n, or fails the test.

func MustParseCSR

func MustParseCSR(t *testing.T, reqPEM string) *x509.CertificateRequest

MustParseCSR successfully parses a PEM-encoded PKCS#10 certificate signing request or fails the test.

func MustParseCert

func MustParseCert(t *testing.T, certPEM string) *x509.Certificate

MustParseCert successfully parses a PEM-encoded X509 certificate or fails the test.

func MustParseECPrivateKey

func MustParseECPrivateKey(t *testing.T, keyPEM string) *ecdsa.PrivateKey

MustParseECPrivateKey successfully parses a PEM-encoded EC private key or fails the test.

func MustParseRSAPrivateKey

func MustParseRSAPrivateKey(t *testing.T, keyPEM string) *rsa.PrivateKey

MustParseRSAPrivateKey successfully parses a PEM-encoded RSA private key or fails the test.

func MustParseURI

func MustParseURI(t *testing.T, s string) *url.URL

MustParseURI successfully converts a string to a *url.URL or fails the test.

func MustReadFile

func MustReadFile(t *testing.T, filename string) []byte

MustReadFile reads the contents of a file or fails the test.

Types

This section is empty.

Jump to

Keyboard shortcuts

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