mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-30 02:46:30 +02:00
* integration-tests: switch to go for backends to support TLS scenarios * fix apply order * generate additional tls certs * integration-tests: tls_skip_verify option * integration-tests: wait for openid to come up before starting authenticate * add tls_server_name test * add test for tls_custom_ca * increase setup timeout to 15 minutes * fix secret name reference * mtls wip * mtls wip * add test for client_cert
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
// Package cluster is used to configure a kubernetes cluster for testing.
|
|
package cluster
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/cookiejar"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
"golang.org/x/net/publicsuffix"
|
|
)
|
|
|
|
// A Cluster is used to configure a kubernetes cluster.
|
|
type Cluster struct {
|
|
Transport *http.Transport
|
|
|
|
workingDir string
|
|
certsBundle *TLSCertsBundle
|
|
}
|
|
|
|
// New creates a new Cluster.
|
|
func New(workingDir string) *Cluster {
|
|
return &Cluster{
|
|
workingDir: workingDir,
|
|
}
|
|
}
|
|
|
|
// NewHTTPClient creates a new *http.Client, with a cookie jar, and a LocalRoundTripper
|
|
// which routes traffic to the nginx ingress controller.
|
|
func (cluster *Cluster) NewHTTPClient() *http.Client {
|
|
jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return &http.Client{
|
|
Transport: &loggingRoundTripper{cluster.Transport},
|
|
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
|
return http.ErrUseLastResponse
|
|
},
|
|
Jar: jar,
|
|
}
|
|
}
|
|
|
|
type loggingRoundTripper struct {
|
|
http.RoundTripper
|
|
}
|
|
|
|
func (rt *loggingRoundTripper) RoundTrip(req *http.Request) (res *http.Response, err error) {
|
|
res, err = rt.RoundTripper.RoundTrip(req)
|
|
log.Debug().Str("method", req.Method).Str("url", req.URL.String()).Msg("http request")
|
|
return res, err
|
|
}
|