go-loose/internal/server/oidc_test.go
2026-10-01 23:15:57 +02:00

22 lines
696 B
Go

package server
import (
"net/http/httptest"
"testing"
"github.com/danyel/go-loose/internal/config"
)
func TestOAuthStateCookieDomain(t *testing.T) {
server := &Server{cfg: config.Config{AuthDomain: "auth.local"}}
tenantRequest := httptest.NewRequest("GET", "http://nmbs.auth.local/auth/start", nil)
if domain := server.oauthStateCookieDomain(tenantRequest); domain != "auth.local" {
t.Fatalf("tenant cookie domain = %q, want auth.local", domain)
}
localRequest := httptest.NewRequest("GET", "http://localhost:8080/auth/start", nil)
if domain := server.oauthStateCookieDomain(localRequest); domain != "" {
t.Fatalf("local cookie domain = %q, want host-only cookie", domain)
}
}