Documentation ¶
Overview ¶
Utility functions for testing net2/http2
Index ¶
- func EnsureListen(c *C, hostport string)
- func GenerateCertWithCA(hostname string) ([]byte, []byte, []byte, error)
- func GenerateCertWithCAPrefs(hostname string, lookupIps bool, expiration time.Duration) ([]byte, []byte, []byte, error)
- func GenerateSelfSignedCert(hostname string) ([]byte, []byte, error)
- func PrivDerToPem(priv *rsa.PrivateKey) []byte
- func PubDerToPem(der []byte) []byte
- func RandomListenPort(c *C) int
- type CustomHandler
- type TestServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureListen ¶
func EnsureListen(c *C, hostport string)
This checks to ensure a server is running on the specified host port. DO NOT USE IN PRODUCTION.
func GenerateCertWithCA ¶
generate CA and certificate signed by generated CA. Returns CA's certificate, certificate, private key, error
func GenerateCertWithCAPrefs ¶
func GenerateSelfSignedCert ¶
GenerateSelfSignedCert genereate self-signed certificate and returns public certificate in pem, private key in pem, error.
func PrivDerToPem ¶
func PrivDerToPem(priv *rsa.PrivateKey) []byte
PrivDerToPem converts rsa private key from der to pem.
func PubDerToPem ¶
PubDerToPem converts public key from der format to pem.
func RandomListenPort ¶
func RandomListenPort(c *C) int
This returns a random port for unit testing. DO NOT USE IN PRODUCTION.
Types ¶
type CustomHandler ¶
type CustomHandler struct {
Handler func(witer http.ResponseWriter, req *http.Request)
}
func (*CustomHandler) ServeHTTP ¶
func (c *CustomHandler) ServeHTTP( writer http.ResponseWriter, req *http.Request)
type TestServer ¶
func SetupTestServer ¶
func SetupTestServer(ssl bool) (*TestServer, string)
Create a dummy server for unittesting. DO NOT USE IN PRODUCTION.
Click to show internal directories.
Click to hide internal directories.