mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-02 08:19:23 +02:00
core/authenticate: refactor identity authenticators to initiate redirect (#4858)
* core/authenticate: refactor identity authenticators to initiate redirect, use cookie for redirect url for cognito * set secure and http only, update test
This commit is contained in:
parent
4c15b202d1
commit
3adbc65d37
14 changed files with 237 additions and 125 deletions
42
internal/handlers/signedout_test.go
Normal file
42
internal/handlers/signedout_test.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package handlers_test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/handlers"
|
||||
)
|
||||
|
||||
func TestSignedOut(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("ok", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
r := httptest.NewRequest(http.MethodGet, "/.pomerium/signed_out", nil)
|
||||
|
||||
handlers.SignedOut(handlers.SignedOutData{}).ServeHTTP(w, r)
|
||||
|
||||
assert.Equal(t, http.StatusOK, w.Code)
|
||||
})
|
||||
|
||||
t.Run("redirect", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
r := httptest.NewRequest(http.MethodGet, "/.pomerium/signed_out", nil)
|
||||
r.AddCookie(&http.Cookie{
|
||||
Name: "_pomerium_signed_out_redirect_uri",
|
||||
Value: "https://www.google.com",
|
||||
})
|
||||
|
||||
handlers.SignedOut(handlers.SignedOutData{}).ServeHTTP(w, r)
|
||||
|
||||
assert.Equal(t, http.StatusFound, w.Code)
|
||||
assert.Equal(t, "https://www.google.com", w.Header().Get("Location"))
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue