mirror of
https://github.com/goauthentik/authentik
synced 2026-04-27 09:57:31 +02:00
* packages/client-go: init Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> * format Signed-off-by: Jens Langhammer <jens@goauthentik.io> * remove mod/sum Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix translate Signed-off-by: Jens Langhammer <jens@goauthentik.io> * no go replace Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update rust makefile with pwd Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> * fix build Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix docs Signed-off-by: Jens Langhammer <jens@goauthentik.io> * don't need a version ig? Signed-off-by: Jens Langhammer <jens@goauthentik.io> * exclude go client from cspell Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix main docker build Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: Jens Langhammer <jens@goauthentik.io>
72 lines
2.0 KiB
Go
72 lines
2.0 KiB
Go
package application
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
api "goauthentik.io/packages/client-go"
|
|
)
|
|
|
|
func TestCheckRedirectParam_None(t *testing.T) {
|
|
a := newTestApplication()
|
|
// Test no rd param
|
|
req, _ := http.NewRequest("GET", "/outpost.goauthentik.io/auth/start", nil)
|
|
|
|
rd, ok := a.checkRedirectParam(req)
|
|
|
|
assert.Equal(t, false, ok)
|
|
assert.Equal(t, "", rd)
|
|
}
|
|
|
|
func TestCheckRedirectParam_Invalid(t *testing.T) {
|
|
a := newTestApplication()
|
|
// Test invalid rd param
|
|
req, _ := http.NewRequest("GET", "/outpost.goauthentik.io/auth/start?rd=https://google.com", nil)
|
|
|
|
rd, ok := a.checkRedirectParam(req)
|
|
|
|
assert.Equal(t, false, ok)
|
|
assert.Equal(t, "", rd)
|
|
}
|
|
|
|
func TestCheckRedirectParam_ValidFull(t *testing.T) {
|
|
a := newTestApplication()
|
|
// Test valid full rd param
|
|
req, _ := http.NewRequest("GET", "/outpost.goauthentik.io/auth/start?rd=https://ext.t.goauthentik.io/test?foo", nil)
|
|
|
|
rd, ok := a.checkRedirectParam(req)
|
|
|
|
assert.Equal(t, true, ok)
|
|
assert.Equal(t, "https://ext.t.goauthentik.io/test?foo", rd)
|
|
}
|
|
|
|
func TestCheckRedirectParam_ValidPartial(t *testing.T) {
|
|
a := newTestApplication()
|
|
// Test valid partial rd param
|
|
req, _ := http.NewRequest("GET", "/outpost.goauthentik.io/auth/start?rd=/test?foo", nil)
|
|
|
|
rd, ok := a.checkRedirectParam(req)
|
|
|
|
assert.Equal(t, true, ok)
|
|
assert.Equal(t, "https://ext.t.goauthentik.io/test?foo", rd)
|
|
}
|
|
|
|
func TestCheckRedirectParam_Domain(t *testing.T) {
|
|
a := newTestApplication()
|
|
a.proxyConfig.Mode = api.PROXYMODE_FORWARD_DOMAIN.Ptr()
|
|
a.proxyConfig.CookieDomain = new("t.goauthentik.io")
|
|
req, _ := http.NewRequest("GET", "https://a.t.goauthentik.io/outpost.goauthentik.io/auth/start", nil)
|
|
|
|
rd, ok := a.checkRedirectParam(req)
|
|
|
|
assert.Equal(t, false, ok)
|
|
assert.Equal(t, "", rd)
|
|
req, _ = http.NewRequest("GET", "/outpost.goauthentik.io/auth/start?rd=https://ext.t.goauthentik.io/test", nil)
|
|
|
|
rd, ok = a.checkRedirectParam(req)
|
|
|
|
assert.Equal(t, true, ok)
|
|
assert.Equal(t, "https://ext.t.goauthentik.io/test", rd)
|
|
}
|