awstesting

package
v1.41.3 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

README

AWS SDK for Go awstesting packages

awstesting is a collection of packages used internally by the SDK, and is subject to have breaking changes. This package is not internal so that if you really need to use its functionality, and understand breaking changes will be made, you are able to.

These packages will be refactored in the future so that the API generator and model parsers are exposed cleanly on their own.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ClientTLSCert 01-client.pem
	ClientTLSCert = []byte(`-----BEGIN CERTIFICATE-----
MIIEjjCCAnYCAQEwDQYJKoZIhvcNAQEFBQAwDTELMAkGA1UEBhMCVVMwHhcNMjAx
MTI0MDAyODI5WhcNMzAxMTIyMDAyODI5WjANMQswCQYDVQQGEwJVUzCCAiIwDQYJ
KoZIhvcNAQEBBQADggIPADCCAgoCggIBAN8gy1UtBR73fCJ9JWIREfBtqW/+hfNn
ZyIu7bc4MTWoP1dYG3CVV+HALijfVNeFQaohXjWaUIaXAa4idtM1AAf+J8GADqHp
z4qnAoIWLqfWRwtFJyggB2tnzmFA/yxR2jlpe3yT/OL0aXtYgS9bVeH6nWWjNuAo
D6qlTGSB/7ns8iDUK0WRJsodRGPi8OHNm4q5Pxqbzfvzu2vmF66NcvNb/96yIngl
Sjv6CSTz16hbbmqQQJAXurjkOLbSFCYZ76D2pYmqS/hLpUlFH/Bd/BcVP/3H5INA
fodY9Rx1oXETNuC69QgLA+2zlhGmbICh+OexIqNb2RH6vwi7EV5/Y4v7CKwzypre
OgOtkYQiDjhG3CxB+8E4q5t43SKpft7KFUXWmTaxOxZr7gmuBZGV5Lxzg+NgnFnV
tkPCVxKYsSSdhs11z0Ne/BBsGXCw0YoJ7HacFuVCf//C/vqT7y2ivhao3oMlv3ae
HjfHi9WIsZbDBB37Kk4UFXlXO0WXijrH09wILDW3IQ65fYMUBIyKFt9hKGjWKfcg
BWuTgJ98eG+BmxP6PIWgZTo1XdWKcxPblidLkwU4OzzuHONSsoGL8ee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KCV6IAEcvNyOXMPo=
-----END CERTIFICATE-----
`)

	// TLSBundleKey ai.key
	TLSBundleKey = []byte(`-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQDdYVh3oqKP5wEr2648AkM1wolohMxpMN+dzcbAAeePzagy9y1z
QE7YkibvJCQa5gIddiBS7Vixl4xo42JR20FpzkemsL3nl50GbpCckVoe5v0JbfR6
NAoGRNVPvN9mnORllZXTcVtS8+CPlvf3oc6nvCPNEUunixCn1BVxolvvUQIDAQAB
AoGBAMISrcirddGrlLZLLrKC1ULS2T0cdkqdQtwHYn4+7S5+/z42vMx1iumHLsSk
rVY7X41OWkX4trFxhvEIrc/O48bo2zw78P7flTxHy14uxXnllU8cLThE29SlUU7j
AVBNxJZMsXMlS/DowwD4CjFe+x4Pu9wZcReF2Z9ntzMpySABAkEA+iWoJCPE2JpS
y78q3HYYgpNY3gF3JqQ0SI/zTNkb3YyEIUffEYq0Y9pK13HjKtdsSuX4osTIhQkS
+UgRp6tCAQJBAOKPYTfQ2FX8ijgUpHZRuEAVaxASAS0UATiLgzXxLvOh/VC2at5x
wjOX6sD65pPz/0D8Qj52Cq6Q1TQ+377SDVECQAIy0od+yPweXxvrUjUd1JlRMjbB
TIrKZqs8mKbUQapw0bh5KTy+O1elU4MRPS3jNtBxtP25PQnuSnxmZcFTgAECQFzg
DiiFcsn9FuRagfkHExMiNJuH5feGxeFaP9WzI144v9GAllrOI6Bm3JNzx2ZLlg4b
20Qju8lIEj6yr6JYFaECQHM1VSojGRKpOl9Ox/R4yYSA9RV5Gyn00/aJNxVYyPD5
i3acL2joQm2kLD/LO8paJ4+iQdRXCOMMIpjxSNjGQjQ=
-----END RSA PRIVATE KEY-----
`)
)
  • Create the CA Cert
  • Create certificate signing request
  • Create a signed certificate
Cert generation steps

# Create the CA key openssl genrsa -des3 -out ca.key 1024

Create the CA Cert

openssl req -new -sha256 -x509 -days 3650 \
    -subj "/C=GO/ST=Gopher/O=Testing ROOT CA" \
    -key ca.key -out ca.crt

# Create config cat > csr_details.txt <<-EOF

[req] default_bits = 1024 prompt = no default_md = sha256 req_extensions = SAN distinguished_name = dn

[ dn ] C=GO ST=Gopher O=Testing Certificate OU=Testing IP

[SAN] subjectAltName = IP:127.0.0.1 EOF

Create certificate signing request

openssl req -new -sha256 -nodes -newkey rsa:1024 \
    -config <( cat csr_details.txt ) \
    -keyout ia.key -out ia.csr

Create a signed certificate

openssl x509 -req -days 3650 \
    -CAcreateserial \
    -extfile <( cat csr_details.txt ) \
    -extensions SAN \
    -CA ca.crt -CAkey ca.key -in ia.csr -out ia.crt

# Verify openssl req -noout -text -in ia.csr openssl x509 -noout -text -in ia.crt

Functions

func AssertJSON

func AssertJSON(t *testing.T, expect, actual string, msgAndArgs ...interface{}) bool

AssertJSON verifies that the expect json string matches the actual.

func AssertQuery

func AssertQuery(t *testing.T, expect, actual string, msgAndArgs ...interface{}) bool

AssertQuery verifies the expect HTTP query string matches the actual.

func AssertURL

func AssertURL(t *testing.T, expect, actual string, msgAndArgs ...interface{}) bool

AssertURL verifies the expected URL is matches the actual.

func AssertXML

func AssertXML(t *testing.T, expect, actual string, msgAndArgs ...interface{}) bool

AssertXML verifies that the expect XML string matches the actual.

func CleanupTLSBundleFiles

func CleanupTLSBundleFiles(files ...string) error

CleanupTLSBundleFiles takes variadic list of files to be deleted.

func CreateClientTLSCertFiles

func CreateClientTLSCertFiles() (cert, key string, err error)

CreateClientTLSCertFiles returns a set of temporary files for the client certificate and key files.

func CreateTLSBundleFiles

func CreateTLSBundleFiles() (cert, key, ca string, err error)

CreateTLSBundleFiles returns the temporary filenames for the certificate key, and CA PEM content. These files should be deleted when no longer needed. CleanupTLSBundleFiles can be used for this cleanup.

func CreateTLSServer

func CreateTLSServer(cert, key string, mux *http.ServeMux) (string, error)

CreateTLSServer will create the TLS server on an open port using the certificate and key. The address will be returned that the server is running on.

func DidPanic

func DidPanic(fn func()) (bool, interface{})

DidPanic returns if the function paniced and returns true if the function paniced.

func Match

func Match(t *testing.T, regex, expected string)

Match is a testing helper to test for testing error by comparing expected with a regular expression.

func NewClient

func NewClient(cfgs ...*aws.Config) *client.Client

NewClient creates and initializes a generic service client for testing.

func NewTLSClientCertServer

func NewTLSClientCertServer(handler http.Handler) (*httptest.Server, error)

NewTLSClientCertServer creates a new HTTP test server initialize to require HTTP clients authenticate with TLS client certificates.

func PopEnv deprecated

func PopEnv(env []string)

PopEnv takes the list of the environment values and injects them into the process's environment variable data. Clears any existing environment values that may already exist.

Deprecated: PopEnv exists for backward compatibility and may be removed from the future iterations. It is not `internal` so that if you really need to use its functionality, and understand breaking changes will be made, you are able to.

func SortedKeys

func SortedKeys(m map[string]interface{}) []string

SortedKeys returns a sorted slice of keys of a map.

func SprintExpectActual

func SprintExpectActual(expect, actual interface{}) string

SprintExpectActual returns a string for test failure cases when the actual value is not the same as the expected.

func StashEnv deprecated

func StashEnv() []string

StashEnv stashes the current environment variables and returns an array of all environment values as key=val strings.

Deprecated: StashEnv exists for backward compatibility and may be removed from the future iterations. It is not `internal` so that if you really need to use its functionality, and understand breaking changes will be made, you are able to.

Types

type DiscardAt

type DiscardAt struct{}

DiscardAt is an io.WriteAt that discards the requested bytes to be written

func (DiscardAt) WriteAt

func (d DiscardAt) WriteAt(p []byte, off int64) (n int, err error)

WriteAt discards the given []byte slice and returns len(p) bytes as having been written at the given offset. It will never return an error.

type EndlessReader

type EndlessReader struct{}

EndlessReader is an io.Reader that will always return that bytes have been read.

func (EndlessReader) Read

func (e EndlessReader) Read(p []byte) (int, error)

Read will report that it has read len(p) bytes in p. The content in the []byte will be unmodified. This will never return an error.

type FakeContext

type FakeContext struct {
	Error  error
	DoneCh chan struct{}
}

A FakeContext provides a simple stub implementation of a Context

func (*FakeContext) Deadline

func (c *FakeContext) Deadline() (deadline time.Time, ok bool)

Deadline always will return not set

func (*FakeContext) Done

func (c *FakeContext) Done() <-chan struct{}

Done returns a read channel for listening to the Done event

func (*FakeContext) Err

func (c *FakeContext) Err() error

Err returns the error, is nil if not set.

func (*FakeContext) Value

func (c *FakeContext) Value(key interface{}) interface{}

Value ignores the Value and always returns nil

type ReadCloser

type ReadCloser struct {
	Size   int
	Closed bool

	FillData func(bool, []byte, int, int)
	// contains filtered or unexported fields
}

ReadCloser is a io.ReadCloser for unit testing. Designed to test for leaks and whether a handle has been closed

func (*ReadCloser) Close

func (r *ReadCloser) Close() error

Close sets Closed to true and returns no error

func (*ReadCloser) Read

func (r *ReadCloser) Read(b []byte) (int, error)

Read will call FillData and fill it with whatever data needed. Decrements the size until zero, then return io.EOF.

type ZeroReader

type ZeroReader struct{}

ZeroReader is a io.Reader which will always write zeros to the byte slice provided.

func (*ZeroReader) Read

func (r *ZeroReader) Read(b []byte) (int, error)

Read fills the provided byte slice with zeros returning the number of bytes written.

Directories

Path Synopsis
Package unit performs initialization and validation for unit tests
Package unit performs initialization and validation for unit tests

Jump to

Keyboard shortcuts

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