package verify

import "github.com/google/martian/v3/verify"

Package verify provides support for using martian modifiers for request and response verifications.

Index

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is an http.Handler that returns the request and response verifications of reqv and resv as JSON.

func NewHandler

func NewHandler() *Handler

NewHandler returns an http.Handler for requesting the verification error status.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP writes out a JSON response containing a list of verification errors that occurred during the requests and responses sent to the proxy.

func (*Handler) SetRequestVerifier

func (h *Handler) SetRequestVerifier(reqv RequestVerifier)

SetRequestVerifier sets the RequestVerifier to verify.

func (*Handler) SetResponseVerifier

func (h *Handler) SetResponseVerifier(resv ResponseVerifier)

SetResponseVerifier sets the ResponseVerifier to verify.

type RequestResponseVerifier

type RequestResponseVerifier interface {
	RequestVerifier
	ResponseVerifier
}

RequestResponseVerifier is a RequestVerifier and a ResponseVerifier.

type RequestVerifier

type RequestVerifier interface {
	martian.RequestModifier
	VerifyRequests() error
	ResetRequestVerifications()
}

RequestVerifier is a RequestModifier that maintains a verification state. RequestVerifiers should only return an error from ModifyRequest for errors unrelated to the expectation.

type ResetHandler

type ResetHandler struct {
	// contains filtered or unexported fields
}

ResetHandler is an http.Handler that resets the request and response verifications of reqv and resv.

func NewResetHandler

func NewResetHandler() *ResetHandler

NewResetHandler returns an http.Handler for reseting the verification error status.

func (*ResetHandler) ServeHTTP

func (h *ResetHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP resets the verifier for the given ID so that it may be run again.

func (*ResetHandler) SetRequestVerifier

func (h *ResetHandler) SetRequestVerifier(reqv RequestVerifier)

SetRequestVerifier sets the RequestVerifier to reset.

func (*ResetHandler) SetResponseVerifier

func (h *ResetHandler) SetResponseVerifier(resv ResponseVerifier)

SetResponseVerifier sets the ResponseVerifier to reset.

type ResponseVerifier

type ResponseVerifier interface {
	martian.ResponseModifier
	VerifyResponses() error
	ResetResponseVerifications()
}

ResponseVerifier is a ResponseModifier that maintains a verification state. ResponseVerifiers should only return an error from ModifyResponse for errors unrelated to the expectation.

type TestVerifier

type TestVerifier struct {
	RequestError  error
	ResponseError error
}

TestVerifier is a request and response verifier with overridable errors for verification.

func (*TestVerifier) ModifyRequest

func (tv *TestVerifier) ModifyRequest(*http.Request) error

ModifyRequest is a no-op.

func (*TestVerifier) ModifyResponse

func (tv *TestVerifier) ModifyResponse(*http.Response) error

ModifyResponse is a no-op.

func (*TestVerifier) ResetRequestVerifications

func (tv *TestVerifier) ResetRequestVerifications()

ResetRequestVerifications clears out the set request error.

func (*TestVerifier) ResetResponseVerifications

func (tv *TestVerifier) ResetResponseVerifications()

ResetResponseVerifications clears out the set response error.

func (*TestVerifier) VerifyRequests

func (tv *TestVerifier) VerifyRequests() error

VerifyRequests returns the set request error.

func (*TestVerifier) VerifyResponses

func (tv *TestVerifier) VerifyResponses() error

VerifyResponses returns the set response error.

Source Files

verify.go verify_handlers.go

Version
v3.1.0
Published
Feb 24, 2020
Platform
windows/amd64
Imports
4 packages
Last checked
4 hours ago

Tools for package owners.