Documentation ¶
Index ¶
- Constants
- func AreFuncsEqual(a interface{}, b interface{}) (bool, error)
- func AreStringSlicesEqual(a []string, b []string) bool
- func CloneStringSlice(inSlice []string) []string
- func ConformToJSONSchemaFile(schemaURL string) types.GomegaMatcher
- func GetPEMPublicKeyAlgorithm(PEMPublicKey string) (x509.PublicKeyAlgorithm, error)
- func GetProjectPath(d *deps.Dependencies) (string, error)
- func GetSourceFilename(d *deps.Dependencies) (string, error)
- func GetURLFromProjectPath(d *deps.Dependencies, projPath string) (string, error)
- func StringPtr(s string) *string
- func ValidateJSONSchema(d *deps.Dependencies, responseStr string, schemaPath string) error
- func ValidateResponse(d *deps.Dependencies, responseStr string) (*codechallenge.SignedMessage, x509.PublicKeyAlgorithm, error)
- func WrapFuncCallWithCounter(f func()) (func(), *int)
- type DummyFileInfo
- type ErrorSpec
- type FakeFileSystem
- type GenericStringMatcher
- type ReaderFunc
- type RegexpStringMatcher
- type StringMatcher
- type StringStringMatcher
Constants ¶
const (
JSONValidationSchemaPath = "testdata/valid_output_schema.json"
)
JSONValidationSchemaPath the path in the project to the valid response schema.
Variables ¶
This section is empty.
Functions ¶
func AreFuncsEqual ¶
AreFuncsEqual returns true only if a and b are both functions, and both point to the same function. Returns false and a non-nil error if either argument is not a function. Returns true and a non-nil error if both arguments are nil,
func AreStringSlicesEqual ¶
AreStringSlicesEqual determines if two string slices are equal. Equality distinguishes nil-ness, but not capacity
func CloneStringSlice ¶
CloneStringSlice create a non-shared copy of inSlice
func ConformToJSONSchemaFile ¶
func ConformToJSONSchemaFile(schemaURL string) types.GomegaMatcher
ConformToJSONSchemaFile returns a Gomega "custom matcher" to validate a JSON blob against a JSON schema
func GetPEMPublicKeyAlgorithm ¶
func GetPEMPublicKeyAlgorithm(PEMPublicKey string) (x509.PublicKeyAlgorithm, error)
GetPEMPublicKeyAlgorithm determines the PKI algorithm from a given public key string. (When the production code supports verification, this will be moved to a methods of the X509Encoded and PEMEncoded types)
func GetProjectPath ¶
func GetProjectPath(d *deps.Dependencies) (string, error)
GetProjectPath returns the root path of the project (at compile time.)
func GetSourceFilename ¶
func GetSourceFilename(d *deps.Dependencies) (string, error)
GetSourceFilename returns the filename of the caller's source code.
func GetURLFromProjectPath ¶
func GetURLFromProjectPath(d *deps.Dependencies, projPath string) (string, error)
GetURLFromProjectPath converts a project path to a file:/// URL.
func ValidateJSONSchema ¶
func ValidateJSONSchema(d *deps.Dependencies, responseStr string, schemaPath string) error
ValidateJSONSchema validates that a string containing JSON conforms to the specified schema.
func ValidateResponse ¶
func ValidateResponse(d *deps.Dependencies, responseStr string) (*codechallenge.SignedMessage, x509.PublicKeyAlgorithm, error)
ValidateResponse validates that the string provided conforms to the schema in the spec, has a valid PEM format public key, a valid base64 signature, and that the signature was produced by signing the message with the private key (corresponding to the included public key). It returns the parsed JSON response, the signing algorithm and any errors encountered.
func WrapFuncCallWithCounter ¶
func WrapFuncCallWithCounter(f func()) (func(), *int)
WrapFuncCallWithCounter wraps the provided function, adding a returned pointer to a call counter.
Types ¶
type DummyFileInfo ¶
DummyFileInfo a mock for a os.FileInfo interface.
func (*DummyFileInfo) IsDir ¶
func (dfi *DummyFileInfo) IsDir() bool
IsDir abbreviation for Mode().IsDir()
func (*DummyFileInfo) ModTime ¶
func (dfi *DummyFileInfo) ModTime() time.Time
ModTime modification time
func (*DummyFileInfo) Size ¶
func (dfi *DummyFileInfo) Size() int64
Size length in bytes for regular files; system-dependent for others
func (*DummyFileInfo) Sys ¶
func (dfi *DummyFileInfo) Sys() interface{}
Sys underlying data source (can return nil)
type ErrorSpec ¶
ErrorSpec defines the expected value of an error.
func NewErrorSpecFrom ¶
NewErrorSpecFrom returns a *ErrorSpec that matches inErr.
func (*ErrorSpec) EnsureMatches ¶
EnsureMatches returns an error is inErr doesn't match.
type FakeFileSystem ¶
FakeFileSystem is a representation of the filesystem:
- all empty leaf directories are represented by a nil
- all files are represented by a pointer to a string of its contents
func (FakeFileSystem) Clone ¶
func (ffs FakeFileSystem) Clone() FakeFileSystem
Clone makes a deep clone of the FakeFileSystem.
func (FakeFileSystem) IsEqualTo ¶
func (ffs FakeFileSystem) IsEqualTo(other FakeFileSystem) bool
IsEqualTo does a deep comparison of two FakeFileSystems
func (FakeFileSystem) String ¶
func (ffs FakeFileSystem) String() string
String returns a string representation of the FakeFileSystem.
type GenericStringMatcher ¶
GenericStringMatcher is generic matcher for a string validation function.
func GetResponseMatcherForMessageAndAlgorithm ¶
func GetResponseMatcherForMessageAndAlgorithm(d *deps.Dependencies, msg string, algorithm x509.PublicKeyAlgorithm) GenericStringMatcher
GetResponseMatcherForMessageAndAlgorithm returns a string matcher for a valid response with a specific message and algorithm
func GetResponseMatcherForMessageAndPubKey ¶
func GetResponseMatcherForMessageAndPubKey(d *deps.Dependencies, msg string, pubKey string) GenericStringMatcher
GetResponseMatcherForMessageAndPubKey returns a string matcher for a valid response with a specific message and public key
func (GenericStringMatcher) MatchString ¶
func (gsm GenericStringMatcher) MatchString(s string) error
MatchString returns whether the strings match.
func (GenericStringMatcher) String ¶
func (gsm GenericStringMatcher) String() string
String returns a generic printable representation
type ReaderFunc ¶
ReaderFunc is a func that implements the io.Reader interface.
type RegexpStringMatcher ¶
type RegexpStringMatcher struct {
// contains filtered or unexported fields
}
RegexpStringMatcher is a thin wrapper over regexp.Regexp to alter its String() result.
func NewRegexpStringMatcher ¶
func NewRegexpStringMatcher(pattern string) *RegexpStringMatcher
NewRegexpStringMatcher returns a RegexpStringMatcher from the pattern.
func (*RegexpStringMatcher) MatchString ¶
func (rsm *RegexpStringMatcher) MatchString(s string) error
MatchString returns whether the strings match the pattern.
func (*RegexpStringMatcher) String ¶
func (rsm *RegexpStringMatcher) String() string
String returns a printable representation of the regular expression
type StringMatcher ¶
StringMatcher is an interface for comparing strings.
type StringStringMatcher ¶
type StringStringMatcher struct {
// contains filtered or unexported fields
}
StringStringMatcher returns StringMatcher only matching itself.
func NewStringStringMatcher ¶
func NewStringStringMatcher(s string) *StringStringMatcher
NewStringStringMatcher returns a new StringStringMatcher from the string s.
func (*StringStringMatcher) MatchString ¶
func (ssm *StringStringMatcher) MatchString(s string) error
MatchString returns whether the strings are equal
func (*StringStringMatcher) String ¶
func (ssm *StringStringMatcher) String() string
String returns a printable representation of the string