mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-29 22:48:15 +02:00
various bugfixes and improvements
This commit is contained in:
parent
e221c8af84
commit
51fa483885
12 changed files with 819 additions and 306 deletions
55
internal/testenv/selftests/tracing_test.go
Normal file
55
internal/testenv/selftests/tracing_test.go
Normal file
|
@ -0,0 +1,55 @@
|
|||
package selftests_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/pomerium/pomerium/config"
|
||||
"github.com/pomerium/pomerium/internal/testenv"
|
||||
"github.com/pomerium/pomerium/internal/testenv/scenarios"
|
||||
"github.com/pomerium/pomerium/internal/testenv/snippets"
|
||||
"github.com/pomerium/pomerium/internal/testenv/upstreams"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
func TestOTLPTracing(t *testing.T) {
|
||||
t.Setenv("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", "http://localhost:4317")
|
||||
env := testenv.New(t)
|
||||
defer env.Stop()
|
||||
env.Add(testenv.ModifierFunc(func(ctx context.Context, cfg *config.Config) {
|
||||
cfg.Options.ProxyLogLevel = config.LogLevelInfo
|
||||
}))
|
||||
up := upstreams.HTTP(nil, upstreams.WithDisplayName("Upstream"))
|
||||
up.Handle("/foo", func(w http.ResponseWriter, req *http.Request) {
|
||||
w.Write([]byte("OK"))
|
||||
})
|
||||
env.Add(scenarios.NewIDP([]*scenarios.User{
|
||||
{
|
||||
Email: "foo@example.com",
|
||||
FirstName: "Firstname",
|
||||
LastName: "Lastname",
|
||||
},
|
||||
}))
|
||||
|
||||
route := up.Route().
|
||||
From(env.SubdomainURL("foo")).
|
||||
PPL(`{"allow":{"and":["email":{"is":"foo@example.com"}]}}`)
|
||||
|
||||
env.AddUpstream(up)
|
||||
env.Start()
|
||||
snippets.WaitStartupComplete(env)
|
||||
|
||||
ctx, span := env.Tracer().Start(env.Context(), "Authenticate", trace.WithNewRoot())
|
||||
resp, err := up.Get(route, upstreams.AuthenticateAs("foo@example.com"), upstreams.Path("/foo"), upstreams.Context(ctx))
|
||||
span.End()
|
||||
require.NoError(t, err)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
resp.Body.Close()
|
||||
assert.Equal(t, resp.StatusCode, 200)
|
||||
assert.Equal(t, "OK", string(body))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue