{"modulePath":"github.com/cloudfoundry/gorouter","version":"v0.0.0-20250429140807-a602bb6a6243","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package test_util\n\n## Constants\n\n```go\nconst (\n\tTLSConfigFromCACerts       = 1\n\tTLSConfigFromClientCACerts = 2\n\tTLSConfigFromUnknownCA     = 3\n)\n```\n\n```go\nconst LocalhostDNS = \"localhost.routing.cf-app.com\"\n```\nOur tests assume that there exists a DNS entry \\*.localhost.routing.cf-app.com that maps to 127.0.0.1 If that DNS entry does not work, then many, many tests will fail\n\n## Functions\n\n```go\nfunc CreateCert(cname string) tls.Certificate\n```\n\n```go\nfunc CreateCertDER(cname string) (*rsa.PrivateKey, []byte)\n```\n\n```go\nfunc CreateECDSACertDER(cname string) (*ecdsa.PrivateKey, []byte)\n```\n\n```go\nfunc CreateECDSAKeyPairFromDER(certDER []byte, privKey *ecdsa.PrivateKey) (keyPEM, certPEM []byte)\n```\n\n```go\nfunc CreateECKeyPair(cname string) (keyPEM, certPEM []byte)\n```\n\n```go\nfunc CreateKeyPair(cname string) (keyPEM, certPEM []byte)\n```\n\n```go\nfunc CreateKeyPairFromDER(certDER []byte, privKey *rsa.PrivateKey) (keyPEM, certPEM []byte)\n```\n\n```go\nfunc CustomSpecSSLConfig(onlyTrustClientCACerts bool, TLSClientConfigOption int, statusPort, statusTLSPort, statusRoutesPort, proxyPort, SSLPort, routeServiceServerPort uint16, natsPorts ...uint16) (*config.Config, *tls.Config)\n```\n\n```go\nfunc NewFakeMetron() *fakeMetron\n```\n\n```go\nfunc NewRequest(method, host, rawPath string, body io.Reader) *http.Request\n```\n\n```go\nfunc NewResponse(status int) *http.Response\n```\n\n```go\nfunc NextAvailPort() uint16\n```\n\n```go\nfunc RegisterAddr(reg *registry.RouteRegistry, path string, addr string, cfg RegisterConfig)\n```\n\n```go\nfunc RegisterConnHandler(reg *registry.RouteRegistry, path string, handler connHandler, cfg ...RegisterConfig) net.Listener\n```\n\n```go\nfunc RegisterHTTPHandler(reg *registry.RouteRegistry, path string, handler http.HandlerFunc, cfg ...RegisterConfig) net.Listener\n```\n\n```go\nfunc RegisterWSHandler(reg *registry.RouteRegistry, path string, handler websocket.Handler, cfg ...RegisterConfig) net.Listener\n```\n\n```go\nfunc SpecConfig(statusPort, statusTLSPort, statusRoutesPort, proxyPort, routeServiceServerPort uint16, natsPorts ...uint16) *config.Config\n```\n\n```go\nfunc SpecSSLConfig(statusPort, statusTLSPort, statusRoutesPort, proxyPort, SSLPort, routeServiceServerPort uint16, natsPorts ...uint16) (*config.Config, *tls.Config)\n```\n\n## Types\n\n```go\ntype CertChain struct {\n\tCertPEM, CACertPEM       []byte\n\tPrivKeyPEM, CAPrivKeyPEM []byte\n\n\tCACert         *x509.Certificate\n\tCAPrivKey      *rsa.PrivateKey\n\tCAPrivKeyECDSA *ecdsa.PrivateKey\n}\n```\n\n```go\nfunc CreateCertAndAddCA(cn CertNames, cp *x509.CertPool) CertChain\n```\nCreateCertAndAddCA creates a signed cert with a root CA and adds the CA to the specified cert pool\n\n```go\nfunc CreateExpiredSignedCertWithRootCA(cert CertNames) CertChain\n```\n\n```go\nfunc CreateSignedCertWithRootCA(cert CertNames) CertChain\n```\n\n```go\nfunc CreateSignedECDSACertWithRootCA(cert CertNames) CertChain\n```\n\n```go\nfunc (cc *CertChain) AsTLSConfig() *tls.Config\n```\n\n```go\nfunc (c *CertChain) TLSCert() tls.Certificate\n```\n\n```go\nfunc (cc *CertChain) WriteCACertToDir(dir string) string\n```\n\n```go\ntype CertNames struct {\n\tCommonName string\n\tSANs       SubjectAltNames\n}\n```\n\n```go\ntype Event struct {\n\tEventType string\n\tName      string\n\tOrigin    string\n\tValue     float64\n}\n```\n\n```go\ntype FailureReporter struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewFailureReporter(client client.Client) FailureReporter\n```\n\n```go\nfunc (fr FailureReporter) AfterSuiteDidRun(setupSummary *types.SetupSummary)\n```\n\n```go\nfunc (fr FailureReporter) BeforeSuiteDidRun(setupSummary *types.SetupSummary)\n```\n\n```go\nfunc (fr FailureReporter) SpecDidComplete(ss *types.SpecSummary)\n```\n\n```go\nfunc (fr FailureReporter) SpecSuiteDidEnd(summary *types.SuiteSummary)\n```\n\n```go\nfunc (fr FailureReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary)\n```\n\n```go\nfunc (fr FailureReporter) SpecWillRun(specSummary *types.SpecSummary)\n```\n\n```go\nfunc (fr FailureReporter) SuiteDidEnd(summary *types.SuiteSummary)\n```\n\n```go\nfunc (fr FailureReporter) SuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary)\n```\n\n```go\ntype FakeFile struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (f *FakeFile) Read(data *[]byte) (int, error)\n```\n\n```go\nfunc (f *FakeFile) Write(data []byte) (int, error)\n```\n\n```go\ntype FakeMetron interface {\n\tAllEvents() []Event\n\n\tAddress() string\n\tClose() error\n\tPort() int\n}\n```\n\n```go\ntype HangingReadCloser struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (h *HangingReadCloser) Close() error\n```\n\n```go\nfunc (h *HangingReadCloser) Read(p []byte) (n int, err error)\n```\n\n```go\ntype HttpConn struct {\n\tnet.Conn\n\n\tReader *bufio.Reader\n\tWriter *bufio.Writer\n}\n```\n\n```go\nfunc NewHttpConn(x net.Conn) *HttpConn\n```\n\n```go\nfunc (x *HttpConn) CheckLine(expected string)\n```\n\n```go\nfunc (x *HttpConn) CheckLines(expected []string)\n```\n\n```go\nfunc (x *HttpConn) ReadRequest() (*http.Request, string)\n```\n\n```go\nfunc (x *HttpConn) ReadResponse() (*http.Response, string)\n```\n\n```go\nfunc (x *HttpConn) WriteLine(line string) error\n```\n\n```go\nfunc (x *HttpConn) WriteLines(lines []string) error\n```\n\n```go\nfunc (x *HttpConn) WriteRequest(req *http.Request)\n```\n\n```go\nfunc (x *HttpConn) WriteResponse(resp *http.Response)\n```\n\n```go\ntype NATSRunner struct {\n\tMessageBus *nats.Conn\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewNATSRunner(port int) *NATSRunner\n```\n\n```go\nfunc (runner *NATSRunner) KillWithFire()\n```\n\n```go\nfunc (runner *NATSRunner) Start()\n```\n\n```go\nfunc (runner *NATSRunner) Stop()\n```\n\n```go\ntype Nats struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewNats(port uint16) *Nats\n```\n\n```go\nfunc (n *Nats) Port() uint16\n```\n\n```go\nfunc (n *Nats) Start()\n```\n\n```go\nfunc (n *Nats) Stop()\n```\n\n```go\ntype RegisterConfig struct {\n\tRouteServiceUrl     string\n\tServerCertDomainSAN string\n\tInstanceId          string\n\tInstanceIndex       string\n\tAppId               string\n\tStaleThreshold      int\n\tTLSConfig           *tls.Config\n\tIgnoreTLSConfig     bool\n\tProtocol            string\n}\n```\n\n```go\ntype SlowReadCloser struct {\n\tSleepDuration time.Duration\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (h *SlowReadCloser) Close() error\n```\n\n```go\nfunc (h *SlowReadCloser) Read(p []byte) (n int, err error)\n```\n\n```go\ntype SubjectAltNames struct {\n\tDNS string\n\tIP  string\n}\n```\n\n```go\ntype TestLogger struct {\n\t*slog.Logger\n\t*TestSink\n}\n```\nTestLogger implements an slog logger that can be used with Ginkgo tests\n\n```go\nfunc NewTestLogger(component string) *TestLogger\n```\nNewTestLogger returns a new slog logger using a zap handler\n\n```go\nfunc (z *TestLogger) Buffer() *gbytes.Buffer\n```\nBuffer returns the gbytes buffer that was used as the sink\n\n```go\nfunc (z *TestLogger) Lines(level zapcore.Level) []string\n```\n\n```go\ntype TestSink struct {\n\t*gbytes.Buffer\n}\n```\nTaken from go.uber.org/zap\n\n```go\nfunc (s *TestSink) Lines() []string\n```\n\n```go\nfunc (s *TestSink) Sync() error\n```\n\n","path":"github.com/cloudfoundry/gorouter/test_util","name":"test_util","synopsis":"","isRedistributable":true}
