Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CipherBinAPIClient ¶
CipherBinAPIClient is used with http.Client and MockClient to allow mocking of services
type Client ¶
type Client struct {
CipherBinAPIClient
APIBaseURL string
BrowserBaseURL string
}
Client makes network API calls to cipherb.in
func NewClient ¶
func NewClient(browserBaseURL, apiBaseURL string, client CipherBinAPIClient) (*Client, error)
NewClient is a constructor for the ApiClient and satifies the CipherBinAPIClient interface
func (*Client) GetMessage ¶
func (c *Client) GetMessage(url string) (*app.MessageResponse, error)
GetMessage simply takes a cipherb.in public URL string and returns the appropriate encrypted message
type ClosingBuffer ¶
ClosingBuffer embeds a bytes.Buffer, giving it a Read method required for a Response Body ReadCloser body
func MockBody ¶
func MockBody(b []byte) *ClosingBuffer
MockBody creates a mock body that can be added to a response
func (ClosingBuffer) Close ¶
func (cb ClosingBuffer) Close() (err error)
Close allows a ClosingBuffer to Close, implementing a net/http Response Body ReadCloser interface
type MockClient ¶
type MockClient struct {
Response []byte
Responses [][]byte
Requests []*http.Request
StatusCode int
}
MockClient is responsible for stubbing requests in tests. If the Response field is set, the mock client will respond to each request with the Response. If Responses is set, the mock client will match subsequent requests to subsequent responses, moving along the array of Responses once for each request
func MockResponse ¶
func MockResponse(body string) *MockClient
MockResponse creates a mock client that will return the given response on the body
func MockResponses ¶
func MockResponses(bodies ...string) *MockClient
MockResponses creates a mock client with a series of canned responses