mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 18:36:30 +02:00
25 lines
683 B
Go
25 lines
683 B
Go
package httputil
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/pomerium/pomerium/internal/telemetry/requestid"
|
|
)
|
|
|
|
func TestDefaultClient(t *testing.T) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
for _, header := range []string{"X-B3-Sampled", "X-B3-Spanid", "X-B3-Traceid", "X-Request-Id"} {
|
|
if _, ok := r.Header[header]; !ok {
|
|
t.Errorf("header %s is not set", header)
|
|
}
|
|
}
|
|
w.WriteHeader(http.StatusOK)
|
|
}))
|
|
defer ts.Close()
|
|
req, _ := http.NewRequest(http.MethodGet, ts.URL, nil)
|
|
req = req.WithContext(requestid.WithValue(context.Background(), "foo"))
|
|
_, _ = defaultClient.Do(req)
|
|
}
|