package awstesting
import "github.com/aws/aws-sdk-go-v2/internal/awstesting"
Index ¶
- Variables
- func AssertJSON(t *testing.T, expect, actual string, msgAndArgs ...interface{}) bool
- func AssertQuery(t *testing.T, expect, actual string, msgAndArgs ...interface{}) bool
- func AssertURL(t *testing.T, expect, actual string, msgAndArgs ...interface{}) bool
- func AssertXML(t *testing.T, expect, actual string, container interface{}, msgAndArgs ...interface{}) bool
- func CleanupTLSBundleFiles(files ...string) error
- func CreateClientTLSCertFiles() (cert, key string, err error)
- func CreateTLSBundleFiles() (cert, key, ca string, err error)
- func CreateTLSServer(cert, key string, mux *http.ServeMux) (string, error)
- func DidPanic(fn func()) (bool, interface{})
- func Match(t *testing.T, regex, expected string)
- func NewTLSClientCertServer(handler http.Handler) (*httptest.Server, error)
- func PopEnv(env []string)
- func SprintExpectActual(expect, actual interface{}) string
- func StashEnv(envToKeep ...string) []string
- type DiscardAt
- type EndlessReader
- type FakeContext
- func (c *FakeContext) Deadline() (deadline time.Time, ok bool)
- func (c *FakeContext) Done() <-chan struct{}
- func (c *FakeContext) Err() error
- func (c *FakeContext) Value(key interface{}) interface{}
- type MockCredentialsProvider
- func (p MockCredentialsProvider) Invalidate()
- func (p MockCredentialsProvider) Retrieve(ctx context.Context) (aws.Credentials, error)
- type ReadCloser
- type SigV4Signature
- type ZeroReader
Variables ¶
var ( // TLSBundleCA is the CA PEM TLSBundleCA []byte // TLSBundleCert is the Server PEM TLSBundleCert []byte // TLSBundleKey is the Server private key PEM TLSBundleKey []byte // ClientTLSCert is the Client PEM ClientTLSCert []byte // ClientTLSKey is the Client private key PEM ClientTLSKey []byte )
Functions ¶
func AssertJSON ¶
AssertJSON verifies that the expect json string matches the actual.
func AssertQuery ¶
AssertQuery verifies the expect HTTP query string matches the actual.
func AssertURL ¶
AssertURL verifies the expected URL is matches the actual.
func AssertXML ¶
func AssertXML(t *testing.T, expect, actual string, container interface{}, msgAndArgs ...interface{}) bool
AssertXML verifies that the expect xml string matches the actual.
func CleanupTLSBundleFiles ¶
CleanupTLSBundleFiles takes variadic list of files to be deleted.
func CreateClientTLSCertFiles ¶
CreateClientTLSCertFiles returns a set of temporary files for the client certificate and key files.
func CreateTLSBundleFiles ¶
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 ¶
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 ¶
Match is a testing helper to test for testing error by comparing expected with a regular expression.
func NewTLSClientCertServer ¶
NewTLSClientCertServer creates a new HTTP test server initialize to require HTTP clients authenticate with TLS client certificates.
func PopEnv ¶
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.
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 ¶
StashEnv stashes the current environment variables except variables listed in envToKeepx Returns an function to pop out old environment
Types ¶
type DiscardAt ¶
type DiscardAt struct{}
DiscardAt is an io.WriteAt that discards the requested bytes to be written
func (DiscardAt) WriteAt ¶
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 MockCredentialsProvider ¶
type MockCredentialsProvider struct { RetrieveFn func(ctx context.Context) (aws.Credentials, error) InvalidateFn func() }
MockCredentialsProvider is a type that can be used to mock out credentials providers
func (MockCredentialsProvider) Invalidate ¶
func (p MockCredentialsProvider) Invalidate()
Invalidate calls the InvalidateFn
func (MockCredentialsProvider) Retrieve ¶
func (p MockCredentialsProvider) Retrieve(ctx context.Context) (aws.Credentials, error)
Retrieve calls the RetrieveFn
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 SigV4Signature ¶
type SigV4Signature struct { Preamble string // e.g. AWS4-HMAC-SHA256, AWS4-ECDSA-P256-SHA256 SigningName string // generally the service name e.g. "s3" SigningRegion string // for sigv4a this is the region-set header as-is SignedHeaders []string // list of signed headers Signature string // calculated signature }
SigV4Signature represents a parsed sigv4 or sigv4a signature.
func ParseSigV4Signature ¶
func ParseSigV4Signature(header http.Header) *SigV4Signature
ParseSigV4Signature deconstructs a sigv4 or sigv4a signature from a set of request headers.
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.
Source Files ¶
assert.go certificate_utils.go discard.go endless_reader.go util.go
Directories ¶
Path | Synopsis |
---|---|
internal/awstesting/unit | Package unit performs initialization and validation for unit tests |
- Version
- v1.36.3 (latest)
- Published
- Feb 27, 2025
- Platform
- linux/amd64
- Imports
- 27 packages
- Last checked
- 1 hour ago –
Tools for package owners.