mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 18:36:30 +02:00
integration: check for profile cookies (#4847)
Update the authentication flow integration test to verify that the pomerium_identity_profile cookies are not present for the stateful authentication flow.
This commit is contained in:
parent
fe46ed33f4
commit
a6ae9d3f2d
3 changed files with 31 additions and 0 deletions
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/pomerium/pomerium/integration/flows"
|
"github.com/pomerium/pomerium/integration/flows"
|
||||||
|
"github.com/pomerium/pomerium/pkg/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRouteSessions(t *testing.T) {
|
func TestRouteSessions(t *testing.T) {
|
||||||
|
@ -48,6 +49,14 @@ func TestRouteSessions(t *testing.T) {
|
||||||
// Under the stateful authenticate flow, the two routes should share
|
// Under the stateful authenticate flow, the two routes should share
|
||||||
// the same session.
|
// the same session.
|
||||||
assert.Equal(t, claims1.ID, claims2.ID)
|
assert.Equal(t, claims1.ID, claims2.ID)
|
||||||
|
|
||||||
|
// The only cookies set on the authenticate service domain should be
|
||||||
|
// "_pomerium_authenticate" and "_pomerium_csrf". (No identity profile
|
||||||
|
// cookies should be present.)
|
||||||
|
c := client.Jar.Cookies(mustParseURL("https://authenticate.localhost.pomerium.io"))
|
||||||
|
assert.Equal(t, 2, len(c))
|
||||||
|
cookieNames := slices.Map(c, func(c *http.Cookie) string { return c.Name })
|
||||||
|
assert.ElementsMatch(t, []string{"_pomerium_authenticate", "_pomerium_csrf"}, cookieNames)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,16 @@ func Filter[S ~[]E, E any](s S, f func(E) bool) S {
|
||||||
return ns
|
return ns
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Map constructs a new slice containing the elements obtained by invoking the
|
||||||
|
// function f on each element of s.
|
||||||
|
func Map[S ~[]E, E, T any](s S, f func(E) T) []T {
|
||||||
|
ns := make([]T, len(s))
|
||||||
|
for i := range s {
|
||||||
|
ns[i] = f(s[i])
|
||||||
|
}
|
||||||
|
return ns
|
||||||
|
}
|
||||||
|
|
||||||
// Remove removes e from s.
|
// Remove removes e from s.
|
||||||
func Remove[S ~[]E, E comparable](s S, e E) S {
|
func Remove[S ~[]E, E comparable](s S, e E) S {
|
||||||
var ns S
|
var ns S
|
||||||
|
|
|
@ -1,11 +1,23 @@
|
||||||
package slices
|
package slices
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestMap(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
in := []string{"one", "two", "three", "four"}
|
||||||
|
|
||||||
|
assert.Equal(t, []string{"ONE", "TWO", "THREE", "FOUR"}, Map(in, strings.ToUpper))
|
||||||
|
|
||||||
|
stringLen := func(s string) int { return len(s) }
|
||||||
|
assert.Equal(t, []int{3, 3, 5, 4}, Map(in, stringLen))
|
||||||
|
}
|
||||||
|
|
||||||
func TestReverse(t *testing.T) {
|
func TestReverse(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue