Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActiveChannel ¶
type ActiveChannel struct {
*PassiveChannel
// contains filtered or unexported fields
}
func NewActiveChannel ¶
func NewActiveChannel(timeout time.Duration) *ActiveChannel
NewActiveChannel returns a channel which can receive and modify callback responses. The timeout controls how long Recv() and Send() can wait for callback data before failing.
Channels are useful when tests want to manipulate callbacks from within an `inner` function.
func (*ActiveChannel) Callback ¶
func (c *ActiveChannel) Callback() Fn
Callback returns the callback implementation used to send data to this channel.
type CallbackServer ¶
type CallbackServer struct {
// contains filtered or unexported fields
}
func NewCallbackServer ¶
func NewCallbackServer(t ct.TestLike, hostnameRunningComplement string) (*CallbackServer, error)
NewCallbackServer runs a local HTTP server that can read callbacks from mitmproxy. Automatically listens on a high numbered port. Must be Close()d at the end of the test. Register callback handlers via CallbackServer.SetOnRequestCallback and CallbackServer.SetOnResponseCallback
func (*CallbackServer) SetOnRequestCallback ¶
func (s *CallbackServer) SetOnRequestCallback(t ct.TestLike, cb Fn) (callbackURL string)
func (*CallbackServer) SetOnResponseCallback ¶
func (s *CallbackServer) SetOnResponseCallback(t ct.TestLike, cb Fn) (callbackURL string)
type Data ¶
type Data struct {
Method string `json:"method"`
URL string `json:"url"`
AccessToken string `json:"access_token"`
ResponseCode int `json:"response_code"`
ResponseBody json.RawMessage `json:"response_body"`
RequestBody json.RawMessage `json:"request_body"`
}
type PassiveChannel ¶
type PassiveChannel struct {
// contains filtered or unexported fields
}
func NewPassiveChannel ¶
func NewPassiveChannel(timeout time.Duration, blocking bool) *PassiveChannel
NewPassiveChannel returns a channel which can receive callback responses, but cannot modify them. This is useful for sniffing network traffic. The timeout controls how long Recv() can wait until there is callback data before failing. If blocking is true, callbacks will not return until Recv() is called. This can be useful for synchronising actions when a callback is invoked.
Channels are useful when tests want to manipulate callbacks from within an `inner` function.
func (*PassiveChannel) Callback ¶
func (c *PassiveChannel) Callback() Fn
Callback returns the callback implementation used to send data to this channel.
func (*PassiveChannel) Chan ¶
func (c *PassiveChannel) Chan() <-chan *Data
Chan returns a consume-only channel.
This exists as an escape hatch for when Recv/TryRecv are insufficient, and this channel needs to be used as part of a larger `select` block.
func (*PassiveChannel) Close ¶
func (c *PassiveChannel) Close()
type Response ¶
type Response struct {
// if set, changes the HTTP response status code for this request.
RespondStatusCode int `json:"respond_status_code,omitempty"`
// if set, changes the HTTP response body for this request.
RespondBody json.RawMessage `json:"respond_body,omitempty"`
}