testing

package
v0.0.0-...-57974ef Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var B3Certs = func() []*x509.Certificate {
	certPem, _ := ioutil.ReadFile("../../testdata/b3/fullchain.cert")
	certs, _ := signedexchange.ParseCertificates(certPem)
	return certs
}()

90 days cert of amppackageexample.com and www.amppackageexample.com in SAN

View Source
var B3Certs2 = func() []*x509.Certificate {
	certPem, _ := ioutil.ReadFile("../../testdata/b3/fullchain2.cert")
	certs, _ := signedexchange.ParseCertificates(certPem)
	return certs
}()

90 days cert of amppackageexample2.com and www.amppackageexample2.com in SAN

View Source
var B3Certs91Days = func() []*x509.Certificate {
	certPem, _ := ioutil.ReadFile("../../testdata/b3/fullchain_91days.cert")
	certs, _ := signedexchange.ParseCertificates(certPem)
	return certs
}()

91 days cert from B3Key

View Source
var B3Key = func() crypto.PrivateKey {
	keyPem, _ := ioutil.ReadFile("../../testdata/b3/server.privkey")
	key, _ := util.ParsePrivateKey(keyPem)
	return key
}()

Private key of B3Certs

View Source
var B3Key2 = func() crypto.PrivateKey {
	keyPem, _ := ioutil.ReadFile("../../testdata/b3/server2.privkey")
	key, _ := util.ParsePrivateKey(keyPem)
	return key
}()

Private key of B3Certs2

View Source
var B3KeyP521 = func() crypto.PrivateKey {
	keyPem, _ := ioutil.ReadFile("../../testdata/b3/server_p521.privkey")
	key, _ := util.ParsePrivateKey(keyPem)
	return key
}()

secp521r1 private key

View Source
var CACert = func() *x509.Certificate {
	certPem, _ := ioutil.ReadFile("../../testdata/b3/ca.cert")
	certs, _ := signedexchange.ParseCertificates(certPem)
	return certs[0]
}()

Cert for a fake CA

View Source
var CAKey = func() *rsa.PrivateKey {
	keyPem, _ := ioutil.ReadFile("../../testdata/b3/ca.privkey")
	for {
		var pemBlock *pem.Block
		pemBlock, keyPem := pem.Decode(keyPem)
		if pemBlock == nil {
			panic("Error parsing PEM block in ca.privkey.")
		}

		if key, err := x509.ParsePKCS1PrivateKey(pemBlock.Bytes); err == nil {
			return key
		}
		if len(keyPem) == 0 {
			panic("Failed to parse ca.privkey; no matching PEM blocks.")
		}

	}
}()

RSA private key for a fake CA

View Source
var CertName = util.CertName(Certs[0])

The URL path component corresponding to the cert's sha-256.

View Source
var Certs = func() []*x509.Certificate {
	certPem, _ := ioutil.ReadFile("../../testdata/b3/fullchain.cert")
	certs, _ := signedexchange.ParseCertificates(certPem)
	return certs
}()

A cert (with its issuer chain) for testing.

View Source
var Key = func() crypto.PrivateKey {
	keyPem, _ := ioutil.ReadFile("../../testdata/b3/server.privkey")

	key, _ := util.ParsePrivateKey(keyPem)
	return key
}()

Its corresponding private key.

Functions

This section is empty.

Types

type FakeClock

type FakeClock struct {
	SecondsSince0 time.Duration
	Delta         time.Duration
}

func NewFakeClock

func NewFakeClock() *FakeClock

func (*FakeClock) Now

func (this *FakeClock) Now() time.Time

type Request

type Request struct {
	T       *testing.T
	Handler http.Handler
	Target  string
	Host    string
	Header  http.Header
	Body    io.Reader
}

Request encapsulates all the information needed to construct a test request for use by the unit tests.

func NewRequest

func NewRequest(t *testing.T, h http.Handler, target string) *Request

NewRequest returns a new test request.

func (*Request) Do

func (r *Request) Do() *http.Response

Get returns the completed test request object.

func (*Request) SetBody

func (r *Request) SetBody(body io.Reader) *Request

SetBody sets the body for the request. May be nil for an empty body.

func (*Request) SetHeaders

func (r *Request) SetHeaders(host string, header http.Header) *Request

SetHeaders sets the headers for the request. Host may be empty for the default.

Jump to

Keyboard shortcuts

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