mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
refactor: fix tests
This commit is contained in:
parent
821e4a225a
commit
9a3c40f6a6
5 changed files with 8 additions and 19 deletions
|
@ -306,7 +306,7 @@ func TestInitOIDC(t *testing.T) {
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
_, err := NewOIDCProvider(tt.issuerURL, tt.clientID, tt.clientSecret, tt.redirectURL, tt.logoutURL, tt.allowedUsers, tt.allowedGroups)
|
_, err := NewOIDCProvider(tt.issuerURL, tt.clientID, tt.clientSecret, tt.redirectURL, tt.allowedUsers, tt.allowedGroups)
|
||||||
if (err != nil) != tt.wantErr {
|
if (err != nil) != tt.wantErr {
|
||||||
t.Errorf("InitOIDC() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("InitOIDC() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,11 @@ func TestIsJSONMarshallable(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "baseError",
|
name: "baseError",
|
||||||
err: &baseError{},
|
err: &baseError{},
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "baseError with json marshallable error",
|
||||||
|
err: &baseError{&testErr{}},
|
||||||
want: true,
|
want: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,6 +52,7 @@ func NewServer(name string, url *net.URL, weight Weight, handler http.Handler, h
|
||||||
func TestNewServer[T ~int | ~float32 | ~float64](weight T) Server {
|
func TestNewServer[T ~int | ~float32 | ~float64](weight T) Server {
|
||||||
srv := &server{
|
srv := &server{
|
||||||
weight: Weight(weight),
|
weight: Weight(weight),
|
||||||
|
url: net.MustParseURL("http://localhost"),
|
||||||
}
|
}
|
||||||
return srv
|
return srv
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/yusing/go-proxy/internal/common"
|
|
||||||
"github.com/yusing/go-proxy/internal/net/types"
|
"github.com/yusing/go-proxy/internal/net/types"
|
||||||
. "github.com/yusing/go-proxy/internal/utils/testing"
|
. "github.com/yusing/go-proxy/internal/utils/testing"
|
||||||
)
|
)
|
||||||
|
@ -15,7 +14,7 @@ func TestRedirectToHTTPs(t *testing.T) {
|
||||||
})
|
})
|
||||||
ExpectNoError(t, err)
|
ExpectNoError(t, err)
|
||||||
ExpectEqual(t, result.ResponseStatus, http.StatusPermanentRedirect)
|
ExpectEqual(t, result.ResponseStatus, http.StatusPermanentRedirect)
|
||||||
ExpectEqual(t, result.ResponseHeaders.Get("Location"), "https://example.com:"+common.ProxyHTTPSPort)
|
ExpectEqual(t, result.ResponseHeaders.Get("Location"), "https://example.com")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNoRedirect(t *testing.T) {
|
func TestNoRedirect(t *testing.T) {
|
||||||
|
|
|
@ -8,19 +8,6 @@ theGreatPretender:
|
||||||
- X-Test3
|
- X-Test3
|
||||||
- X-Test4
|
- X-Test4
|
||||||
|
|
||||||
notAuthenticAuthentik:
|
|
||||||
- use: RedirectHTTP
|
|
||||||
- use: ForwardAuth
|
|
||||||
address: https://authentik.company
|
|
||||||
trustForwardHeader: true
|
|
||||||
addAuthCookiesToResponse:
|
|
||||||
- session_id
|
|
||||||
- user_id
|
|
||||||
authResponseHeaders:
|
|
||||||
- X-Auth-SessionID
|
|
||||||
- X-Auth-UserID
|
|
||||||
- use: CustomErrorPage
|
|
||||||
|
|
||||||
realIPAuthentik:
|
realIPAuthentik:
|
||||||
- use: RedirectHTTP
|
- use: RedirectHTTP
|
||||||
- use: RealIP
|
- use: RealIP
|
||||||
|
@ -30,9 +17,6 @@ realIPAuthentik:
|
||||||
- "192.168.0.0/16"
|
- "192.168.0.0/16"
|
||||||
- "172.16.0.0/12"
|
- "172.16.0.0/12"
|
||||||
recursive: true
|
recursive: true
|
||||||
- use: ForwardAuth
|
|
||||||
address: https://authentik.company
|
|
||||||
trustForwardHeader: true
|
|
||||||
|
|
||||||
testFakeRealIP:
|
testFakeRealIP:
|
||||||
- use: ModifyRequest
|
- use: ModifyRequest
|
||||||
|
|
Loading…
Add table
Reference in a new issue