Documentation ¶
Overview ¶
* Package mock provides an httptest.Server that allows mock interactions with the * Sectigo API for both unit tests of the Sectigo package and integration tests with GDS * Sectigo/Certificate operations. * * The basic use case is to create a *mock.Server using mock.New(). Requests to the * mock server endpoint (fetched using mock.Server.URL()) will return "happy path" * responses for a single fake certificate interaction. You can also modify the response * from the mock server by using mock.Handle or one of the handler methods.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handle ¶
func Handle(endpoint string, handler gin.HandlerFunc) error
Handle is a helper function that adds a handler to the mock server's handlers map and returns that handler function when the endpoint is called.
func Start ¶
Start() initializes a new server which mocks the Sectigo REST API. By default, it sets up HTTP handlers which return 200 OK responses with mocked data, but custom handlers can be passed in by tests to test specific error paths. Note that this function modifies the externally used baseURL for the Sectigo endpoint, and the caller must call Stop() to close the server and undo the mock when done. Start() takes one paramter, which is the name of the sectigo profile that the mock server uses to verify request parameters in createSingleCertBatch.
Types ¶
type Profile ¶ added in v1.3.1
type Profile struct { ID string Name string Balance int Params []ProfileParam }
type ProfileParam ¶ added in v1.5.1
type ProfileParam struct { Name string Validate validationFunc }
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server helps verify that the success paths of the Sectigo API calls are working, while also providing a way for tests to inject handlers to test the errors that might be returned from the Sectigo API.